## org.apache.commons.math.optimization.univariate
Class BracketFinder

    java.lang.Object
      org.apache.commons.math.optimization.univariate.BracketFinder

    public class BracketFinder

extends Object

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
Version:
  $Revision$ $Date$

Field Summary
`private static double` `EPS_MIN` Tolerance to avoid division by zero.
`private int` `evaluations` Number of 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 double` `GOLD` Golden section.
`private double` `growLimit` Factor for expanding the interval.
`private double` `hi` Higher bound of the bracket.
`private int` `iterations` Number of iterations.
`private double` `lo` Lower bound of the bracket.
`private int` `maxIterations` Maximum number of iterations.
`private double` `mid` Point inside the bracket.

Constructor Summary
`BracketFinder()` Constructor with default values `100, 50` (see the `other constructor`).
`BracketFinder(double growLimit, int maxIterations)` Create a bracketing interval finder.

Method Summary
`private double` `eval(UnivariateRealFunction f, double x)`
`int` `getEvaluations()`
`double` `getFHi()` Get function value at `getHi()`.
`double` `getFLow()` Get function value at `getLo()`.
`double` `getFMid()` Get function value at `getMid()`.
`double` `getHi()`
`int` `getIterations()`
`double` `getLo()`
`double` `getMid()`
`private void` `reset()` Reset internal state.
`void` `search(UnivariateRealFunction func, GoalType goal, double xA, double xB)` Search new points that bracket a local optimum of the function.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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.

### maxIterations

    private final int maxIterations

  Maximum number of iterations.

### iterations

    private int iterations

  Number of iterations.

### evaluations

    private int evaluations

  Number of 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 at `lo`.

### fHi

    private double fHi

  Function value at `hi`.

### fMid

    private double fMid

  Function value at `mid`.

Constructor Detail

### BracketFinder

    public BracketFinder()

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

### BracketFinder

    public BracketFinder(double growLimit,
                         int maxIterations)

  Create a bracketing interval finder.

  Parameters:
    `growLimit` - Expanding factor.
    `maxIterations` - Maximum number of iterations allowed for finding a bracketing interval.

Method Detail

### search

    public void search(UnivariateRealFunction func,
                       GoalType goal,
                       double xA,
                       double xB)
                throws MaxIterationsExceededException,
                       FunctionEvaluationException

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

  Parameters:
    `func` - Function whose optimum should be bracketted.
    `goal` - `Goal type`.
    `xA` - Initial point.
    `xB` - Initial point.
  Throws:
    `MaxIterationsExceededException` - if the maximum iteration count is exceeded.
    `FunctionEvaluationException` - if an error occurs evaluating the function.

### getIterations

    public int getIterations()

  Returns:
    the number of iterations.

### getEvaluations

    public int getEvaluations()

  Returns:
    the number of evaluations.

### getLo

    public double getLo()

  Returns:
    the lower bound of the bracket.
  See Also:
    `getFLow()`

### getFLow

    public double getFLow()

  Get function value at `getLo()`.

  Returns:
    function value at `getLo()`

### getHi

    public double getHi()

  Returns:
    the higher bound of the bracket.
  See Also:
    `getFHi()`

### getFHi

    public double getFHi()

  Get function value at `getHi()`.

  Returns:
    function value at `getHi()`

### getMid

    public double getMid()

  Returns:
    a point in the middle of the bracket.
  See Also:
    `getFMid()`

### getFMid

    public double getFMid()

  Get function value at `getMid()`.

  Returns:
    function value at `getMid()`

### eval

    private double eval(UnivariateRealFunction f,
                        double x)
                 throws FunctionEvaluationException

  Parameters:
    `f` - Function.
    `x` - Argument.
  Returns:
    `f(x)`
  Throws:
    `FunctionEvaluationException` - if function cannot be evaluated at x

### reset

    private void reset()

  Reset internal state.

Copyright (c) 2003-2013 Apache Software Foundation