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 java.lang.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 Classes Modifier and Type Class Description private static class
AbstractOptimizationProblem.MaxEvalCallback
Defines the action to perform when reaching the maximum number of evaluations.private static class
AbstractOptimizationProblem.MaxIterCallback
Defines the action to perform when reaching the maximum number of evaluations.
-
Field Summary
Fields Modifier and Type Field Description private ConvergenceChecker<PAIR>
checker
Convergence checker.private static AbstractOptimizationProblem.MaxEvalCallback
MAX_EVAL_CALLBACK
Callback to use for the evaluation counter.private static AbstractOptimizationProblem.MaxIterCallback
MAX_ITER_CALLBACK
Callback to use for the iteration counter.private int
maxEvaluations
max evaluationsprivate int
maxIterations
max iterations
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractOptimizationProblem(int maxEvaluations, int maxIterations, ConvergenceChecker<PAIR> checker)
Create anAbstractOptimizationProblem
from the given data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConvergenceChecker<PAIR>
getConvergenceChecker()
Gets the convergence checker.Incrementor
getEvaluationCounter()
Get a independent Incrementor that counts up to the maximum number of evaluations and then throws an exception.Incrementor
getIterationCounter()
Get a independent Incrementor that counts up to the maximum number of iterations and then throws an exception.
-
-
-
Field Detail
-
MAX_EVAL_CALLBACK
private static final AbstractOptimizationProblem.MaxEvalCallback MAX_EVAL_CALLBACK
Callback to use for the evaluation counter.
-
MAX_ITER_CALLBACK
private static final AbstractOptimizationProblem.MaxIterCallback MAX_ITER_CALLBACK
Callback to use for the iteration counter.
-
maxEvaluations
private final int maxEvaluations
max evaluations
-
maxIterations
private final int maxIterations
max iterations
-
checker
private final ConvergenceChecker<PAIR> checker
Convergence checker.
-
-
Constructor Detail
-
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 Detail
-
getEvaluationCounter
public Incrementor 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
public Incrementor 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
public ConvergenceChecker<PAIR> getConvergenceChecker()
Gets the convergence checker.- Specified by:
getConvergenceChecker
in interfaceOptimizationProblem<PAIR>
- Returns:
- the object used to check for convergence.
-
-