Interface UnivariateRealOptimizer
-
- All Superinterfaces:
ConvergingAlgorithm
- All Known Implementing Classes:
AbstractUnivariateRealOptimizer,BrentOptimizer,MultiStartUnivariateRealOptimizer
public interface UnivariateRealOptimizer extends ConvergingAlgorithm
Interface for (univariate real) optimization algorithms.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetEvaluations()Get the number of evaluations of the objective function.doublegetFunctionValue()Get the result of the last run of the optimizer.intgetMaxEvaluations()Get the maximal number of functions evaluations.doublegetResult()Get the result of the last run of the optimizer.doubleoptimize(UnivariateRealFunction f, GoalType goalType, double min, double max)Find an optimum in the given interval.doubleoptimize(UnivariateRealFunction f, GoalType goalType, double min, double max, double startValue)Find an optimum in the given interval, start at startValue.voidsetMaxEvaluations(int maxEvaluations)Set the maximal number of functions evaluations.-
Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy
-
-
-
-
Method Detail
-
setMaxEvaluations
void setMaxEvaluations(int maxEvaluations)
Set the maximal number of functions evaluations.- Parameters:
maxEvaluations- maximal number of function evaluations
-
getMaxEvaluations
int getMaxEvaluations()
Get the maximal number of functions evaluations.- Returns:
- the maximal number of functions evaluations.
-
getEvaluations
int getEvaluations()
Get the number of evaluations of the objective function.The number of evaluations corresponds to the last call to the
optimizemethod. It is 0 if the method has not been called yet.- Returns:
- the number of evaluations of the objective function.
-
optimize
double optimize(UnivariateRealFunction f, GoalType goalType, double min, double max) throws ConvergenceException, FunctionEvaluationException
Find an optimum in the given interval.An optimizer may require that the interval brackets a single optimum.
- Parameters:
f- the function to optimize.goalType- type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZE.min- the lower bound for the interval.max- the upper bound for the interval.- Returns:
- a value where the function is optimum.
- Throws:
ConvergenceException- if the maximum iteration count is exceeded or the optimizer detects convergence problems otherwise.FunctionEvaluationException- if an error occurs evaluating the function.java.lang.IllegalArgumentException- if min > max or the endpoints do not satisfy the requirements specified by the optimizer.
-
optimize
double optimize(UnivariateRealFunction f, GoalType goalType, double min, double max, double startValue) throws ConvergenceException, FunctionEvaluationException
Find an optimum in the given interval, start at startValue.An optimizer may require that the interval brackets a single optimum.
- Parameters:
f- the function to optimize.goalType- type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZE.min- the lower bound for the interval.max- the upper bound for the interval.startValue- the start value to use.- Returns:
- a value where the function is optimum.
- Throws:
ConvergenceException- if the maximum iteration count is exceeded or the optimizer detects convergence problems otherwise.FunctionEvaluationException- if an error occurs evaluating the function.java.lang.IllegalArgumentException- if min > max or the arguments do not satisfy the requirements specified by the optimizer.java.lang.IllegalStateException- if there are no data.
-
getResult
double getResult()
Get the result of the last run of the optimizer.- Returns:
- the optimum.
- Throws:
java.lang.IllegalStateException- if there is no result available, either because no result was yet computed or the last attempt failed.
-
getFunctionValue
double getFunctionValue() throws FunctionEvaluationExceptionGet the result of the last run of the optimizer.- Returns:
- the value of the function at the optimum.
- Throws:
FunctionEvaluationException- if an error occurs evaluating the function.java.lang.IllegalStateException- if there is no result available, either because no result was yet computed or the last attempt failed.
-
-