P
- Type of the point/value pair returned by the optimization
algorithm.public abstract class BaseOptimizer<P> extends Object
Modifier and Type | Field and Description |
---|---|
protected Incrementor |
evaluations
Evaluations counter.
|
protected Incrementor |
iterations
Iterations counter.
|
Modifier | Constructor and Description |
---|---|
protected |
BaseOptimizer(ConvergenceChecker<P> checker) |
protected |
BaseOptimizer(ConvergenceChecker<P> checker,
int maxEval,
int maxIter) |
Modifier and Type | Method and Description |
---|---|
protected abstract P |
doOptimize()
Performs the bulk of the optimization algorithm.
|
ConvergenceChecker<P> |
getConvergenceChecker()
Gets the convergence checker.
|
int |
getEvaluations()
Gets the number of evaluations of the objective function.
|
int |
getIterations()
Gets the number of iterations performed by the algorithm.
|
int |
getMaxEvaluations()
Gets the maximal number of function evaluations.
|
int |
getMaxIterations()
Gets the maximal number of iterations.
|
protected void |
incrementEvaluationCount()
Increment the evaluation count.
|
protected void |
incrementIterationCount()
Increment the iteration count.
|
P |
optimize()
Performs the optimization.
|
P |
optimize(OptimizationData... optData)
Stores data and performs the optimization.
|
protected void |
parseOptimizationData(OptimizationData... optData)
Scans the list of (required and optional) optimization data that
characterize the problem.
|
protected Incrementor evaluations
protected Incrementor iterations
protected BaseOptimizer(ConvergenceChecker<P> checker)
checker
- Convergence checker.protected BaseOptimizer(ConvergenceChecker<P> checker, int maxEval, int maxIter)
checker
- Convergence checker.maxEval
- Maximum number of objective function evaluations.maxIter
- Maximum number of algorithm iterations.public int getMaxEvaluations()
public int getEvaluations()
optimize
method. It is 0 if the method has not been
called yet.public int getMaxIterations()
public int getIterations()
optimize
method. It is 0 if the method has not been
called yet.public ConvergenceChecker<P> getConvergenceChecker()
public P optimize(OptimizationData... optData) throws MathIllegalStateException
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.
optData
- Optimization data.
This method will register the following data:
MathIllegalStateException
- if the maximal number of
evaluations is exceeded.MathIllegalStateException
- if the maximal number of
iterations is exceeded.public P optimize() throws MathIllegalStateException
MathIllegalStateException
- if the maximal number of
evaluations is exceeded.MathIllegalStateException
- if the maximal number of
iterations is exceeded.protected abstract P doOptimize()
protected void incrementEvaluationCount() throws MathIllegalStateException
MathIllegalStateException
- if the allowed evaluations
have been exhausted.protected void incrementIterationCount() throws MathIllegalStateException
MathIllegalStateException
- if the allowed iterations
have been exhausted.protected void parseOptimizationData(OptimizationData... optData)
Copyright © 2016-2021 CS GROUP. All rights reserved.