Class BracketFinder
- java.lang.Object
-
- org.apache.commons.math3.optim.univariate.BracketFinder
-
public class BracketFinder extends java.lang.ObjectProvide an interval that brackets a local optimum of a function. This code is based on a Python implementation (from SciPy, moduleoptimize.pyv0.5).- Since:
- 2.2
-
-
Field Summary
Fields Modifier and Type Field Description private static doubleEPS_MINTolerance to avoid division by zero.private IntegerSequence.IncrementorevaluationsCounter for function evaluations.private doublefHiFunction value athi.private doublefLoFunction value atlo.private doublefMidFunction value atmid.private static doubleGOLDGolden section.private doublegrowLimitFactor for expanding the interval.private doublehiHigher bound of the bracket.private doubleloLower bound of the bracket.private doublemidPoint inside the bracket.
-
Constructor Summary
Constructors Constructor Description BracketFinder()Constructor with default values100, 500(see theother constructor).BracketFinder(double growLimit, int maxEvaluations)Create a bracketing interval finder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private doubleeval(UnivariateFunction f, double x)intgetEvaluations()doublegetFHi()Get function value atgetHi().doublegetFLo()Get function value atgetLo().doublegetFMid()Get function value atgetMid().doublegetHi()doublegetLo()intgetMaxEvaluations()doublegetMid()voidsearch(UnivariateFunction func, GoalType goal, double xA, double xB)Search new points that bracket a local optimum of the function.
-
-
-
Field Detail
-
EPS_MIN
private static final double EPS_MIN
Tolerance to avoid division by zero.- See Also:
- Constant Field Values
-
GOLD
private static final double GOLD
Golden section.- See Also:
- Constant Field Values
-
growLimit
private final double growLimit
Factor for expanding the interval.
-
evaluations
private IntegerSequence.Incrementor evaluations
Counter for function evaluations.
-
lo
private double lo
Lower bound of the bracket.
-
hi
private double hi
Higher bound of the bracket.
-
mid
private double mid
Point inside the bracket.
-
fLo
private double fLo
Function value atlo.
-
fHi
private double fHi
Function value athi.
-
fMid
private double fMid
Function value atmid.
-
-
Constructor Detail
-
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 Detail
-
search
public void search(UnivariateFunction func, GoalType goal, double xA, double xB)
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()
-
getHi
public double getHi()
- Returns:
- the higher bound of the bracket.
- See Also:
getFHi()
-
getMid
public double getMid()
- Returns:
- a point in the middle of the bracket.
- See Also:
getFMid()
-
eval
private double eval(UnivariateFunction f, double x)
- Parameters:
f- Function.x- Argument.- Returns:
f(x)- Throws:
TooManyEvaluationsException- if the maximal number of evaluations is exceeded.
-
-