e04dg minimizes an unconstrained nonlinear function of several variables using a pre-conditioned, limited memory quasi-Newton conjugate gradient method. First derivatives (or an ‘acceptable’ finite difference approximation to them) are required. It is intended for use on large scale problems.
public static void e04dg( int n, E04..::..E04DG_OBJFUN objfun, out int iter, out double objf, double objgrd, double x, E04..::..e04dgOptions options, out int ifail )
Public Shared Sub e04dg ( _ n As Integer, _ objfun As E04..::..E04DG_OBJFUN, _ <OutAttribute> ByRef iter As Integer, _ <OutAttribute> ByRef objf As Double, _ objgrd As Double(), _ x As Double(), _ options As E04..::..e04dgOptions, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void e04dg( int n, E04..::..E04DG_OBJFUN^ objfun, [OutAttribute] int% iter, [OutAttribute] double% objf, array<double>^ objgrd, array<double>^ x, E04..::..e04dgOptions^ options, [OutAttribute] int% ifail )
static member e04dg : n : int * objfun : E04..::..E04DG_OBJFUN * iter : int byref * objf : float byref * objgrd : float * x : float * options : E04..::..e04dgOptions * ifail : int byref -> unit
- Type: System..::..Int32On entry: , the number of variables.Constraint: .
- Type: NagLibrary..::..E04..::..E04DG_OBJFUNobjfun must calculate the objective function and possibly its gradient as well for a specified -element vector .
A delegate of type E04DG_OBJFUN.
- Type: System..::..Int32%On exit: the total number of iterations performed.
- Type: System..::..Double%On exit: the value of the objective function at the final iterate.
- Type: array<System..::..Double>()An array of size [n]On exit: the gradient of the objective function at the final iterate (or its finite difference approximation).
- Type: array<System..::..Double>()An array of size [n]On entry: an initial estimate of the solution.On exit: the final estimate of the solution.
- Type: NagLibrary..::..E04..::..e04dgOptionsAn Object of type E04.e04dgOptions. Used to configure optional parameters to this method.
e04dg is designed to solve unconstrained minimization problems of the form
where is an -element vector.
You must supply an initial estimate of the solution.
Gill P E and Murray W (1979) Conjugate-gradient methods for large-scale nonlinear optimization Technical Report SOL 79-15 Department of Operations Research, Stanford University
Gill P E, Murray W and Wright M H (1981) Practical Optimization Academic Press
Note: e04dg may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
- Not used by this method.
- Not used by this method.
- The limiting number of iterations (as determined by the optional parameter Iteration Limit () has been reached.
- The computed upper bound on the step length taken during the linesearch was too small. A rerun with an increased value of the optional parameter Maximum Step Length ( say) may be successful unless (the default value), in which case the current point cannot be improved upon.
- Not used by this method.
- The conditions for an acceptable solution (see parameter ifail in [Parameters]) have not all been met, but a lower point could not be found.If objfun computes the objective function and its gradient correctly, then this may occur because an overly stringent accuracy has been requested, i.e., the value of the optional parameter Optimality Tolerance () is too small or if . In this case you should apply the three tests described under to determine whether or not the final solution is acceptable. For a discussion of attainable accuracy see Gill et al. (1981).If many iterations have occurred in which essentially no progress has been made or e04dg has failed to move from the initial point, objfun may be incorrect. You should refer to the comments below under and check the gradients using the optional parameter Verify (). Unfortunately, there may be small errors in the objective gradients that cannot be detected by the verification process. Finite difference approximations to first derivatives are catastrophically affected by even small inaccuracies.
- The user-supplied derivatives of the objective function appear to be incorrect.Large errors were found in the derivatives of the objective function. This value of ifail will occur if the verification process indicated that at least one gradient element had no correct figures. You should refer to the printed output to determine which elements are suspected to be in error.As a first step, you should check that the code for the objective values is correct – for example, by computing the function at a point where the correct value is known. However, care should be taken that the chosen point fully tests the evaluation of the function. It is remarkable how often the values or are used to test function evaluation procedures, and how often the special properties of these numbers make the test meaningless.Special care should be used in this test if computation of the objective function involves subsidiary data communicated in storage. Although the first evaluation of the function may be correct, subsequent calculations may be in error because some of the subsidiary data has accidentally been overwritten.Errors in programming the function may be quite subtle in that the function value is almost correct. For example, the function may not be accurate to full precision because of the inaccurate calculation of a subsidiary quantity, or the limited accuracy of data upon which the function depends. A common error on machines where numerical calculations are usually performed in double precision is to include even one single precision constant in the calculation of the function; since some compilers do not convert such constants to double precision, half the correct figures may be lost by such a seemingly trivial error.
- The gradient at the starting point is ‘too small’. More precisely, the value of is less than , where is the value of the optional parameter Function Precision ().The problem should be rerun from a different starting point.
- An input parameter is invalid.
On successful exit () the accuracy of the solution will be as defined by the optional parameter Optimality Tolerance ().
To evaluate an ‘acceptable’ set of finite difference intervals using e04xa requires function evaluations per variable for a well-scaled problem and up to function evaluations per variable for a badly scaled problem.
This section describes the intermediate printout and final printout produced by e04dg. You can control the level of printed output (see the description of the optional parameter Print Level). Note that the intermediate printout and final printout are produced only if (the default ).
The following line of summary output ( characters) is produced at every iteration. In all cases, the values of the quantities are those in effect on completion of the given iteration.
|Itn||is the iteration count.|
|Step||is the step taken along the computed search direction. On reasonably well-behaved problems, the unit step (i.e., ) will be taken as the solution is approached.|
|Nfun||is the cumulated number of evaluations of the objective function needed for the linesearch. Evaluations needed for the verification of the gradients by finite differences are not included. Nfun is printed as a guide to the amount of work required for the linesearch. e04dg will perform at most function evaluations per iteration.|
|Objective||is the value of the objective function at .|
|Norm G||is the Euclidean norm of the gradient of the objective function at .|
|Norm X||is the Euclidean norm of .|
|Norm (X(k-1)-X(k))||is the Euclidean norm of .|
The following describes the printout for each variable.
|Variable||gives the name (Varbl) and index , for of the variable.|
|Value||is the value of the variable at the final iteration.|
|Gradient Value||is the value of the gradient of the objective function with respect to the th variable at the final iteration.|
Numerical values are output with a fixed number of digits; they are not guaranteed to be accurate to this precision.
This example finds a minimum of the function
The initial point is
and (to five figures).
The optimal solution is
This section contains a description of the method used by e04dg.
e04dg uses a pre-conditioned conjugate gradient method and is based upon algorithm PLMA as described in Section 4.8.3 of Gill and Murray (1979) and Gill et al. (1981).
The algorithm proceeds as follows:
Let be a given starting point and let denote the current iteration, starting with . The iteration requires , the gradient vector evaluated at , the th estimate of the minimum. At each iteration a vector (known as the direction of search) is computed and the new estimate is given by where (the step length) minimizes the function with respect to the scalar . A choice of initial step is taken as
where is a user-supplied estimate of the function value at the solution. If is not specified, the software always chooses the unit step length for . Subsequent step length estimates are computed using cubic interpolation with safeguards.
A quasi-Newton method can be used to compute the search direction by updating the inverse of the approximate Hessian and computing
The updating formula for the approximate inverse is given by
where and .
The method used to obtain the search direction is based upon computing as where is a matrix obtained by updating the identity matrix with a limited number of quasi-Newton corrections. The storage of an by matrix is avoided by storing only the vectors that define the rank two corrections – hence the term ‘limited-memory’ quasi-Newton method. The precise method depends upon the number of updating vectors stored. For example, the direction obtained with the ‘one-step’ limited memory update is given by (1) using (2) with equal to the identity matrix, viz.
Using a limited-memory quasi-Newton formula, such as the one above, guarantees to be a descent direction if all the inner products are positive for all vectors and used in the updating formula.