org.apache.commons.math.optimization.direct
Class BaseAbstractVectorialOptimizer<FUNC extends MultivariateVectorialFunction>

java.lang.Object
  extended by org.apache.commons.math.optimization.direct.BaseAbstractVectorialOptimizer<FUNC>
Type Parameters:
FUNC - the type of the objective function to be optimized
All Implemented Interfaces:
BaseMultivariateVectorialOptimizer<FUNC>, BaseOptimizer<VectorialPointValuePair>
Direct Known Subclasses:
AbstractLeastSquaresOptimizer

public abstract class BaseAbstractVectorialOptimizer<FUNC extends MultivariateVectorialFunction>
extends java.lang.Object
implements BaseMultivariateVectorialOptimizer<FUNC>

Base class for implementing optimizers for multivariate scalar functions. This base class handles the boiler-plate methods associated to thresholds settings, iterations and evaluations counting.

Since:
3.0
Version:
$Id$

Field Summary
protected  Incrementor evaluations
          Evaluations counter.
 
Constructor Summary
protected BaseAbstractVectorialOptimizer()
          Simple constructor with default settings.
protected BaseAbstractVectorialOptimizer(ConvergenceChecker<VectorialPointValuePair> checker)
           
 
Method Summary
protected  double[] computeObjectiveValue(double[] point)
          Compute the objective function value.
protected abstract  VectorialPointValuePair doOptimize()
          Perform the bulk of the optimization algorithm.
 ConvergenceChecker<VectorialPointValuePair> getConvergenceChecker()
          Get the convergence checker.
 int getEvaluations()
          Get the number of evaluations of the objective function.
 int getMaxEvaluations()
          Get the maximal number of function evaluations.
 double[] getStartPoint()
           
protected  double[] getTargetRef()
           
protected  double[] getWeightRef()
           
 VectorialPointValuePair optimize(int maxEval, FUNC f, double[] t, double[] w, double[] startPoint)
          Optimize an objective function.
 void setConvergenceChecker(ConvergenceChecker<VectorialPointValuePair> convergenceChecker)
          Set the convergence checker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

evaluations

protected final Incrementor evaluations
Evaluations counter.

Constructor Detail

BaseAbstractVectorialOptimizer

protected BaseAbstractVectorialOptimizer()
Simple constructor with default settings. The convergence check is set to a SimpleVectorialValueChecker and the allowed number of evaluations is set to Integer.MAX_VALUE.


BaseAbstractVectorialOptimizer

protected BaseAbstractVectorialOptimizer(ConvergenceChecker<VectorialPointValuePair> checker)
Parameters:
checker - Convergence checker.
Method Detail

getMaxEvaluations

public int getMaxEvaluations()
Get the maximal number of function evaluations.

Specified by:
getMaxEvaluations in interface BaseOptimizer<VectorialPointValuePair>
Returns:
the maximal number of function evaluations.

getEvaluations

public int getEvaluations()
Get the number of evaluations of the objective function. The number of evaluations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.

Specified by:
getEvaluations in interface BaseOptimizer<VectorialPointValuePair>
Returns:
the number of evaluations of the objective function.

setConvergenceChecker

public void setConvergenceChecker(ConvergenceChecker<VectorialPointValuePair> convergenceChecker)
Set the convergence checker.

Specified by:
setConvergenceChecker in interface BaseOptimizer<VectorialPointValuePair>
Parameters:
convergenceChecker - Object to use to check for convergence.

getConvergenceChecker

public ConvergenceChecker<VectorialPointValuePair> getConvergenceChecker()
Get the convergence checker.

Specified by:
getConvergenceChecker in interface BaseOptimizer<VectorialPointValuePair>
Returns:
the object used to check for convergence.

computeObjectiveValue

protected double[] computeObjectiveValue(double[] point)
Compute the objective function value.

Parameters:
point - Point at which the objective function must be evaluated.
Returns:
the objective function value at the specified point.
Throws:
TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

optimize

public VectorialPointValuePair optimize(int maxEval,
                                        FUNC f,
                                        double[] t,
                                        double[] w,
                                        double[] startPoint)
Optimize an objective function. Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is ∑weighti(objectivei - targeti)2

Specified by:
optimize in interface BaseMultivariateVectorialOptimizer<FUNC extends MultivariateVectorialFunction>
Parameters:
maxEval - Maximum number of function evaluations.
f - Objective function.
t - Target value for the objective functions at optimum.
w - Weights for the least squares cost computation.
startPoint - Start point for optimization.
Returns:
the point/value pair giving the optimal value for objective function.

getStartPoint

public double[] getStartPoint()
Returns:
the initial guess.

doOptimize

protected abstract VectorialPointValuePair doOptimize()
Perform the bulk of the optimization algorithm.

Returns:
the point/value pair giving the optimal value for the objective function.

getTargetRef

protected double[] getTargetRef()
Returns:
a reference to the array.

getWeightRef

protected double[] getWeightRef()
Returns:
a reference to the array.


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.