Moving classes to a more appropriate package.
Removed unused interfaces.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@999948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2010-09-22 13:54:25 +00:00
parent b625ebe85b
commit 8232bfbded
10 changed files with 43 additions and 91 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.math.optimization.general; package org.apache.commons.math.optimization.direct;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.util.Incrementor; import org.apache.commons.math.util.Incrementor;
@ -33,19 +33,14 @@ import org.apache.commons.math.optimization.SimpleScalarValueChecker;
* Base class for implementing optimizers for multivariate scalar functions. * Base class for implementing optimizers for multivariate scalar functions.
* This base class handles the boiler-plate methods associated to thresholds * This base class handles the boiler-plate methods associated to thresholds
* settings, iterations and evaluations counting. * settings, iterations and evaluations counting.
* This class is mainly intended to enforce the internal coherence of
* Commons-FastMath.
* A class that implements an optimization algorithm should inherit from
* {@link AbstractScalarOptimizer} or from
* {@link AbstractScalarDifferentiableOptimizer}.
* *
* @param <T> the type of the objective function to be optimized * @param <FUNC> Type of the objective function to be optimized
* *
* @version $Revision$ $Date$ * @version $Revision$ $Date$
* @since 2.2 * @since 2.2
*/ */
public abstract class BaseAbstractScalarOptimizer<T extends MultivariateRealFunction> public abstract class BaseAbstractScalarOptimizer<FUNC extends MultivariateRealFunction>
implements BaseMultivariateRealOptimizer<T> { implements BaseMultivariateRealOptimizer<FUNC> {
/** Evaluations counter. */ /** Evaluations counter. */
protected final Incrementor evaluations = new Incrementor(); protected final Incrementor evaluations = new Incrementor();
/** Convergence checker. */ /** Convergence checker. */
@ -120,7 +115,7 @@ public abstract class BaseAbstractScalarOptimizer<T extends MultivariateRealFunc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public RealPointValuePair optimize(T f, public RealPointValuePair optimize(FUNC f,
GoalType goalType, GoalType goalType,
double[] startPoint) double[] startPoint)
throws FunctionEvaluationException { throws FunctionEvaluationException {

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.math.optimization.general; package org.apache.commons.math.optimization.direct;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.util.Incrementor; import org.apache.commons.math.util.Incrementor;

View File

@ -22,14 +22,13 @@ import java.util.Comparator;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.exception.DimensionMismatchException; import org.apache.commons.math.exception.DimensionMismatchException;
import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.GoalType; import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
import org.apache.commons.math.optimization.ConvergenceChecker; import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.SimpleScalarValueChecker; import org.apache.commons.math.optimization.SimpleScalarValueChecker;
import org.apache.commons.math.optimization.general.AbstractScalarOptimizer;
/** /**
* This class implements simplex-based direct search optimization * This class implements simplex-based direct search optimization
@ -76,8 +75,6 @@ import org.apache.commons.math.optimization.general.AbstractScalarOptimizer;
* performed by the derived classes according to the implemented * performed by the derived classes according to the implemented
* algorithms.</p> * algorithms.</p>
* *
* implements MultivariateRealOptimizer since 2.0
*
* @see MultivariateRealFunction * @see MultivariateRealFunction
* @see NelderMead * @see NelderMead
* @see MultiDirectional * @see MultiDirectional
@ -85,8 +82,7 @@ import org.apache.commons.math.optimization.general.AbstractScalarOptimizer;
* @since 1.2 * @since 1.2
*/ */
public abstract class DirectSearchOptimizer public abstract class DirectSearchOptimizer
extends AbstractScalarOptimizer extends BaseAbstractScalarOptimizer<MultivariateRealFunction> {
implements MultivariateRealOptimizer {
/** Simplex. */ /** Simplex. */
protected RealPointValuePair[] simplex; protected RealPointValuePair[] simplex;
/** Start simplex configuration. */ /** Start simplex configuration. */

View File

@ -22,6 +22,7 @@ import java.util.Comparator;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.optimization.ConvergenceChecker; import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
/** /**
* This class implements the multi-directional direct search method. * This class implements the multi-directional direct search method.
@ -30,25 +31,27 @@ import org.apache.commons.math.optimization.RealPointValuePair;
* @see NelderMead * @see NelderMead
* @since 1.2 * @since 1.2
*/ */
public class MultiDirectional extends DirectSearchOptimizer { public class MultiDirectional extends DirectSearchOptimizer
implements MultivariateRealOptimizer {
/** Expansion coefficient. */ /** Expansion coefficient. */
private final double khi; private final double khi;
/** Contraction coefficient. */ /** Contraction coefficient. */
private final double gamma; private final double gamma;
/** Build a multi-directional optimizer with default coefficients. /**
* <p>The default values are 2.0 for khi and 0.5 for gamma.</p> * Build a multi-directional optimizer with default coefficients.
* The default values are 2.0 for khi and 0.5 for gamma.
*/ */
public MultiDirectional() { public MultiDirectional() {
this.khi = 2.0; this.khi = 2.0;
this.gamma = 0.5; this.gamma = 0.5;
} }
/** Build a multi-directional optimizer with specified coefficients. /**
* @param khi expansion coefficient * Build a multi-directional optimizer with specified coefficients.
* @param gamma contraction coefficient *
* @param khi Expansion coefficient.
* @param gamma Contraction coefficient.
*/ */
public MultiDirectional(final double khi, final double gamma) { public MultiDirectional(final double khi, final double gamma) {
this.khi = khi; this.khi = khi;

View File

@ -21,6 +21,7 @@ import java.util.Comparator;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
/** /**
* This class implements the Nelder-Mead direct search method. * This class implements the Nelder-Mead direct search method.
@ -29,23 +30,21 @@ import org.apache.commons.math.optimization.RealPointValuePair;
* @see MultiDirectional * @see MultiDirectional
* @since 1.2 * @since 1.2
*/ */
public class NelderMead extends DirectSearchOptimizer { public class NelderMead extends DirectSearchOptimizer
implements MultivariateRealOptimizer {
/** Reflection coefficient. */ /** Reflection coefficient. */
private final double rho; private final double rho;
/** Expansion coefficient. */ /** Expansion coefficient. */
private final double khi; private final double khi;
/** Contraction coefficient. */ /** Contraction coefficient. */
private final double gamma; private final double gamma;
/** Shrinkage coefficient. */ /** Shrinkage coefficient. */
private final double sigma; private final double sigma;
/** Build a Nelder-Mead optimizer with default coefficients. /**
* <p>The default coefficients are 1.0 for rho, 2.0 for khi and 0.5 * Build a Nelder-Mead optimizer with default coefficients.
* for both gamma and sigma.</p> * The default coefficients are 1.0 for rho, 2.0 for khi and 0.5
* for both gamma and sigma.
*/ */
public NelderMead() { public NelderMead() {
this.rho = 1.0; this.rho = 1.0;
@ -54,11 +53,13 @@ public class NelderMead extends DirectSearchOptimizer {
this.sigma = 0.5; this.sigma = 0.5;
} }
/** Build a Nelder-Mead optimizer with specified coefficients. /**
* @param rho reflection coefficient * Build a Nelder-Mead optimizer with specified coefficients.
* @param khi expansion coefficient *
* @param gamma contraction coefficient * @param rho Reflection coefficient.
* @param sigma shrinkage coefficient * @param khi Expansion coefficient.
* @param gamma Contraction coefficient.
* @param sigma Shrinkage coefficient.
*/ */
public NelderMead(final double rho, final double khi, public NelderMead(final double rho, final double khi,
final double gamma, final double sigma) { final double gamma, final double sigma) {

View File

@ -15,18 +15,20 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.math.optimization.general; package org.apache.commons.math.optimization.direct;
import java.util.Arrays; import java.util.Arrays;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.util.FastMath; import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.analysis.UnivariateRealFunction; import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.exception.NumberIsTooSmallException; import org.apache.commons.math.exception.NumberIsTooSmallException;
import org.apache.commons.math.exception.NotStrictlyPositiveException; import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.optimization.GoalType; import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.ConvergenceChecker; import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
import org.apache.commons.math.optimization.univariate.BracketFinder; import org.apache.commons.math.optimization.univariate.BracketFinder;
import org.apache.commons.math.optimization.univariate.BrentOptimizer; import org.apache.commons.math.optimization.univariate.BrentOptimizer;
import org.apache.commons.math.optimization.univariate.UnivariateRealPointValuePair; import org.apache.commons.math.optimization.univariate.UnivariateRealPointValuePair;
@ -47,7 +49,8 @@ import org.apache.commons.math.optimization.univariate.UnivariateRealPointValueP
* @since 2.2 * @since 2.2
*/ */
public class PowellOptimizer public class PowellOptimizer
extends AbstractScalarOptimizer { extends BaseAbstractScalarOptimizer<MultivariateRealFunction>
implements MultivariateRealOptimizer {
/** /**
* Minimum relative tolerance. * Minimum relative tolerance.
*/ */

View File

@ -29,6 +29,7 @@ import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.optimization.ConvergenceChecker; import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer; import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.VectorialPointValuePair; import org.apache.commons.math.optimization.VectorialPointValuePair;
import org.apache.commons.math.optimization.direct.BaseAbstractVectorialOptimizer;
import org.apache.commons.math.util.FastMath; import org.apache.commons.math.util.FastMath;
/** /**
@ -72,7 +73,8 @@ public abstract class AbstractLeastSquaresOptimizer
/** /**
* Simple constructor with default settings. * Simple constructor with default settings.
* The convergence check is set to a {@link SimpleVectorialValueChecker}. * The convergence check is set to a {@link
* org.apache.commons.math.optimization.SimpleVectorialValueChecker}.
*/ */
protected AbstractLeastSquaresOptimizer() {} protected AbstractLeastSquaresOptimizer() {}
/** /**

View File

@ -24,6 +24,7 @@ import org.apache.commons.math.optimization.DifferentiableMultivariateRealOptimi
import org.apache.commons.math.optimization.GoalType; import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.ConvergenceChecker; import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.direct.BaseAbstractScalarOptimizer;
/** /**
* Base class for implementing optimizers for multivariate scalar * Base class for implementing optimizers for multivariate scalar

View File

@ -1,49 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.optimization.general;
import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
import org.apache.commons.math.optimization.ConvergenceChecker;
import org.apache.commons.math.optimization.RealPointValuePair;
/**
* Base class for implementing optimizers for multivariate (not necessarily
* differentiable) scalar functions.
*
* @version $Revision$ $Date$
* @since 2.2
*/
public abstract class AbstractScalarOptimizer
extends BaseAbstractScalarOptimizer<MultivariateRealFunction>
implements MultivariateRealOptimizer {
/**
* Simple constructor with default settings.
* The convergence check is set to a
* {@link org.apache.commons.math.optimization.SimpleScalarValueChecker}.
*/
protected AbstractScalarOptimizer() {}
/**
* @param checker Convergence checker.
* @param maxEvaluations Maximum number of function evaluations.
*/
protected AbstractScalarOptimizer(ConvergenceChecker<RealPointValuePair> checker,
int maxEvaluations) {
super(checker, maxEvaluations);
}
}

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.commons.math.optimization.general; package org.apache.commons.math.optimization.direct;
import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathException; import org.apache.commons.math.MathException;