Class BracketFinder
java.lang.Object
org.apache.commons.math3.optim.univariate.BracketFinder
Provide an interval that brackets a local optimum of a function.
This code is based on a Python implementation (from SciPy,
module
optimize.py v0.5).- Since:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleTolerance to avoid division by zero.private IntegerSequence.IncrementorCounter for function evaluations.private doubleFunction value athi.private doubleFunction value atlo.private doubleFunction value atmid.private static final doubleGolden section.private final doubleFactor for expanding the interval.private doubleHigher bound of the bracket.private doubleLower bound of the bracket.private doublePoint inside the bracket. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with default values100, 500(see theother constructor).BracketFinder(double growLimit, int maxEvaluations) Create a bracketing interval finder. -
Method Summary
Modifier and TypeMethodDescriptionprivate doubleeval(UnivariateFunction f, double x) intdoublegetFHi()Get function value atgetHi().doublegetFLo()Get function value atgetLo().doublegetFMid()Get function value atgetMid().doublegetHi()doublegetLo()intdoublegetMid()voidsearch(UnivariateFunction func, GoalType goal, double xA, double xB) Search new points that bracket a local optimum of the function.
-
Field Details
-
EPS_MIN
private static final double EPS_MINTolerance to avoid division by zero.- See Also:
-
GOLD
private static final double GOLDGolden section.- See Also:
-
growLimit
private final double growLimitFactor for expanding the interval. -
evaluations
Counter for function evaluations. -
lo
private double loLower bound of the bracket. -
hi
private double hiHigher bound of the bracket. -
mid
private double midPoint inside the bracket. -
fLo
private double fLoFunction value atlo. -
fHi
private double fHiFunction value athi. -
fMid
private double fMidFunction value atmid.
-
-
Constructor Details
-
BracketFinder
public BracketFinder()Constructor with default values100, 500(see theother constructor). -
BracketFinder
public BracketFinder(double growLimit, int maxEvaluations) Create a bracketing interval finder.- Parameters:
growLimit- Expanding factor.maxEvaluations- Maximum number of evaluations allowed for finding a bracketing interval.
-
-
Method Details
-
search
Search new points that bracket a local optimum of the function.- Parameters:
func- Function whose optimum should be bracketed.goal-Goal type.xA- Initial point.xB- Initial point.- Throws:
TooManyEvaluationsException- if the maximum number of evaluations is exceeded.
-
getMaxEvaluations
public int getMaxEvaluations()- Returns:
- the number of evalutations.
-
getEvaluations
public int getEvaluations()- Returns:
- the number of evalutations.
-
getLo
public double getLo()- Returns:
- the lower bound of the bracket.
- See Also:
-
getFLo
public double getFLo()Get function value atgetLo().- Returns:
- function value at
getLo()
-
getHi
public double getHi()- Returns:
- the higher bound of the bracket.
- See Also:
-
getFHi
public double getFHi()Get function value atgetHi().- Returns:
- function value at
getHi()
-
getMid
public double getMid()- Returns:
- a point in the middle of the bracket.
- See Also:
-
getFMid
public double getFMid()Get function value atgetMid().- Returns:
- function value at
getMid()
-
eval
- Parameters:
f- Function.x- Argument.- Returns:
f(x)- Throws:
TooManyEvaluationsException- if the maximal number of evaluations is exceeded.
-