org.apache.commons.math3.optimization.general
Class AbstractScalarDifferentiableOptimizer

java.lang.Object
  extended by org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer<DifferentiableMultivariateFunction>
      extended by org.apache.commons.math3.optimization.general.AbstractScalarDifferentiableOptimizer
All Implemented Interfaces:
BaseMultivariateOptimizer<DifferentiableMultivariateFunction>, BaseOptimizer<PointValuePair>, DifferentiableMultivariateOptimizer
Direct Known Subclasses:
NonLinearConjugateGradientOptimizer

public abstract class AbstractScalarDifferentiableOptimizer
extends BaseAbstractMultivariateOptimizer<DifferentiableMultivariateFunction>
implements DifferentiableMultivariateOptimizer

Base class for implementing optimizers for multivariate scalar differentiable functions. It contains boiler-plate code for dealing with gradient evaluation.

Since:
2.0
Version:
$Id: AbstractScalarDifferentiableOptimizer.java 1244107 2012-02-14 16:17:55Z erans $

Field Summary
private  MultivariateVectorFunction gradient
          Objective function gradient.
 
Fields inherited from class org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer
evaluations
 
Constructor Summary
protected AbstractScalarDifferentiableOptimizer()
          Simple constructor with default settings.
protected AbstractScalarDifferentiableOptimizer(ConvergenceChecker<PointValuePair> checker)
           
 
Method Summary
protected  double[] computeObjectiveGradient(double[] evaluationPoint)
          Compute the gradient vector.
 PointValuePair optimize(int maxEval, DifferentiableMultivariateFunction f, GoalType goalType, double[] startPoint)
          Optimize an objective function.
 
Methods inherited from class org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer
computeObjectiveValue, doOptimize, getConvergenceChecker, getEvaluations, getGoalType, getMaxEvaluations, getStartPoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math3.optimization.BaseOptimizer
getConvergenceChecker, getEvaluations, getMaxEvaluations
 

Field Detail

gradient

private MultivariateVectorFunction gradient
Objective function gradient.

Constructor Detail

AbstractScalarDifferentiableOptimizer

protected AbstractScalarDifferentiableOptimizer()
Simple constructor with default settings. The convergence check is set to a SimpleValueChecker.


AbstractScalarDifferentiableOptimizer

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

computeObjectiveGradient

protected double[] computeObjectiveGradient(double[] evaluationPoint)
Compute the gradient vector.

Parameters:
evaluationPoint - Point at which the gradient must be evaluated.
Returns:
the gradient at the specified point.
Throws:
TooManyEvaluationsException - if the allowed number of evaluations is exceeded.

optimize

public PointValuePair optimize(int maxEval,
                               DifferentiableMultivariateFunction f,
                               GoalType goalType,
                               double[] startPoint)
Optimize an objective function.

Specified by:
optimize in interface BaseMultivariateOptimizer<DifferentiableMultivariateFunction>
Overrides:
optimize in class BaseAbstractMultivariateOptimizer<DifferentiableMultivariateFunction>
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.


Copyright (c) 2003-2013 Apache Software Foundation