riso.numerical
Class Mcsrch

java.lang.Object
  extended byriso.numerical.Mcsrch

public class Mcsrch
extends java.lang.Object

This class implements an algorithm for multi-dimensional line search. This file is a translation of Fortran code written by Jorge Nocedal. It is distributed as part of the RISO project. See comments in the file LBFGS.java for more information.


Constructor Summary
Mcsrch()
           
 
Method Summary
static void mcsrch(int n, double[] x, double f, double[] g, double[] s, int is0, double[] stp, double ftol, double xtol, int maxfev, int[] info, int[] nfev, double[] wa)
          Minimize a function along a search direction.
static void mcstep(double[] stx, double[] fx, double[] dx, double[] sty, double[] fy, double[] dy, double[] stp, double fp, double dp, boolean[] brackt, double stpmin, double stpmax, int[] info)
          The purpose of this function is to compute a safeguarded step for a linesearch and to update an interval of uncertainty for a minimizer of the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mcsrch

public Mcsrch()
Method Detail

mcsrch

public static void mcsrch(int n,
                          double[] x,
                          double f,
                          double[] g,
                          double[] s,
                          int is0,
                          double[] stp,
                          double ftol,
                          double xtol,
                          int maxfev,
                          int[] info,
                          int[] nfev,
                          double[] wa)
Minimize a function along a search direction. This code is a Java translation of the function MCSRCH from lbfgs.f, which in turn is a slight modification of the subroutine CSRCH of More' and Thuente. The changes are to allow reverse communication, and do not affect the performance of the routine. This function, in turn, calls mcstep.

The Java translation was effected mostly mechanically, with some manual clean-up; in particular, array indices start at 0 instead of 1. Most of the comments from the Fortran code have been pasted in here as well.

The purpose of mcsrch is to find a step which satisfies a sufficient decrease condition and a curvature condition.

At each stage this function updates an interval of uncertainty with endpoints stx and sty. The interval of uncertainty is initially chosen so that it contains a minimizer of the modified function

      f(x+stp*s) - f(x) - ftol*stp*(gradf(x)'s).
 
If a step is obtained for which the modified function has a nonpositive function value and nonnegative derivative, then the interval of uncertainty is chosen so that it contains a minimizer of f(x+stp*s).

The algorithm is designed to find a step which satisfies the sufficient decrease condition

       f(x+stp*s) <= f(X) + ftol*stp*(gradf(x)'s),
 
and the curvature condition
       abs(gradf(x+stp*s)'s)) <= gtol*abs(gradf(x)'s).
 
If ftol is less than gtol and if, for example, the function is bounded below, then there is always a step which satisfies both conditions. If no step can be found which satisfies both conditions, then the algorithm usually stops when rounding errors prevent further progress. In this case stp only satisfies the sufficient decrease condition.

Parameters:
n - The number of variables.
x - On entry this contains the base point for the line search. On exit it contains x + stp*s.
f - On entry this contains the value of the objective function at x. On exit it contains the value of the objective function at x + stp*s.
g - On entry this contains the gradient of the objective function at x. On exit it contains the gradient at x + stp*s.
s - The search direction.
stp - On entry this contains an initial estimate of a satifactory step length. On exit stp contains the final estimate.
ftol - Tolerance for the sufficient decrease condition.
xtol - Termination occurs when the relative width of the interval of uncertainty is at most xtol.
maxfev - Termination occurs when the number of evaluations of the objective function is at least maxfev by the end of an iteration.
info - This is an output variable, which can have these values:
  • info = 0 Improper input parameters.
  • info = -1 A return is made to compute the function and gradient.
  • info = 1 The sufficient decrease condition and the directional derivative condition hold.
  • info = 2 Relative width of the interval of uncertainty is at most xtol.
  • info = 3 Number of function evaluations has reached maxfev.
  • info = 4 The step is at the lower bound stpmin.
  • info = 5 The step is at the upper bound stpmax.
  • info = 6 Rounding errors prevent further progress. There may not be a step which satisfies the sufficient decrease and curvature conditions. Tolerances may be too small.
nfev - On exit, this is set to the number of function evaluations.
wa - Temporary storage array, of length n.

mcstep

public static void mcstep(double[] stx,
                          double[] fx,
                          double[] dx,
                          double[] sty,
                          double[] fy,
                          double[] dy,
                          double[] stp,
                          double fp,
                          double dp,
                          boolean[] brackt,
                          double stpmin,
                          double stpmax,
                          int[] info)
The purpose of this function is to compute a safeguarded step for a linesearch and to update an interval of uncertainty for a minimizer of the function.

The parameter stx contains the step with the least function value. The parameter stp contains the current step. It is assumed that the derivative at stx is negative in the direction of the step. If brackt[0] is true when mcstep returns then a minimizer has been bracketed in an interval of uncertainty with endpoints stx and sty.

Variables that must be modified by mcstep are implemented as 1-element arrays.

Parameters:
stx - Step at the best step obtained so far. This variable is modified by mcstep.
fx - Function value at the best step obtained so far. This variable is modified by mcstep.
dx - Derivative at the best step obtained so far. The derivative must be negative in the direction of the step, that is, dx and stp-stx must have opposite signs. This variable is modified by mcstep.
sty - Step at the other endpoint of the interval of uncertainty. This variable is modified by mcstep.
fy - Function value at the other endpoint of the interval of uncertainty. This variable is modified by mcstep.
dy - Derivative at the other endpoint of the interval of uncertainty. This variable is modified by mcstep.
stp - Step at the current step. If brackt is set then on input stp must be between stx and sty. On output stp is set to the new step.
fp - Function value at the current step.
dp - Derivative at the current step.
brackt - Tells whether a minimizer has been bracketed. If the minimizer has not been bracketed, then on input this variable must be set false. If the minimizer has been bracketed, then on output this variable is true.
stpmin - Lower bound for the step.
stpmax - Upper bound for the step.
info - On return from mcstep, this is set as follows: If info is 1, 2, 3, or 4, then the step has been computed successfully. Otherwise info = 0, and this indicates improper input parameters.