org.apache.commons.math3.optimization.direct
Class BaseAbstractMultivariateOptimizer<FUNC extends MultivariateFunction>

java.lang.Object
  extended by org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer<FUNC>
Type Parameters:
FUNC - Type of the objective function to be optimized.
All Implemented Interfaces:
BaseMultivariateOptimizer<FUNC>, BaseOptimizer<PointValuePair>
Direct Known Subclasses:
AbstractScalarDifferentiableOptimizer, BaseAbstractMultivariateSimpleBoundsOptimizer, PowellOptimizer, SimplexOptimizer

public abstract class BaseAbstractMultivariateOptimizer<FUNC extends MultivariateFunction>
extends Object
implements BaseMultivariateOptimizer<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:
2.2
Version:
$Id$

Field Summary
private  ConvergenceChecker<PointValuePair> checker
          Convergence checker.
protected  Incrementor evaluations
          Evaluations counter.
private  MultivariateFunction function
          Objective function.
private  GoalType goal
          Type of optimization.
private  double[] start
          Initial guess.
 
Constructor Summary
protected BaseAbstractMultivariateOptimizer()
          Simple constructor with default settings.
protected BaseAbstractMultivariateOptimizer(ConvergenceChecker<PointValuePair> checker)
           
 
Method Summary
protected  double computeObjectiveValue(double[] point)
          Compute the objective function value.
protected abstract  PointValuePair doOptimize()
          Perform the bulk of the optimization algorithm.
 ConvergenceChecker<PointValuePair> getConvergenceChecker()
          Get the convergence checker.
 int getEvaluations()
          Get the number of evaluations of the objective function.
 GoalType getGoalType()
           
 int getMaxEvaluations()
          Get the maximal number of function evaluations.
 double[] getStartPoint()
           
 PointValuePair optimize(int maxEval, FUNC f, GoalType goalType, double[] startPoint)
          Optimize an objective function.
 
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.


checker

private ConvergenceChecker<PointValuePair> checker
Convergence checker.


goal

private GoalType goal
Type of optimization.


start

private double[] start
Initial guess.


function

private MultivariateFunction function
Objective function.

Constructor Detail

BaseAbstractMultivariateOptimizer

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


BaseAbstractMultivariateOptimizer

protected BaseAbstractMultivariateOptimizer(ConvergenceChecker<PointValuePair> checker)
Parameters:
checker - Convergence checker.
Method Detail

getMaxEvaluations

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

Specified by:
getMaxEvaluations in interface BaseOptimizer<PointValuePair>
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<PointValuePair>
Returns:
the number of evaluations of the objective function.

getConvergenceChecker

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

Specified by:
getConvergenceChecker in interface BaseOptimizer<PointValuePair>
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 PointValuePair optimize(int maxEval,
                               FUNC f,
                               GoalType goalType,
                               double[] startPoint)
Optimize an objective function.

Specified by:
optimize in interface BaseMultivariateOptimizer<FUNC extends MultivariateFunction>
Parameters:
maxEval - Maximum number of function evaluations.
f - Objective function.
goalType - Type of optimization goal: either GoalType.MAXIMIZE or GoalType.MINIMIZE.
startPoint - Start point for optimization.
Returns:
the point/value pair giving the optimal value for objective function.

getGoalType

public GoalType getGoalType()
Returns:
the optimization type.

getStartPoint

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

doOptimize

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

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


Copyright (c) 2003-2013 Apache Software Foundation