public class BrentMinimizer
extends java.lang.Object
Richard Brent, Algorithms for Minimization without Derivatives, Dover, 2002, ISBN: 0-486-41998-3The code itself is based on the C implementation by John Burkardt available at https://people.math.sc.edu/Burkardt/c_src/brent/brent.html. An almost identical implementation is available in Numerical Recipes in C.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_ITERS |
Constructor and Description |
---|
BrentMinimizer() |
Modifier and Type | Method and Description |
---|---|
void |
clearIterationCount()
Clears the cummulatuve iteration count.
|
static FunctionValuePair |
findMin(Function1x1 func,
double a,
double b,
double eps)
Finds a local minimum of a function within an interval
[a,b] . |
static FunctionValuePair |
findMin(Function1x1 func,
double a,
double fa,
double b,
double fb,
double eps)
Finds the minimum of a function over an interval
[a,b] , given
evaluations of the function at the end points. |
FunctionValuePair |
findMinimum(Function1x1 func,
double a,
double b,
double eps)
Finds a local minimum of a function within an interval
[a,b] . |
FunctionValuePair |
findMinimum(Function1x1 func,
double a,
double b,
double eps,
boolean evalEndPoints)
Finds a local minimum of a function within an interval
[a,b] . |
FunctionValuePair |
findMinimum(Function1x1 func,
double a,
double fa,
double b,
double fb,
double eps)
Finds the minimum of a function over an interval
[a,b] , given
evaluations of the function at the end points. |
int |
getIterationCount()
Queries the cummulative number of iterations invoked by this minimizer
since it was created or
clearIterationCount() was called. |
int |
getMaxIterations()
Queries the maximum number of allowed iterations.
|
boolean |
iterationLimitExceeded()
Queries whether the iteration limit was exceeded on the most recent call
to one of the
findMinimum methods. |
void |
setMaxIterations(int maxi)
Set the maximum number of allowed iterations.
|
public int getMaxIterations()
public void setMaxIterations(int maxi)
DEFAULT_MAX_ITERS
.maxi
- maximum number of iterationspublic void clearIterationCount()
public int getIterationCount()
clearIterationCount()
was called.public boolean iterationLimitExceeded()
findMinimum
methods.true
if iteration limit was exceeded.public static FunctionValuePair findMin(Function1x1 func, double a, double b, double eps)
[a,b]
.
This is a static convenience wrapper for
findMinimum(Function1x1,double,double,double)
.func
- function to evaluatea
- left interval end pointb
- right interval end pointeps
- relative tolerance for finding the minimum abscissapublic FunctionValuePair findMinimum(Function1x1 func, double a, double b, double eps)
[a,b]
.
The minimum is found within a relative abscissa tolerance eps
,
which generally should not be less than 1.0e-8
(i.e., the square
root of machine precision). If no true local mimimum is found, then the
method will return the value at the minimum end point.func
- function to evaluatea
- left interval end pointb
- right interval end pointeps
- relative tolerance for finding the minimum abscissapublic FunctionValuePair findMinimum(Function1x1 func, double a, double b, double eps, boolean evalEndPoints)
[a,b]
.
The minimum is found within a relative abscissa tolerance eps
,
which generally should not be less than 1.0e-8
(i.e., the square
root of machine precision). If no true local mimimum is found, then the
method will return the value at the minimum end point.func
- function to evaluatea
- left interval end pointb
- right interval end pointeps
- relative tolerance for finding the minimum abscissaevalEndPoints
- if true
, the method starts by evaluating the
function at the interval end points, which may result in fewer
iterations. This is the default behavior for methods that do not expose
this as an option.public static FunctionValuePair findMin(Function1x1 func, double a, double fa, double b, double fb, double eps)
[a,b]
, given
evaluations of the function at the end points. This is a static
convenience wrapper for findMinimum(Function1x1,double,double,double,double,double)
.func
- function to evaluatea
- left interval end pointfa
- value of the function at a
b
- right interval end pointfb
- value of the function at b
eps
- relative tolerance for finding the minimum abscissapublic FunctionValuePair findMinimum(Function1x1 func, double a, double fa, double b, double fb, double eps)
[a,b]
, given
evaluations of the function at the end points. The minimum is found
within a relative abscissa tolerance eps
, which generally should
not be less than 1.0e-8
(i.e., the square root of machine
precision). If no true local mimimum is found, then the method will
return the value at the minimum end point.func
- function to evaluatea
- left interval end pointfa
- value of the function at a
b
- right interval end pointfb
- value of the function at b
eps
- relative tolerance for finding the minimum abscissa