Top Description Fields Constructors Methods
org.apache.commons.math3.optim.univariate

public Class BracketFinder

extends Object
Class Inheritance
Imports
org.apache.commons.math3.util.FastMath, .IntegerSequence, org.apache.commons.math3.exception.NotStrictlyPositiveException, .TooManyEvaluationsException, .MaxCountExceededException, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.optim.nonlinear.scalar.GoalType

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

Modifier and TypeField and Description
private static final double
EPS_MIN

Tolerance to avoid division by zero.

private IntegerSequence.Incrementor
evaluations

Counter for function evaluations.

private double
fHi

Function value at hi.

private double
fLo

Function value at lo.

private double
fMid

Function value at mid.

private static final double
GOLD

Golden section.

private final double
growLimit

Factor for expanding the interval.

private double
hi

Higher bound of the bracket.

private double
lo

Lower bound of the bracket.

private double
mid

Point inside the bracket.

Constructor Summary

AccessConstructor and Description
public
BracketFinder()

Constructor with default values 100, 500 (see the other constructor).

public
BracketFinder(double
Expanding factor.
growLimit
,
int
Maximum number of evaluations allowed for finding a bracketing interval.
maxEvaluations
)

Create a bracketing interval finder.

Method Summary

Modifier and TypeMethod and Description
private double

Returns:

f(x)
eval
(UnivariateFunction
Function.
f
,
double
Argument.
x
)

public int

Returns:

the number of evalutations.
getEvaluations
()

public double

Returns:

function value at getHi()
getFHi
()

Get function value at getHi().

public double

Returns:

function value at getLo()
getFLo
()

Get function value at getLo().

public double

Returns:

function value at getMid()
getFMid
()

Get function value at getMid().

public double

Returns:

the higher bound of the bracket.
getHi
()

public double

Returns:

the lower bound of the bracket.
getLo
()

public int

Returns:

the number of evalutations.
getMaxEvaluations
()

public double

Returns:

a point in the middle of the bracket.
getMid
()

public void
search(UnivariateFunction
Function whose optimum should be bracketed.
func
,
GoalType goal, double
Initial point.
xA
,
double
Initial point.
xB
)

Search new points that bracket a local optimum of the function.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EPS_MINback to summary
private static final double EPS_MIN

Tolerance to avoid division by zero.

evaluationsback to summary
private IntegerSequence.Incrementor evaluations

Counter for function evaluations.

fHiback to summary
private double fHi

Function value at hi.

fLoback to summary
private double fLo

Function value at lo.

fMidback to summary
private double fMid

Function value at mid.

GOLDback to summary
private static final double GOLD

Golden section.

growLimitback to summary
private final double growLimit

Factor for expanding the interval.

hiback to summary
private double hi

Higher bound of the bracket.

loback to summary
private double lo

Lower bound of the bracket.

midback to summary
private double mid

Point inside the bracket.

Constructor Detail

BracketFinderback to summary
public BracketFinder()

Constructor with default values 100, 500 (see the other constructor).

BracketFinderback to summary
public BracketFinder(double growLimit, int maxEvaluations)

Create a bracketing interval finder.

Parameters
growLimit:double

Expanding factor.

maxEvaluations:int

Maximum number of evaluations allowed for finding a bracketing interval.

Method Detail

evalback to summary
private double eval(UnivariateFunction f, double x)
Parameters
f:UnivariateFunction

Function.

x:double

Argument.

Returns:double

f(x)

Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
getEvaluationsback to summary
public int getEvaluations()
Returns:int

the number of evalutations.

getFHiback to summary
public double getFHi()

Get function value at getHi().

Returns:double

function value at getHi()

getFLoback to summary
public double getFLo()

Get function value at getLo().

Returns:double

function value at getLo()

getFMidback to summary
public double getFMid()

Get function value at getMid().

Returns:double

function value at getMid()

getHiback to summary
public double getHi()
Returns:double

the higher bound of the bracket.

See Also
getFHi()
getLoback to summary
public double getLo()
Returns:double

the lower bound of the bracket.

See Also
getFLo()
getMaxEvaluationsback to summary
public int getMaxEvaluations()
Returns:int

the number of evalutations.

getMidback to summary
public double getMid()
Returns:double

a point in the middle of the bracket.

See Also
getFMid()
searchback to summary
public void search(UnivariateFunction func, GoalType goal, double xA, double xB)

Search new points that bracket a local optimum of the function.

Parameters
func:UnivariateFunction

Function whose optimum should be bracketed.

goal:GoalType

Goal type.

xA:double

Initial point.

xB:double

Initial point.

Exceptions
TooManyEvaluationsException:
if the maximum number of evaluations is exceeded.