Top Description Inners Fields Constructors Methods
org.apache.commons.math3.optim

public abstract Class BaseOptimizer<PAIR>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.optim.univariate.UnivariateOptimizer, org.apache.commons.math3.optim.BaseMultivariateOptimizer
Type Parameters
<PAIR>
Type of the point/value pair returned by the optimization algorithm.
Imports
org.apache.commons.math3.util.Incrementor, org.apache.commons.math3.exception.TooManyEvaluationsException, .TooManyIterationsException

Base class for implementing optimizers. It contains the boiler-plate code for counting the number of evaluations of the objective function and the number of iterations of the algorithm, and storing the convergence checker. It is not a "user" class.
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BaseOptimizer.MaxEvalCallback

Defines the action to perform when reaching the maximum number of evaluations.

private static class
BaseOptimizer.MaxIterCallback

Defines the action to perform when reaching the maximum number of evaluations.

Field Summary

Modifier and TypeField and Description
private final ConvergenceChecker<PAIR>
checker

Convergence checker.

protected final Incrementor
evaluations

Deprecated as a consequence of Incrementor being deprecated.
Evaluations counter.
protected final Incrementor
iterations

Deprecated as a consequence of Incrementor being deprecated.
Iterations counter.

Constructor Summary

AccessConstructor and Description
protected
BaseOptimizer(ConvergenceChecker<PAIR>
Convergence checker.
checker
)

protected
BaseOptimizer(ConvergenceChecker<PAIR>
Convergence checker.
checker
,
int
Maximum number of objective function evaluations.
maxEval
,
int
Maximum number of algorithm iterations.
maxIter
)

Method Summary

Modifier and TypeMethod and Description
protected abstract PAIR

Returns:

the point/value pair giving the optimal value of the objective function.
doOptimize
()

Performs the bulk of the optimization algorithm.

public ConvergenceChecker<PAIR>

Returns:

the object used to check for convergence.
getConvergenceChecker
()

Gets the convergence checker.

public int

Returns:

the number of evaluations of the objective function.
getEvaluations
()

Gets the number of evaluations of the objective function.

public int

Returns:

the number of evaluations of the objective function.
getIterations
()

Gets the number of iterations performed by the algorithm.

public int

Returns:

the maximal number of function evaluations.
getMaxEvaluations
()

Gets the maximal number of function evaluations.

public int

Returns:

the maximal number of iterations.
getMaxIterations
()

Gets the maximal number of iterations.

protected void
incrementEvaluationCount()

Increment the evaluation count.

protected void
incrementIterationCount()

Increment the iteration count.

public PAIR

Returns:

a point/value pair that satisfies the convergence criteria.
optimize
(OptimizationData...
Optimization data. This method will register the following data:
optData
)

Stores data and performs the optimization.

public PAIR

Returns:

a point/value pair that satisfies the convergence criteria.
optimize
()

Performs the optimization.

protected void
parseOptimizationData(OptimizationData...
Optimization data. The following data will be looked for:
optData
)

Scans the list of (required and optional) optimization data that characterize the problem.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkerback to summary
private final ConvergenceChecker<PAIR> checker

Convergence checker.

evaluationsback to summary
protected final Incrementor evaluations

Deprecated

as a consequence of Incrementor being deprecated. See corresponding docs for further information.

Evaluations counter.

iterationsback to summary
protected final Incrementor iterations

Deprecated

as a consequence of Incrementor being deprecated. See corresponding docs for further information.

Iterations counter.

Constructor Detail

BaseOptimizerback to summary
protected BaseOptimizer(ConvergenceChecker<PAIR> checker)
Parameters
checker:ConvergenceChecker<PAIR>

Convergence checker.

BaseOptimizerback to summary
protected BaseOptimizer(ConvergenceChecker<PAIR> checker, int maxEval, int maxIter)
Parameters
checker:ConvergenceChecker<PAIR>

Convergence checker.

maxEval:int

Maximum number of objective function evaluations.

maxIter:int

Maximum number of algorithm iterations.

Method Detail

doOptimizeback to summary
protected abstract PAIR doOptimize()

Performs the bulk of the optimization algorithm.

Returns:PAIR

the point/value pair giving the optimal value of the objective function.

getConvergenceCheckerback to summary
public ConvergenceChecker<PAIR> getConvergenceChecker()

Gets the convergence checker.

Returns:ConvergenceChecker<PAIR>

the object used to check for convergence.

getEvaluationsback to summary
public int getEvaluations()

Gets 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.

Returns:int

the number of evaluations of the objective function.

getIterationsback to summary
public int getIterations()

Gets the number of iterations performed by the algorithm. The number iterations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.

Returns:int

the number of evaluations of the objective function.

getMaxEvaluationsback to summary
public int getMaxEvaluations()

Gets the maximal number of function evaluations.

Returns:int

the maximal number of function evaluations.

getMaxIterationsback to summary
public int getMaxIterations()

Gets the maximal number of iterations.

Returns:int

the maximal number of iterations.

incrementEvaluationCountback to summary
protected void incrementEvaluationCount() throws TooManyEvaluationsException

Increment the evaluation count.

Exceptions
TooManyEvaluationsException:
if the allowed evaluations have been exhausted.
incrementIterationCountback to summary
protected void incrementIterationCount() throws TooManyIterationsException

Increment the iteration count.

Exceptions
TooManyIterationsException:
if the allowed iterations have been exhausted.
optimizeback to summary
public PAIR optimize(OptimizationData... optData) throws TooManyEvaluationsException, TooManyIterationsException

Stores data and performs the optimization.

The list of parameters is open-ended so that sub-classes can extend it with arguments specific to their concrete implementations.

When the method is called multiple times, instance data is overwritten only when actually present in the list of arguments: when not specified, data set in a previous call is retained (and thus is optional in subsequent calls).

Important Note

Subclasses must override parseOptimizationData(OptimizationData[]) if they need to register their own options; but then, they must also call super.parseOptimizationData(optData) within that method.

Parameters
optData:OptimizationData[]

Optimization data. This method will register the following data:

Returns:PAIR

a point/value pair that satisfies the convergence criteria.

Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
TooManyIterationsException:
if the maximal number of iterations is exceeded.
optimizeback to summary
public PAIR optimize() throws TooManyEvaluationsException, TooManyIterationsException

Performs the optimization.

Returns:PAIR

a point/value pair that satisfies the convergence criteria.

Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
TooManyIterationsException:
if the maximal number of iterations is exceeded.
parseOptimizationDataback to summary
protected void parseOptimizationData(OptimizationData... optData)

Scans the list of (required and optional) optimization data that characterize the problem.

Parameters
optData:OptimizationData[]

Optimization data. The following data will be looked for:

org.apache.commons.math3.optim back to summary

private Class BaseOptimizer.MaxEvalCallback

extends Object
implements MaxCountExceededCallback
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback

Defines the action to perform when reaching the maximum number of evaluations.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
trigger(int
Maximal count.
max
)

Implements org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Function called when the maximal count has been reached.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MaxEvalCallbackback to summary
private MaxEvalCallback()

Method Detail

triggerback to summary
public void trigger(int max)

Implements org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Doc from org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Function called when the maximal count has been reached.

Parameters
max:int

Maximal count.

org.apache.commons.math3.optim back to summary

private Class BaseOptimizer.MaxIterCallback

extends Object
implements MaxCountExceededCallback
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback

Defines the action to perform when reaching the maximum number of evaluations.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
trigger(int
Maximal count.
max
)

Implements org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Function called when the maximal count has been reached.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MaxIterCallbackback to summary
private MaxIterCallback()

Method Detail

triggerback to summary
public void trigger(int max)

Implements org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Doc from org.apache.commons.math3.util.Incrementor.MaxCountExceededCallback.trigger.

Function called when the maximal count has been reached.

Parameters
max:int

Maximal count.