org.apache.commons.math.optimization.univariate

## Class BrentOptimizer

- java.lang.Object
- - org.apache.commons.math.ConvergingAlgorithmImpl
  - - org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer
    - - org.apache.commons.math.optimization.univariate.BrentOptimizer

- All Implemented Interfaces:
    ConvergingAlgorithm, UnivariateRealOptimizer

      public class BrentOptimizer
      extends AbstractUnivariateRealOptimizer

  Implements Richard Brent's algorithm (from his book "Algorithms for Minimization without Derivatives", p. 79) for finding minima of real univariate functions. This implementation is an adaptation partly based on the Python code from SciPy (module "optimize.py" v0.5).
  Since:
    2.0
  Version:
    $Revision: 1070725 $ $Date: 2011-02-15 02:31:12 +0100 (mar. 15 févr. 2011) $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static double` | `GOLDEN_SECTION` Golden section.

    - ### Fields inherited from class org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer

      `functionValue, result, resultComputed`

    - ### Fields inherited from class org.apache.commons.math.ConvergingAlgorithmImpl

      `absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BrentOptimizer()` Construct a solver.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `doOptimize()` Method for implementing actual optimization algorithms in derived classes.
    `private double` | `localMin(boolean isMinim, double lo, double mid, double hi, double eps, double t)` Find the minimum of the function within the interval `(lo, hi)`.

    - ### Methods inherited from class org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer

      `checkResultComputed, clearResult, computeObjectiveValue, computeObjectiveValue, getEvaluations, getFunctionValue, getGoalType, getMax, getMaxEvaluations, getMin, getResult, getStartValue, optimize, optimize, setFunctionValue, setMaxEvaluations, setResult`

    - ### 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

    - #### GOLDEN_SECTION

          private static final double GOLDEN_SECTION

      Golden section.

  - ### Constructor Detail

    - #### BrentOptimizer

          public BrentOptimizer()

      Construct a solver.

  - ### Method Detail

    - #### doOptimize

          protected double doOptimize()
                               throws MaxIterationsExceededException,
                                      FunctionEvaluationException

      Method for implementing actual optimization algorithms in derived classes. From version 3.0 onwards, this method will be abstract - i.e. concrete implementations will have to implement it. If this method is not implemented, subclasses must override `AbstractUnivariateRealOptimizer.optimize(UnivariateRealFunction, GoalType, double, double)`.
      Overrides:
        `doOptimize` in class `AbstractUnivariateRealOptimizer`
      Returns:
        the optimum.
      Throws:
        `MaxIterationsExceededException` - if the maximum iteration count is exceeded.
        `FunctionEvaluationException` - if an error occurs evaluating the function.

    - #### localMin

          private double localMin(boolean isMinim,
                        double lo,
                        double mid,
                        double hi,
                        double eps,
                        double t)
                           throws MaxIterationsExceededException,
                                  FunctionEvaluationException

      Find the minimum of the function within the interval `(lo, hi)`. If the function is defined on the interval `(lo, hi)`, then this method finds an approximation `x` to the point at which the function attains its minimum.
      `t` and `eps` define a tolerance `tol = eps |x| + t` and the function is never evaluated at two points closer together than `tol`. `eps` should be no smaller than 2 macheps and preferable not much less than sqrt(macheps), where macheps is the relative machine precision. `t` should be positive.
      Parameters:
        `isMinim` - `true` when minimizing the function.
        `lo` - Lower bound of the interval.
        `mid` - Point inside the interval `[lo, hi]`.
        `hi` - Higher bound of the interval.
        `eps` - Relative accuracy.
        `t` - Absolute accuracy.
      Returns:
        the optimum point.
      Throws:
        `MaxIterationsExceededException` - if the maximum iteration count is exceeded.
        `FunctionEvaluationException` - if an error occurs evaluating the function.

Copyright (c) 2003-2013 Apache Software Foundation