public class MinUnconMultiVar extends Object implements Serializable, Cloneable
Class MinUnconMultivar
uses a quasiNewton method to find
the minimum of a function f(x) of n
variables. The problem is stated as follows:
Given a starting point , the search direction is computed according to the formula
where B is a positive definite approximation of the Hessian, and is the gradient evaluated at . A line search is then used to find a new point
such that
Finally, the optimality condition where is a gradient tolerance, is sought.
When optimality is not achieved, B is updated according to the BFGS formula
where and . Another search direction is then computed to begin the next iteration. For more details, see Dennis and Schnabel (1983, Appendix A).
In this implementation, the first stopping criterion for
MinUnconMultivar
occurs when the norm of the gradient is less
than the given gradient tolerance gradientTolerance
. The second
stopping criterion for MinUnconMultivar
occurs when the scaled
distance between the last two steps is less than the step tolerance
stepTolerance
.
Since by default, a finitedifference method is used to estimate the
gradient for some single precision calculations, an inaccurate estimate of
the gradient may cause the algorithm to terminate at a noncritical point.
Supply the gradient for a more accurate gradient evaluation
(setGradient
).
The user may also choose to supply the Hessian. If, during intermediate calculations, the user supplied Hessian becomes nonsymmetric positive definite, then the algorithm will resort to using the default approximate Hessian.
Modifier and Type  Class and Description 

static class 
MinUnconMultiVar.ApproximateMinimumException
Scaled step tolerance satisfied; the current point may be an approximate
local solution, or the algorithm is making very slow progress and is not
near a solution, or the scaled step tolerance is too big.

static class 
MinUnconMultiVar.FalseConvergenceException
False convergence error; the iterates appear to be converging to a
noncritical point.

static interface 
MinUnconMultiVar.Function
Public interface for the user supplied function to the
MinUnconMultiVar object. 
static interface 
MinUnconMultiVar.Gradient
Public interface for the user supplied gradient to the
MinUnconMultiVar object. 
static interface 
MinUnconMultiVar.Hessian
Public interface for the user supplied Hessian to the
MinUnconMultiVar object. 
static class 
MinUnconMultiVar.MaxIterationsException
Maximum number of iterations exceeded.

static class 
MinUnconMultiVar.UnboundedBelowException
Five consecutive steps of the maximum allowable stepsize have been taken,
either the function is unbounded below, or has a finite asymptote in some
direction or the maximum allowable step size is too small.

Constructor and Description 

MinUnconMultiVar(int n)
Unconstrained minimum constructor for a function of n variables of type
double . 
Modifier and Type  Method and Description 

double[] 
computeMin(MinUnconMultiVar.Function F)
Return the minimum point of a function of n variables of type
double
using a finitedifference gradient or using a usersupplied gradient. 
int 
getErrorStatus()
Returns the nonfatal error status.

int 
getIterations()
Returns the number of iterations used to compute a minimum.

int 
getNumberOfThreads()
Returns the number of
java.lang.Thread instances used for
parallel processing. 
void 
setDigits(double fdigit)
Set the number of good digits in the function.

void 
setFscale(double fscale)
Set the function scaling value for scaling the gradient.

void 
setGradientTolerance(double gradientTolerance)
Sets the gradient tolerance.

void 
setGuess(double[] xguess)
Set the initial guess of the minimum point of the input function.

void 
setIhess(int ihess)
Set the Hessian initialization parameter.

void 
setMaximumStepsize(double maximumStepsize)
Set the maximum allowable stepsize to use.

void 
setMaxIterations(int maxIterations)
Set the maximum number of iterations allowed.

void 
setNumberOfThreads(int numberOfThreads)
Sets the number of
java.lang.Thread instances to be used for
parallel processing. 
void 
setStepTolerance(double stepTolerance)
Set the scaled step tolerance to use when changing x.

void 
setXscale(double[] xscale)
Set the diagonal scaling matrix for the variables.

public MinUnconMultiVar(int n)
double
.n
 An int
scalar value which defines the number of variables
of the function whose minimum is to be found.public double[] computeMin(MinUnconMultiVar.Function F) throws MinUnconMultiVar.FalseConvergenceException, MinUnconMultiVar.MaxIterationsException, MinUnconMultiVar.UnboundedBelowException
double
using a finitedifference gradient or using a usersupplied gradient.F
 defines the function whose minimum is to be found. F
can be used to
supply a gradient of the function. If F
implements
Gradient
then the usersupplied gradient is used.
Otherwise, an attempt to find the minimum is made using a
finitedifference gradient. If F implements
Hessian
then the usersupplied gradient and Hessian are used. Otherwise,
an approximate Hessian is used during computation.double
array containing the point at which
the minimum of the input function occurs.MinUnconMultiVar.FalseConvergenceException
MinUnconMultiVar.MaxIterationsException
MinUnconMultiVar.UnboundedBelowException
public int getErrorStatus()
int
specifying the nonfatal error status:
Status  Meaning 
1  The last global step failed to locate a lower point than the current x value. The current x may be an approximate local minimizer and no more accuracy is possible or the step tolerance may be too large. 
2  Relative function convergence; both the actual and predicted relative reductions in the function are less than or equal to the relative function convergence tolerance. 
3  Scaled step tolerance satisfied; the current point may be an approximate local solution, or the algorithm is making very slow progress and is not near a solution, or the step tolerance is too big. 
public int getIterations()
int
specifying the number of iterations used
to compute the minimum.public int getNumberOfThreads()
java.lang.Thread
instances used for
parallel processing.int
containing the number of
java.lang.Thread
instances used for parallel processing.public void setDigits(double fdigit)
fdigit
 a double
scalar value specifying the number of good digits
in the user supplied functionIllegalArgumentException
 is thrown if fdigit
is less than or equal to 0public void setFscale(double fscale)
fscale
 a double
scalar specifying the function scaling value
for scaling the gradientIllegalArgumentException
 is thrown if fscale
is less than or equal to 0.public void setGradientTolerance(double gradientTolerance)
gradientTolerance
 a double
specifying the gradient tolerance used
to compute the gradientIllegalArgumentException
 is thrown if gradientTolerance is less than or equal to 0public void setGuess(double[] xguess)
xguess
 a double
array specifying the initial guess of the
minimum point of the input functionpublic void setIhess(int ihess)
ihess
 an int
scalar value specifying the Hessian initialization
parameter. If ihess
= 0.0 the Hessian is initialized to
the identity matrix. Otherwise, the Hessian is initialized
to the diagonal matrix containing
max(abs(f(xguess)),fscale)*xscale*xscale
where xguess is the initial guess of the computed solution and
xscale is the scaling vector for the variables.public void setMaximumStepsize(double maximumStepsize)
maximumStepsize
 a nonnegative double
value specifying the maximum allowable
stepsizeIllegalArgumentException
 is thrown if maximumStepsize is less than or equal to 0public void setMaxIterations(int maxIterations)
maxIterations
 an int
specifying the maximum number of
iterations allowedIllegalArgumentException
 is thrown if maxIterations is less than or equal to 0public void setNumberOfThreads(int numberOfThreads)
java.lang.Thread
instances to be used for
parallel processing.numberOfThreads
 an int
specifying the number of
java.lang.Thread
instances to be used for parallel
processing. If numberOfThreads
is greater than 1, then
interface Function.f
is evaluated in parallel and
Function.f
must be threadsafe. Otherwise, unexpected
behavior can occur.
Default: numberOfThreads
= 1.
public void setStepTolerance(double stepTolerance)
The second stopping criterion for this optimizer is that the scaled distance between the last two steps be less than the step tolerance.
stepTolerance
 a double
scalar value specifying the scaled step tolerance.
The ith component of the scaled step between two points x and y is
computed as
abs(x(i)y(i))/max(abs(x(i)),1/xscale(i))
where xscale is the scaling vector for the variables.IllegalArgumentException
 is thrown if stepTolerance is less than or equal to 0public void setXscale(double[] xscale)
xscale
 a double
array specifying the diagonal scaling matrix
for the variablesIllegalArgumentException
 is thrown if any of the elements
of xscale is less than or equal to 0Copyright © 19702015 Rogue Wave Software
Built October 13 2015.