|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.stanford.rsl.jpop.SimpleFunctionOptimizer
public class SimpleFunctionOptimizer
This class was is based on the Fortran-Java translation of Steve Verrill of fzero and fmin. The code was adopted and altered to fit into a hierarchical object-oriented program structure.
Constructor Summary | |
---|---|
SimpleFunctionOptimizer()
|
Method Summary | |
---|---|
double |
findRoot(SimpleOptimizableFunction function)
Method to find a root of a function between leftEndPoint and rightEndPoint. May use an initial guess to speed to convergence. Accuracy can be adjusted using relativeTolerance and absoluteTolerance. |
static double |
fmin(double leftEndPoint,
double rightEndPoint,
SimpleOptimizableFunction function,
double toleranceFactor)
Deprecated. |
static void |
fzero(SimpleOptimizableFunction function,
double[] b,
double[] c,
double r,
double re,
double ae,
int[] iflag)
Deprecated. |
double |
getAbsoluteTolerance()
|
double |
getInitialGuess()
|
double |
getLeftEndPoint()
|
double |
getRelativeTolerance()
|
double |
getRightEndPoint()
|
boolean |
isPrintWarnings()
|
boolean |
isUseInitialGuess()
|
double |
minimize(SimpleOptimizableFunction function)
Minimizes a SimpleOptimizableFunction. |
void |
setAbsoluteTolerance(double absoluteTolerance)
Sets the absolute tolerance of the search. Defaults to 3.0E-08. |
void |
setInitialGuess(double initialGuess)
An initial guess of a zero can be set. |
void |
setLeftEndPoint(double leftEndPoint)
Sets the left end point of the search interval. Default is Double.MIN_VALUE. |
void |
setPrintWarnings(boolean printWarnings)
Turns warnings on or off. Default is on. |
void |
setRelativeTolerance(double relativeTolerance)
Sets the relative tolerance. Defaults to 3.0E-04. |
void |
setRightEndPoint(double rightEndPoint)
Sets the right end point of the search interval. Defaults to Double.MAX_VALUE. |
void |
setUseInitialGuess(boolean useInitialGuess)
Turns the use of an initial guess on or off. Default is off. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleFunctionOptimizer()
Method Detail |
---|
public double getLeftEndPoint()
public void setLeftEndPoint(double leftEndPoint)
leftEndPoint
- the leftEndPoint to setpublic double getRightEndPoint()
public void setRightEndPoint(double rightEndPoint)
rightEndPoint
- the rightEndPoint to setpublic double getAbsoluteTolerance()
public void setAbsoluteTolerance(double absoluteTolerance)
absoluteTolerance
- the absoluteTolerance to setpublic double getRelativeTolerance()
public void setRelativeTolerance(double relativeTolerance)
relativeTolerance
- the relativeTolerance to setpublic boolean isPrintWarnings()
public void setPrintWarnings(boolean printWarnings)
printWarnings
- the printWarnings to setpublic boolean isUseInitialGuess()
public void setUseInitialGuess(boolean useInitialGuess)
useInitialGuess
- the useInitialGuess to setpublic double getInitialGuess()
public void setInitialGuess(double initialGuess)
initialGuess
- the initialGuess to setpublic double minimize(SimpleOptimizableFunction function)
function
- the function to minimize.
@Deprecated public static double fmin(double leftEndPoint, double rightEndPoint, SimpleOptimizableFunction function, double toleranceFactor)
This method performs a 1-dimensional minimization. It implements Brent's method which combines a golden-section search and parabolic interpolation. The introductory comments from the FORTRAN version are provided below. This method is a translation from FORTRAN to Java of the Netlib function fmin. In the Netlib listing no author is given. Translated by Steve Verrill, March 24, 1998.
leftEndPoint
- Left endpoint of initial intervalrightEndPoint
- Right endpoint of initial intervalfunction
- A class that defines a method, evaluate(),
to minimize. The class must implement
the SimpleOptimizableFunction interface.
evaluate must have one
double valued argument.toleranceFactor
- Desired length of the interval in which
the minimum will be determined to lie
(This should be greater than, roughly, 3.0e-8.)
public double findRoot(SimpleOptimizableFunction function)
function
-
@Deprecated public static void fzero(SimpleOptimizableFunction function, double[] b, double[] c, double r, double re, double ae, int[] iflag)
This method searches for a zero of a function f(x) between the given values b and c until the width of the interval (b,c) has collapsed to within a tolerance specified by the stopping criterion, Math.abs(b-c) <= 2.0*(rw*Math.abs(b)+ae). The method used is an efficient combination of bisection and the secant rule. The introductory comments from the FORTRAN version are provided below. This method is a translation from FORTRAN to Java of the Netlib (actually it is in the SLATEC library which is available at Netlib) function dfzero. In the FORTRAN code, L.F. Shampine and H.A. Watts are listed as the authors. Translated by Steve Verrill, April 17, 2001.
function
- A class that defines a method, evaluate,
that returns a value that is to be zeroed.
The class must implement
the SimpleOptimizableFunction interface.
evaluate must have one
double valued argument.b[1]
- One end point of the initial interval. The value returned
for b[1] is usually the better approximation to a
zero of evaluate.c[1]
- The other end point of the initial interval.r
- Initial guess of a zero. A (better) guess of a zero
of evaluate() which could help in
speeding up convergence. If evaluate(b) and evaluate(r) have
opposite signs, a root will be found in the interval
(b,r); if not, but evaluate(r) and evaluate(c) have opposite
signs, a root will be found in the interval (r,c);
otherwise, the interval (b,c) will be searched for a
possible root. When no better guess is known, it is
recommended that r be set to b or c; because if r is
not interior to the interval (b,c), it will be ignored.re
- Relative error used for rw in the stopping criterion.
If the requested re is less than machine precision,
then rw is set to approximately machine precision.ae
- Absolute error used in the stopping criterion. If the
given interval (b,c) contains the origin, then a
nonzero value should be chosen for AE.iflag[1]
- A status code. User must check iflag[1] after each call.
Control returns to the user from dfzero in all cases.
1: b is within the requested tolerance of a zero.
The interval (b,c) collapsed to the requested
tolerance, the function changes sign in (b,c), and
evaluate(x) decreased in magnitude as (b,c) collapsed.
2: evaluate(b) = 0. However, the interval (b,c) may not have
collapsed to the requested tolerance.
3: b may be near a singular point of evaluate(x).
The interval (b,c) collapsed to the requested tol-
erance and the function changes sign in (b,c), but
evaluate(x) increased in magnitude as (b,c) collapsed,i.e.
Math.abs(evaluate(b out)) >
Math.max(Math.abs(evaluate(b in)),
Math.abs(evaluate(c in)))
4: No change in sign of evaluate(x) was found although the
interval (b,c) collapsed to the requested tolerance.
The user must examine this case and decide whether
b is near a local minimum of evaluate(x), or b is near a
zero of even multiplicity, or neither of these.
5: Too many (> 500) function evaluations used.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |