this routine usesoptional parametersto define choices in the problem specification and in the details of the algorithm. If you wish to use default settings for all of the optional parameters, you need only read Sections 1 to 10 of this document. If, however, you wish to reset some or all of the settings please refer to Section 11 for a detailed description of the algorithm and to Section 12 for a detailed description of the specification of the optional parameters.
e04dgf/e04dga 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.
e04dga is a version of e04dgf that has additional arguments in order to make it safe for use in multithreaded applications (see Section 5). The initialization routine e04wbfmust have been called before calling e04dga.
e04dgf/e04dga is designed to solve unconstrained minimization problems of the form
where is an -element vector.
You must supply an initial estimate of the solution.
For maximum reliability, it is preferable to provide all first partial derivatives. If all of the derivatives cannot be provided, you are recommended to obtain approximate values (using finite differences) by calling e04xaf/e04xaa from within objfun. This is illustrated in Section 10 in e04djf/e04dja.
The method used by e04dgf/e04dga is described in Section 11.
4References
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
5Arguments
1: – IntegerInput
On entry: , the number of variables.
Constraint:
.
2: – Subroutine, supplied by the user.External Procedure
objfun must calculate the objective function and possibly its gradient as well for a specified -element vector .
On exit: may be set to a negative value if you wish to terminate the solution to the current problem, and in this case e04dgf/e04dga will terminate with ifail set to mode.
2: – IntegerInput
On entry: , the number of variables.
3: – Real (Kind=nag_wp) arrayInput
On entry: , the vector of variables at which the objective function and its gradient are to be evaluated.
4: – Real (Kind=nag_wp)Output
On exit: the value of the objective function at .
5: – Real (Kind=nag_wp) arrayOutput
On exit: if ,
must contain the value of evaluated at , for .
6: – IntegerInput
On entry: will be on the first call of objfun by e04dgf/e04dga, and for all subsequent calls. Thus, you may wish to test, nstate within objfun in order to perform certain calculations once only. For example, you may read data or initialize COMMON blocks when .
7: – Integer arrayUser Workspace
8: – Real (Kind=nag_wp) arrayUser Workspace
objfun is called with the arguments iuser and ruser as supplied to e04dgf/e04dga. You should use the arrays iuser and ruser to supply information to objfun.
objfun must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which e04dgf/e04dga is called. Arguments denoted as Input must not be changed by this procedure.
Note:objfun should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by e04dgf/e04dga. If your code inadvertently does return any NaNs or infinities, e04dgf/e04dga is likely to produce unexpected results.
objfun should be tested separately before being used in conjunction with e04dgf/e04dga. See also the description of the optional parameter Verify.
3: – IntegerOutput
On exit: the total number of iterations performed.
4: – Real (Kind=nag_wp)Output
On exit: the value of the objective function at the final iterate.
5: – Real (Kind=nag_wp) arrayOutput
On exit: the gradient of the objective function at the final iterate (or its finite difference approximation).
6: – Real (Kind=nag_wp) arrayInput/Output
On entry: an initial estimate of the solution.
On exit: the final estimate of the solution.
7: – Integer arrayWorkspace
8: – Real (Kind=nag_wp) arrayWorkspace
9: – Integer arrayUser Workspace
10: – Real (Kind=nag_wp) arrayUser Workspace
iuser and ruser are not used by e04dgf/e04dga, but are passed directly to objfun and may be used to pass information to this routine.
11: – IntegerInput/Output
Note:for e04dga, ifail does not occur in this position in the argument list. See the additional arguments described below.
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended since useful values can be provided in some output arguments even when on exit. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
e04dgf/e04dga returns with if the following three conditions are satisfied:
(i)
(ii)
(iii) or
where is the value of the optional parameter Optimality Tolerance () and is the absolute error associated with computing the objective function.
For a full discussion on termination criteria see Chapter 8 of Gill et al. (1981).
Note: the following are additional arguments for specific use with e04dga. Users of e04dgf therefore need not read the remainder of this description.
Note: see the argument description for ifail above.
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
Note: in some cases e04dgf/e04dga may return useful information.
User requested termination.
Too many iterations.
If the algorithm appears to be making satisfactory progress, optional parameter Iteration Limit may be too small. If so, increase its value and rerun e04dgf/e04dga. If the algorithm seems to be making little or no progress, then you should check for incorrect gradients as described under .
Computed upper bound on step length is 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.
Current point cannot be improved upon.
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 e04dgf/e04dga 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.
Large errors found in the derivatives.
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.
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.
Gradient at the starting point is too small.
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.
On entry, .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
On successful exit () the accuracy of the solution will be as defined by the optional parameter Optimality Tolerance ().
8Parallelism and Performance
e04dgf/e04dga makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
To evaluate an ‘acceptable’ set of finite difference intervals using e04xaf/e04xaa requires function evaluations per variable for a well-scaled problem and up to function evaluations per variable for a badly scaled problem.
10Example
This example finds a minimum of the function
The initial point is
and (to five figures).
The optimal solution is
and .
The document for e04djf/e04dja includes an example program to solve the same problem using some of the optional parameters described in Section 12.
10.1Program Text
Note:the following programs illustrate the use of e04dgf and e04dga.
Note: the remainder of this document is intended for more advanced users. Section 11 contains a detailed description of the algorithm which may be needed in order to understand Section 12. Section 12 describes the optional parameters which may be set by calls to e04djf/e04djaand/ore04dkf/e04dka.
11Algorithmic Details
This section contains a description of the method used by e04dgf/e04dga.
e04dgf/e04dga 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
(1)
The updating formula for the approximate inverse is given by
(2)
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 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.
12Optional Parameters
Several optional parameters in e04dgf/e04dga define choices in the problem specification or the algorithm logic. In order to reduce the number of formal arguments of e04dgf/e04dga these optional parameters have associated default values that are appropriate for most problems. Therefore, you need only specify those optional parameters whose values are to be different from their default values.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in Section 12.1.
Optional parameters may be specified by calling one, or both, of the routines e04djf/e04djaande04dkf/e04dka before a call to e04dgf/e04dga.
e04djf/e04dja reads options from an external options file, with Begin and End as the first and last lines respectively and each intermediate line defining a single optional parameter. For example,
Begin
Print Level = 1
End
The call
Call e04djf/e04dja (ioptns, inform)
can then be used to read the file on unit ioptns.
inform will be zero on successful exit. e04djf/e04dja should be consulted for a full description of this method of supplying optional parameters.
e04dkf/e04dka can be called to supply options directly, one call being necessary for each optional parameter.
For example,
Call e04dkf/e04dka ('Print Level = 1')
e04dkf/e04dka should be consulted for a full description of this method of supplying optional parameters.
All optional parameters not specified by you are set to their default values. Optional parameters specified by you are unaltered by e04dgf/e04dga (unless they define invalid values) and so remain in effect for subsequent calls unless altered by you.
12.1Description of the Optional Parameters
For each option, we give a summary line, a description of the optional parameter and details of constraints.
The summary line contains:
the keywords, where the minimum abbreviation of each keyword is underlined (if no characters of an optional qualifier are underlined, the qualifier may be omitted);
a parameter value,
where the letters , and denote options that take character, integer and real values respectively;
the default value, where the symbol is a generic notation for machine precision (see x02ajf), and denotes the relative precision of the objective function Function Precision.
Keywords and character values are case and white space insensitive.
Defaults
This special keyword may be used to reset all optional parameters to their default values.
Estimated Optimal Function Value
This value of specifies the user-supplied guess of the optimum objective function value . This value is used to calculate an initial step length (see Section 11). If the value of is not specified (the default), then this has the effect of setting to unity. It should be noted that for badly scaled functions a unit step along the steepest descent direction will often compute the objective function at very large values of .
Function Precision
Default
The parameter defines , which is intended to be a measure of the accuracy with which the problem function can be computed. If or , the default value is used.
The value of should reflect the relative precision of ; i.e., acts as a relative precision when is large, and as an absolute precision when is small. For example, if is typically of order and the first six significant digits are known to be correct, an appropriate value for would be . In contrast, if is typically of order and the first six significant digits are known to be correct, an appropriate value for would be . The choice of can be quite complicated for badly scaled problems; see Chapter 8 of Gill et al. (1981) for a discussion of scaling techniques. The default value is appropriate for most simple functions that are computed with full accuracy. However when the accuracy of the computed function values is known to be significantly worse than full precision, the value of should be large enough so that no attempt will be made to distinguish between function values that differ by less than the error inherent in the calculation.
Iteration Limit
Default
Iters
Default
Itns
Default
The value of specifies the maximum number of iterations allowed before termination. If , the default value is used.
Problems whose Hessian matrices at the solution contain sets of clustered eigenvalues are likely to be minimized in significantly fewer than iterations. Problems without this property may require anything between and iterations, with approximately iterations being a common figure for moderately difficult problems.
Linesearch Tolerance
Default
The value controls the accuracy with which the step taken during each iteration approximates a minimum of the function along the search direction (the smaller the value of , the more accurate the linesearch). The default value requests an inaccurate search, and is appropriate for most problems. A more accurate search may be appropriate when it is desirable to reduce the number of iterations – for example, if the objective function is cheap to evaluate. If or , the default value is used.
List
Default for e04dgf
Nolist
Default for e04dga
Optional parameter List enables printing of each optional parameter specification as it is supplied. Nolist suppresses this printing.
Maximum Step Length
Default
If , the maximum allowable step length for the linesearch is taken as . If , the default value is used.
Optimality Tolerance
Default
The parameter specifies the accuracy to which you wish the final iterate to approximate a solution of the problem. Broadly speaking, indicates the number of correct figures desired in the objective function at the solution. For example, if is and termination occurs with (see Section 5), then the final point satisfies the termination criteria, where represents Optimality Tolerance. If or , the default value is used. If Optimality Tolerance is chosen below a certain threshold, it will automatically be reset to another value.
Print Level
Default for e04dgf
Default for e04dga
The value controls the amount of printout produced by e04dgf/e04dga, as indicated below. A detailed description of the printout is given in Section 12.2 (summary output at each iteration and the final solution).
Output
No output.
The final solution only.
One line of summary output ( characters; see Section 12.2) for each iteration (no printout of the final solution).
The final solution and one line of summary output for each iteration.
Start Objective Check at Variable
Default
Stop Objective Check at Variable
Default
These keywords take effect only if . They may be used to control the verification of gradient elements computed by objfun. For example, if the first elements of the objective gradient appeared to be correct in an earlier run, so that only element remains questionable, it is reasonable to specify . If the first variables appear linearly in the objective, so that the corresponding gradient elements are constant, the above choice would also be appropriate.
If or , the default value is used. If or , the default value is used.
Verify Level
Default
Verify
Verify Gradients
Verify Objective Gradients
These keywords refer to finite difference checks on the gradient elements computed by objfun. Gradients are verified at the user-supplied initial estimate of the solution. The possible choices for are as follows:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to objfun.
In addition to the ‘cheap’ test, individual gradient elements will also be checked using a reliable (but more expensive) test.
This section describes the intermediate printout and final printout produced by e04dgf/e04dga. 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
for e04dgf, by default no output is produced by e04dga).
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. e04dgf/e04dga 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.