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

Since:
  2.0
Version:
  $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $

Field Summary
`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
`BrentOptimizer()` Construct a solver.

Method Summary
`private double` `localMin(UnivariateRealFunction f, GoalType goalType, double a, double b, double eps, double t)` Find the minimum of the function `f` within the interval `(a, b)`.
`double` `optimize(UnivariateRealFunction f, GoalType goalType, double min, double max)` Find an optimum in the given interval.
`double` `optimize(UnivariateRealFunction f, GoalType goalType, double min, double max, double startValue)` Find an optimum in the given interval, start at startValue.

Methods inherited from class org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer
`checkResultComputed, clearResult, computeObjectiveValue, getEvaluations, getFunctionValue, getMaxEvaluations, getResult, setMaxEvaluations, setResult`

Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
`getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, 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

### optimize

    public double optimize(UnivariateRealFunction f,
                           GoalType goalType,
                           double min,
                           double max,
                           double startValue)
                    throws MaxIterationsExceededException,
                           FunctionEvaluationException

  Find an optimum in the given interval, start at startValue.

  An optimizer may require that the interval brackets a single optimum.

  Parameters:
    `f` - the function to optimize.
    `goalType` - type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`
    `min` - the lower bound for the interval.
    `max` - the upper bound for the interval.
    `startValue` - the start value to use
  Returns:
    a value where the function is optimum
  Throws:
    `FunctionEvaluationException` - if an error occurs evaluating the function
    `MaxIterationsExceededException`

### optimize

    public double optimize(UnivariateRealFunction f,
                           GoalType goalType,
                           double min,
                           double max)
                    throws MaxIterationsExceededException,
                           FunctionEvaluationException

  Find an optimum in the given interval.

  An optimizer may require that the interval brackets a single optimum.

  Parameters:
    `f` - the function to optimize.
    `goalType` - type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`
    `min` - the lower bound for the interval.
    `max` - the upper bound for the interval.
  Returns:
    a value where the function is optimum
  Throws:
    `FunctionEvaluationException` - if an error occurs evaluating the function
    `MaxIterationsExceededException`

### localMin

    private double localMin(UnivariateRealFunction f,
                            GoalType goalType,
                            double a,
                            double b,
                            double eps,
                            double t)
                     throws MaxIterationsExceededException,
                            FunctionEvaluationException

  Find the minimum of the function `f` within the interval `(a, b)`. If the function `f` is defined on the interval `(a, b)`, then this method finds an approximation `x` to the point at which `f` attains its minimum.
  `t` and `eps` define a tolerance `tol = eps |x| + t` and `f` 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:
    `f` - the function to solve
    `goalType` - type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`
    `a` - Lower bound of the interval
    `b` - Higher bound of the interval
    `eps` - Relative accuracy
    `t` - Absolute accuracy
  Returns:
    the point at which the function is minimal.
  Throws:
    `MaxIterationsExceededException` - if the maximum iteration count is exceeded.
    `FunctionEvaluationException` - if an error occurs evaluating the function.

Copyright (c) 2003-2010 Apache Software Foundation