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: 799857 $ $Date: 2009-08-01 09:07:12 -0400 (Sat, 01 Aug 2009) $
Field Summary |
private static double |
c
Golden section. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
c
private static final double c
- Golden section.
BrentOptimizer
public BrentOptimizer()
- Construct a solver.
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 solvegoalType
- type of optimization goal: either GoalType.MAXIMIZE
or GoalType.MINIMIZE
a
- Lower bound of the intervalb
- Higher bound of the intervaleps
- Relative accuracyt
- 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