Package org.apache.commons.math3.optim
Class AbstractOptimizationProblem<PAIR>
java.lang.Object
org.apache.commons.math3.optim.AbstractOptimizationProblem<PAIR>
- Type Parameters:
PAIR
- Type of the point/value pair returned by the optimization algorithm.
- All Implemented Interfaces:
OptimizationProblem<PAIR>
- Direct Known Subclasses:
LeastSquaresFactory.LocalLeastSquaresProblem
public abstract class AbstractOptimizationProblem<PAIR>
extends Object
implements OptimizationProblem<PAIR>
Base class for implementing optimization problems. 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.
- Since:
- 3.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Defines the action to perform when reaching the maximum number of evaluations.private static class
Defines the action to perform when reaching the maximum number of evaluations. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConvergenceChecker
<PAIR> Convergence checker.private static final AbstractOptimizationProblem.MaxEvalCallback
Callback to use for the evaluation counter.private static final AbstractOptimizationProblem.MaxIterCallback
Callback to use for the iteration counter.private final int
max evaluationsprivate final int
max iterations -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractOptimizationProblem
(int maxEvaluations, int maxIterations, ConvergenceChecker<PAIR> checker) Create anAbstractOptimizationProblem
from the given data. -
Method Summary
Modifier and TypeMethodDescriptionGets the convergence checker.Get a independent Incrementor that counts up to the maximum number of evaluations and then throws an exception.Get a independent Incrementor that counts up to the maximum number of iterations and then throws an exception.
-
Field Details
-
MAX_EVAL_CALLBACK
Callback to use for the evaluation counter. -
MAX_ITER_CALLBACK
Callback to use for the iteration counter. -
maxEvaluations
private final int maxEvaluationsmax evaluations -
maxIterations
private final int maxIterationsmax iterations -
checker
Convergence checker.
-
-
Constructor Details
-
AbstractOptimizationProblem
protected AbstractOptimizationProblem(int maxEvaluations, int maxIterations, ConvergenceChecker<PAIR> checker) Create anAbstractOptimizationProblem
from the given data.- Parameters:
maxEvaluations
- the number of allowed model function evaluations.maxIterations
- the number of allowed iterations.checker
- the convergence checker.
-
-
Method Details
-
getEvaluationCounter
Get a independent Incrementor that counts up to the maximum number of evaluations and then throws an exception.- Specified by:
getEvaluationCounter
in interfaceOptimizationProblem<PAIR>
- Returns:
- a counter for the evaluations.
-
getIterationCounter
Get a independent Incrementor that counts up to the maximum number of iterations and then throws an exception.- Specified by:
getIterationCounter
in interfaceOptimizationProblem<PAIR>
- Returns:
- a counter for the evaluations.
-
getConvergenceChecker
Gets the convergence checker.- Specified by:
getConvergenceChecker
in interfaceOptimizationProblem<PAIR>
- Returns:
- the object used to check for convergence.
-