|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.ConvergingAlgorithmImpl
org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer
public abstract class AbstractUnivariateRealOptimizer
Provide a default implementation for several functions useful to generic optimizers.
Field Summary | |
---|---|
protected double |
functionValue
Value of the function at the last computed result. |
protected double |
result
The last computed root. |
protected boolean |
resultComputed
Indicates where a root has been computed. |
Fields inherited from class org.apache.commons.math.ConvergingAlgorithmImpl |
---|
absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy |
Constructor Summary | |
---|---|
protected |
AbstractUnivariateRealOptimizer()
Default constructor. |
protected |
AbstractUnivariateRealOptimizer(int defaultMaximalIterationCount,
double defaultAbsoluteAccuracy)
Deprecated. in 2.2. Please use the "setter" methods to assign meaningful values to the maximum numbers of iterations and evaluations, and to the absolute and relative accuracy thresholds. |
Method Summary | |
---|---|
protected void |
checkResultComputed()
Deprecated. in 2.2 (no alternative). |
protected void |
clearResult()
Deprecated. in 2.2 (no alternative). |
protected double |
computeObjectiveValue(double point)
Compute the objective function value. |
protected double |
computeObjectiveValue(UnivariateRealFunction f,
double point)
Deprecated. in 2.2. Use this replacement instead. |
protected double |
doOptimize()
Method for implementing actual optimization algorithms in derived classes. |
int |
getEvaluations()
Get the number of evaluations of the objective function. |
double |
getFunctionValue()
Get the result of the last run of the optimizer. |
GoalType |
getGoalType()
|
double |
getMax()
|
int |
getMaxEvaluations()
Get the maximal number of functions evaluations. |
double |
getMin()
|
double |
getResult()
Get the result of the last run of the optimizer. |
double |
getStartValue()
|
double |
optimize(UnivariateRealFunction f,
GoalType goal,
double min,
double max)
Find an optimum in the given interval. |
double |
optimize(UnivariateRealFunction f,
GoalType goal,
double min,
double max,
double startValue)
Find an optimum in the given interval, start at startValue. |
protected void |
setFunctionValue(double functionValue)
Set the value at the optimum. |
void |
setMaxEvaluations(int maxEvaluations)
Set the maximal number of functions evaluations. |
protected void |
setResult(double x,
double fx,
int iterationCount)
Deprecated. in 2.2 (no alternative). |
Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl |
---|
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, incrementIterationsCounter, resetAbsoluteAccuracy, resetIterationsCounter, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm |
---|
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy |
Field Detail |
---|
protected boolean resultComputed
protected double result
protected double functionValue
Constructor Detail |
---|
@Deprecated protected AbstractUnivariateRealOptimizer(int defaultMaximalIterationCount, double defaultAbsoluteAccuracy)
defaultAbsoluteAccuracy
- maximum absolute errordefaultMaximalIterationCount
- maximum number of iterations
IllegalArgumentException
- if f is null or the
defaultAbsoluteAccuracy is not validprotected AbstractUnivariateRealOptimizer()
Method Detail |
---|
@Deprecated protected void checkResultComputed()
NoDataException
- if no result has been computedpublic double getResult()
getResult
in interface UnivariateRealOptimizer
public double getFunctionValue() throws FunctionEvaluationException
getFunctionValue
in interface UnivariateRealOptimizer
FunctionEvaluationException
- if an error occurs evaluating the function.@Deprecated protected final void setResult(double x, double fx, int iterationCount)
x
- the result to setfx
- the result to setiterationCount
- the iteration count to set@Deprecated protected final void clearResult()
public void setMaxEvaluations(int maxEvaluations)
setMaxEvaluations
in interface UnivariateRealOptimizer
maxEvaluations
- maximal number of function evaluationspublic int getMaxEvaluations()
getMaxEvaluations
in interface UnivariateRealOptimizer
public int getEvaluations()
The number of evaluations corresponds to the last call to the
optimize
method. It is 0 if the method has not been called yet.
getEvaluations
in interface UnivariateRealOptimizer
public GoalType getGoalType()
public double getMin()
public double getMax()
public double getStartValue()
@Deprecated protected double computeObjectiveValue(UnivariateRealFunction f, double point) throws FunctionEvaluationException
replacement
instead.
f
- objective functionpoint
- point at which the objective function must be evaluated
FunctionEvaluationException
- if the function cannot be evaluated
or the maximal number of iterations is exceededprotected double computeObjectiveValue(double point) throws FunctionEvaluationException
point
- Point at which the objective function must be evaluated.
FunctionEvaluationException
- if the function cannot be evaluated
or the maximal number of iterations is exceeded.public double optimize(UnivariateRealFunction f, GoalType goal, double min, double max, double startValue) throws MaxIterationsExceededException, FunctionEvaluationException
An optimizer may require that the interval brackets a single optimum.
optimize
in interface UnivariateRealOptimizer
f
- the function to optimize.goal
- type of optimization goal: either GoalType.MAXIMIZE
or GoalType.MINIMIZE
.min
- the lower bound for the interval.max
- the upper bound for the interval.startValue
- the start value to use.
FunctionEvaluationException
- if an error occurs evaluating the function.
MaxIterationsExceededException
protected void setFunctionValue(double functionValue)
functionValue
- Value of the objective function at the optimum.public double optimize(UnivariateRealFunction f, GoalType goal, double min, double max) throws MaxIterationsExceededException, FunctionEvaluationException
An optimizer may require that the interval brackets a single optimum.
optimize
in interface UnivariateRealOptimizer
f
- the function to optimize.goal
- type of optimization goal: either GoalType.MAXIMIZE
or GoalType.MINIMIZE
.min
- the lower bound for the interval.max
- the upper bound for the interval.
FunctionEvaluationException
- if an error occurs evaluating the function.
MaxIterationsExceededException
protected double doOptimize() throws MaxIterationsExceededException, FunctionEvaluationException
optimize(UnivariateRealFunction, GoalType, double, double)
.
MaxIterationsExceededException
- if the maximum iteration count
is exceeded.
FunctionEvaluationException
- if an error occurs evaluating
the function.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |