NAG FL Interface
e04lbf (bounds_mod_deriv2_comp)
1
Purpose
e04lbf is a comprehensive modified Newton algorithm for finding:
- an unconstrained minimum of a function of several variables
- a minimum of a function of several variables subject to fixed upper and/or lower bounds on the variables.
First and second derivatives are required. The routine is intended for functions which have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities).
2
Specification
Fortran Interface
Subroutine e04lbf ( |
n, funct, h, monit, iprint, maxcal, eta, xtol, stepmx, ibound, bl, bu, x, hesl, lh, hesd, istate, f, g, iw, liw, w, lw, ifail) |
Integer, Intent (In) |
:: |
n, iprint, maxcal, ibound, lh, liw, lw |
Integer, Intent (Inout) |
:: |
iw(liw), ifail |
Integer, Intent (Out) |
:: |
istate(n) |
Real (Kind=nag_wp), Intent (In) |
:: |
eta, xtol, stepmx |
Real (Kind=nag_wp), Intent (Inout) |
:: |
bl(n), bu(n), x(n), w(lw) |
Real (Kind=nag_wp), Intent (Out) |
:: |
hesl(lh), hesd(n), f, g(n) |
External |
:: |
funct, h, monit |
|
C Header Interface
#include <nag.h>
void |
e04lbf_ (const Integer *n, void (NAG_CALL *funct)(Integer *iflag, const Integer *n, const double xc[], double *fc, double gc[], Integer iw[], const Integer *liw, double w[], const Integer *lw), void (NAG_CALL *h)(Integer *iflag, const Integer *n, const double xc[], double fhesl[], const Integer *lh, double fhesd[], Integer iw[], const Integer *liw, double w[], const Integer *lw), void (NAG_CALL *monit)(const Integer *n, const double xc[], const double *fc, const double gc[], const Integer istate[], const double *gpjnrm, const double *cond, const logical *posdef, const Integer *niter, const Integer *nf, Integer iw[], const Integer *liw, double w[], const Integer *lw), const Integer *iprint, const Integer *maxcal, const double *eta, const double *xtol, const double *stepmx, const Integer *ibound, double bl[], double bu[], double x[], double hesl[], const Integer *lh, double hesd[], Integer istate[], double *f, double g[], Integer iw[], const Integer *liw, double w[], const Integer *lw, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
e04lbf_ (const Integer &n, void (NAG_CALL *funct)(Integer &iflag, const Integer &n, const double xc[], double &fc, double gc[], Integer iw[], const Integer &liw, double w[], const Integer &lw), void (NAG_CALL *h)(Integer &iflag, const Integer &n, const double xc[], double fhesl[], const Integer &lh, double fhesd[], Integer iw[], const Integer &liw, double w[], const Integer &lw), void (NAG_CALL *monit)(const Integer &n, const double xc[], const double &fc, const double gc[], const Integer istate[], const double &gpjnrm, const double &cond, const logical &posdef, const Integer &niter, const Integer &nf, Integer iw[], const Integer &liw, double w[], const Integer &lw), const Integer &iprint, const Integer &maxcal, const double &eta, const double &xtol, const double &stepmx, const Integer &ibound, double bl[], double bu[], double x[], double hesl[], const Integer &lh, double hesd[], Integer istate[], double &f, double g[], Integer iw[], const Integer &liw, double w[], const Integer &lw, Integer &ifail) |
}
|
The routine may be called by the names e04lbf or nagf_opt_bounds_mod_deriv2_comp.
3
Description
e04lbf is applicable to problems of the form:
Special provision is made for unconstrained minimization (i.e., problems which actually have no bounds on the
), problems which have only non-negativity bounds, and problems in which
and
. It is possible to specify that a particular
should be held constant. You must supply a starting point, a
funct to calculate the value of
and its first derivatives
at any point
, and a
h to calculate the second derivatives
.
A typical iteration starts at the current point where (say) variables are free from both their bounds. The vector of first derivatives of with respect to the free variables, , and the matrix of second derivatives with respect to the free variables, , are obtained. (These both have dimension .)
The equations
are solved to give a search direction
. (The matrix
is chosen so that
is positive definite.)
is then expanded to an -vector by the insertion of appropriate zero elements; is found such that is approximately a minimum (subject to the fixed bounds) with respect to , and is replaced by . (If a saddle point is found, a special search is carried out so as to move away from the saddle point.)
If any variable actually reaches a bound, it is fixed and is reduced for the next iteration.
There are two sets of convergence criteria – a weaker and a stronger. Whenever the weaker criteria are satisfied, the Lagrange multipliers are estimated for all active constraints. If any Lagrange multiplier estimate is significantly negative, then one of the variables associated with a negative Lagrange multiplier estimate is released from its bound and the next search direction is computed in the extended subspace (i.e., is increased). Otherwise, minimization continues in the current subspace until the stronger criteria are satisfied. If at this point there are no negative or near-zero Lagrange multiplier estimates, the process is terminated.
If you specify that the problem is unconstrained, e04lbf sets the to and the to . Thus, provided that the problem has been sensibly scaled, no bounds will be encountered during the minimization process and e04lbf will act as an unconstrained minimization algorithm.
4
References
Gill P E and Murray W (1973) Safeguarded steplength algorithms for optimization using descent methods NPL Report NAC 37 National Physical Laboratory
Gill P E and Murray W (1974) Newton-type methods for unconstrained and linearly constrained optimization Math. Programming 7 311–350
Gill P E and Murray W (1976) Minimization subject to bounds on the variables NPL Report NAC 72 National Physical Laboratory
5
Arguments
-
1:
– Integer
Input
-
On entry: the number of independent variables.
Constraint:
.
-
2:
– Subroutine, supplied by the user.
External Procedure
-
funct must evaluate the function
and its first derivatives
at any point
.
The specification of
funct is:
Fortran Interface
Integer, Intent (In) |
:: |
n, liw, lw |
Integer, Intent (Inout) |
:: |
iflag, iw(liw) |
Real (Kind=nag_wp), Intent (In) |
:: |
xc(n) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
w(lw) |
Real (Kind=nag_wp), Intent (Out) |
:: |
fc, gc(n) |
|
C Header Interface
void |
funct_ (Integer *iflag, const Integer *n, const double xc[], double *fc, double gc[], Integer iw[], const Integer *liw, double w[], const Integer *lw) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
funct_ (Integer &iflag, const Integer &n, const double xc[], double &fc, double gc[], Integer iw[], const Integer &liw, double w[], const Integer &lw) |
}
|
-
1:
– Integer
Input/Output
-
On entry: will have been set to .
On exit: if it is not possible to evaluate
or its first derivatives at the point
given in
xc (or if it is wished to stop the calculation for any other reason) you should reset
iflag to some negative number and return control to
e04lbf.
e04lbf will then terminate immediately with
ifail set to your setting of
iflag.
-
2:
– Integer
Input
-
On entry: the number of variables.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the point at which and the are required.
-
4:
– Real (Kind=nag_wp)
Output
-
On exit:
funct must set
fc to the value of the objective function
at the current point
.
-
5:
– Real (Kind=nag_wp) array
Output
-
On exit:
funct must set
to the value of the first derivative
at the point
, for
.
-
6:
– Integer array
Workspace
-
7:
– Integer
Input
-
8:
– Real (Kind=nag_wp) array
Workspace
-
9:
– Integer
Input
-
funct is called with the same arguments
iw,
liw,
w and
lw as for
e04lbf. They are present so that, when other library routines require the solution of a minimization subproblem, constants needed for the function evaluation can be passed through
iw and
w. Similarly, you
could use elements
of
iw and elements from
onwards of
w for passing quantities to
funct from the subroutine which calls
e04lbf. However, because of the danger of mistakes in partitioning, it is recommended that you should pass information to
funct via COMMON global variables and not use
iw or
w at all. In any case
funct must not change the first
elements of
iw or the first
elements of
w.
funct must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
e04lbf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: funct should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
e04lbf. If your code inadvertently
does return any NaNs or infinities,
e04lbf is likely to produce unexpected results.
funct should be tested separately before being used in conjunction with
e04lbf.
-
3:
– Subroutine, supplied by the user.
External Procedure
-
h must calculate the second derivatives of
at any point
. (As with
funct, there is the option of causing
e04lbf to terminate immediately.)
The specification of
h is:
Fortran Interface
Integer, Intent (In) |
:: |
n, lh, liw, lw |
Integer, Intent (Inout) |
:: |
iflag, iw(liw) |
Real (Kind=nag_wp), Intent (In) |
:: |
xc(n) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
fhesd(n), w(lw) |
Real (Kind=nag_wp), Intent (Out) |
:: |
fhesl(lh) |
|
C Header Interface
void |
h_ (Integer *iflag, const Integer *n, const double xc[], double fhesl[], const Integer *lh, double fhesd[], Integer iw[], const Integer *liw, double w[], const Integer *lw) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
h_ (Integer &iflag, const Integer &n, const double xc[], double fhesl[], const Integer &lh, double fhesd[], Integer iw[], const Integer &liw, double w[], const Integer &lw) |
}
|
-
1:
– Integer
Input/Output
-
On entry: is set to a non-negative number.
On exit: if
h resets
iflag to some negative number,
e04lbf will terminate immediately with
ifail set to your setting of
iflag.
-
2:
– Integer
Input
-
On entry: the number of variables.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the point at which the second derivatives of are required.
-
4:
– Real (Kind=nag_wp) array
Output
-
On exit:
h must place the strict lower triangle of the second derivative matrix of
(evaluated at the point
) in
fhesl, stored by rows, i.e., set
, for
and
. (The upper triangle is not required because the matrix is symmetric.)
-
5:
– Integer
Input
-
On entry: the length of the array
fhesl.
-
6:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the value of
at the point
, for
.
These values may be useful in the evaluation of the second derivatives.
On exit:
h must place the diagonal elements of the second derivative matrix of
(evaluated at the point
) in
fhesd, i.e., set
,
.
-
7:
– Integer array
Workspace
-
8:
– Integer
Input
-
9:
– Real (Kind=nag_wp) array
Workspace
-
10:
– Integer
Input
-
As in
funct, these arguments correspond to the arguments
iw,
liw,
w,
lw of
e04lbf.
h must not change the first two elements of
iw or the first
elements of
w. Again, it is recommended that you should pass quantities to
h via COMMON global variables and not use
iw or
w at all.
h must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
e04lbf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: h should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
e04lbf. If your code inadvertently
does return any NaNs or infinities,
e04lbf is likely to produce unexpected results.
h should be tested separately before being used in conjunction with
e04lbf.
-
4:
– Subroutine, supplied by the user.
External Procedure
-
If
, you must supply
monit which is suitable for monitoring the minimization process.
monit must not change the values of any of its arguments.
If
, a
monit with the correct argument list should still be supplied, although it will not be called.
The specification of
monit is:
Fortran Interface
Subroutine monit ( |
n, xc, fc, gc, istate, gpjnrm, cond, posdef, niter, nf, iw, liw, w, lw) |
Integer, Intent (In) |
:: |
n, istate(n), niter, nf, liw, lw |
Integer, Intent (Inout) |
:: |
iw(liw) |
Real (Kind=nag_wp), Intent (In) |
:: |
xc(n), fc, gc(n), gpjnrm, cond |
Real (Kind=nag_wp), Intent (Inout) |
:: |
w(lw) |
Logical, Intent (In) |
:: |
posdef |
|
C Header Interface
void |
monit_ (const Integer *n, const double xc[], const double *fc, const double gc[], const Integer istate[], const double *gpjnrm, const double *cond, const logical *posdef, const Integer *niter, const Integer *nf, Integer iw[], const Integer *liw, double w[], const Integer *lw) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
monit_ (const Integer &n, const double xc[], const double &fc, const double gc[], const Integer istate[], const double &gpjnrm, const double &cond, const logical &posdef, const Integer &niter, const Integer &nf, Integer iw[], const Integer &liw, double w[], const Integer &lw) |
}
|
-
1:
– Integer
Input
-
On entry: the number of variables.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: the coordinates of the current point .
-
3:
– Real (Kind=nag_wp)
Input
-
On entry: the value of at the current point .
-
4:
– Real (Kind=nag_wp) array
Input
-
On entry: the value of
at the current point , for .
-
5:
– Integer array
Input
-
On entry: information about which variables are currently fixed on their bounds and which are free.
If
is negative,
is currently:
-
–fixed on its upper bound if ;
-
–fixed on its lower bound if ;
-
–effectively a constant (i.e., ) if .
If
istate is positive, its value gives the position of
in the sequence of free variables.
-
6:
– Real (Kind=nag_wp)
Input
-
On entry: the Euclidean norm of the projected gradient vector .
-
7:
– Real (Kind=nag_wp)
Input
-
On entry: the ratio of the largest to the smallest elements of the diagonal factor
of the projected Hessian matrix (see specification of
h). This quantity is usually a good estimate of the condition number of the projected Hessian matrix. (If no variables are currently free,
cond is set to zero.)
-
8:
– Logical
Input
-
On entry: is set .TRUE. or .FALSE. according to whether the second derivative matrix for the current subspace, , is positive definite or not.
-
9:
– Integer
Input
-
On entry: the number of iterations (as outlined in
Section 3) which have been performed by
e04lbf so far.
-
10:
– Integer
Input
-
On entry: the number of times that
funct has been called so far. Thus
nf is the number of function and gradient evaluations made so far.
-
11:
– Integer array
Workspace
-
12:
– Integer
Input
-
13:
– Real (Kind=nag_wp) array
Workspace
-
14:
– Integer
Input
-
As in
funct, and
h, these arguments correspond to the arguments
iw,
liw,
w,
lw of
e04lbf. They are included in
monit's argument list primarily for when
e04lbf is called by other library routines.
monit must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
e04lbf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: you should normally print out
fc,
gpjnrm and
cond so as to be able to compare the quantities mentioned in
Section 7. It is normally helpful to examine
xc,
posdef and
nf as well.
-
5:
– Integer
Input
-
On entry: the frequency with which
monit is to be called.
- monit is called once every iprint iterations and just before exit from e04lbf.
- monit is just called at the final point.
-
- monit is not called at all.
iprint should normally be set to a small positive number.
Suggested value:
.
-
6:
– Integer
Input
-
On entry: the maximum permitted number of evaluations of
, i.e., the maximum permitted number of calls of
funct.
Suggested value:
.
Constraint:
.
-
7:
– Real (Kind=nag_wp)
Input
-
On entry: every iteration of
e04lbf involves a linear minimization (i.e., minimization of
with respect to
).
eta specifies how accurately these linear minimizations are to be performed. The minimum with respect to
will be located more accurately for small values of
eta (say,
) than for large values (say,
).
Although accurate linear minimizations will generally reduce the number of iterations of e04lbf, this usually results in an increase in the number of function and gradient evaluations required for each iteration. On balance, it is usually more efficient to perform a low accuracy linear minimization.
Suggested value:
is usually a good choice although a smaller value may be warranted if the matrix of second derivatives is expensive to compute compared with the function and first derivatives.
If , eta should be set to (also when the problem is effectively one-dimensional even though
; i.e., if for all except one of the variables the lower and upper bounds are equal).
Constraint:
.
-
8:
– Real (Kind=nag_wp)
Input
-
On entry: the accuracy in
to which the solution is required.
If
is the true value of
at the minimum, then
, the estimated position before a normal exit, is such that
, where
. For example, if the elements of
are not much larger than
in modulus, and if
xtol is set to
, then
is usually accurate to about five decimal places. (For further details see
Section 7.)
If the problem is scaled roughly as described in
Section 9 and
is the
machine precision, then
is probably the smallest reasonable choice for
xtol. (This is because, normally, to machine accuracy,
where
is any column of the identity matrix.)
If you set
xtol to
(or any positive value less than
),
e04lbf will use
instead of
xtol.
Suggested value:
.
Constraint:
.
-
9:
– Real (Kind=nag_wp)
Input
-
On entry: an estimate of the Euclidean distance between the solution and the starting point supplied by you. (For maximum efficiency a slight overestimate is preferable.)
e04lbf will ensure that, for each iteration,
where
is the iteration number. Thus, if the problem has more than one solution,
e04lbf is most likely to find the one nearest to the starting point. On difficult problems, a realistic choice can prevent the sequence of
entering a region where the problem is ill-behaved and can also help to avoid possible overflow in the evaluation of
. However, an underestimate of
stepmx can lead to inefficiency.
Suggested value:
.
Constraint:
.
-
10:
– Integer
Input
-
On entry: specifies whether the problem is unconstrained or bounded. If there are bounds on the variables,
ibound can be used to indicate whether the facility for dealing with bounds of special forms is to be used. It must be set to one of the following values:
- If the variables are bounded and you are supplying all the and individually.
- If the problem is unconstrained.
- If the variables are bounded, but all the bounds are of the form .
- If all the variables are bounded, and and .
- If the problem is unconstrained. (The option is provided purely for consistency with other routines. In e04lbf it produces the same effect as .)
Constraint:
.
-
11:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the fixed lower bounds
.
If
ibound is set to
, you must set
to
, for
. (If a lower bound is not specified for any
, the corresponding
should be set to a large negative number, e.g.,
.)
If
ibound is set to
, you must set
to
;
e04lbf will then set the remaining elements of
bl equal to
.
If
ibound is set to
,
or
,
bl will be initialized by
e04lbf.
On exit: the lower bounds actually used by e04lbf, e.g., if , .
-
12:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the fixed upper bounds
.
If
ibound is set to
, you must set
to
, for
. (If an upper bound is not specified for any variable, the corresponding
should be set to a large positive number, e.g.,
.)
If
ibound is set to
, you must set
to
;
e04lbf will then set the remaining elements of
bu equal to
.
If
ibound is set to
,
or
,
bu will then be initialized by
e04lbf.
On exit: the upper bounds actually used by e04lbf, e.g., if , .
-
13:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: must be set to a guess at the th component of the position of the minimum, for .
On exit: the final point . Thus, if on exit, is the th component of the estimated position of the minimum.
-
14:
– Real (Kind=nag_wp) array
Output
-
On exit: during the determination of a direction
(see
Section 3),
is decomposed into the product
, where
is a unit lower triangular matrix and
is a diagonal matrix. (The matrices
,
,
and
are all of dimension
, where
is the number of variables free from their bounds.
consists of those rows and columns of the full estimated second derivative matrix which relate to free variables.
is chosen so that
is positive definite.)
hesl and
hesd are used to store the factors
and
. The elements of the strict lower triangle of
are stored row by row in the first
positions of
hesl. The diagonal elements of
are stored in the first
positions of
hesd. In the last factorization before a normal exit, the matrix
will be zero, so that
hesl and
hesd will contain, on exit, the factors of the final estimated second derivative matrix
. The elements of
hesd are useful for deciding whether to accept the results produced by
e04lbf (see
Section 7).
-
15:
– Integer
Input
-
On entry: the dimension of the array
hesl as declared in the (sub)program from which
e04lbf is called.
Constraint:
.
-
16:
– Real (Kind=nag_wp) array
Output
-
On exit: during the determination of a direction
(see
Section 3),
is decomposed into the product
, where
is a unit lower triangular matrix and
is a diagonal matrix. (The matrices
,
,
and
are all of dimension
, where
is the number of variables free from their bounds.
consists of those rows and columns of the full second derivative matrix which relate to free variables.
is chosen so that
is positive definite.)
hesl and
hesd are used to store the factors
and
. The elements of the strict lower triangle of
are stored row by row in the first
positions of
hesl. The diagonal elements of
are stored in the first
positions of
hesd.
In the last factorization before a normal exit, the matrix
will be zero, so that
hesl and
hesd will contain, on exit, the factors of the final second derivative matrix
. The elements of
hesd are useful for deciding whether to accept the result produced by
e04lbf (see
Section 7).
-
17:
– Integer array
Output
-
On exit: information about which variables are currently on their bounds and which are free. If
is:
-
–equal to , is fixed on its upper bound;
-
–equal to , is fixed on its lower bound;
-
–equal to , is effectively a constant (i.e., );
-
–positive, gives the position of in the sequence of free variables.
-
18:
– Real (Kind=nag_wp)
Output
-
On exit: the function value at the final point given in
x.
-
19:
– Real (Kind=nag_wp) array
Output
-
On exit: the first derivative vector corresponding to the final point given in
x. The components of
g corresponding to free variables should normally be close to zero.
-
20:
– Integer array
Workspace
-
21:
– Integer
Input
-
On entry: the dimension of the array
iw as declared in the (sub)program from which
e04lbf is called.
Constraint:
.
-
22:
– Real (Kind=nag_wp) array
Workspace
-
23:
– Integer
Input
-
On entry: the dimension of the array
w as declared in the (sub)program from which
e04lbf is called.
Constraint:
.
-
24:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if
on exit, the recommended value is
.
When the value 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).
6
Error 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 e04lbf may return useful information.
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and for some .
On entry, and .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
-
There have been
maxcal function evaluations.
If steady reductions in
were monitored up to the point where this exit occurred, then the exit probably occurred simply because
maxcal was set too small, so the calculations should be restarted from the final point held in
x. This exit may also indicate that
has no minimum.
-
The conditions for a minimum have not all been satisfied, but a lower point could not be found. See
Section 7 for further information.
Provided that, on exit, the first derivatives of
with respect to the free variables are sufficiently small, and that the estimated condition number of the second derivative matrix is not too large, this error exit may simply mean that, although it has not been possible to satisfy the specified requirements, the algorithm has in fact found the minimum as far as the accuracy of the machine permits. Such a situation can arise, for instance, if
xtol has been set so small that rounding errors in the evaluation of
or its derivatives make it impossible to satisfy the convergence conditions.
If the estimated condition number of the second derivative matrix at the final point is large, it could be that the final point is a minimum, but that the smallest eigenvalue of the Hessian matrix is so close to zero that it is not possible to recognize the point as a minimum.
-
No further progress can be made.
All the Lagrange multiplier estimates which are not indisputably positive lie relatively close to zero, but it is impossible either to continue minimizing on the current subspace or to find a feasible lower point by releasing and perturbing any of the fixed variables. You should investigate as for .
-
User requested termination by setting
iflag negative in
funct or
h.
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.
The values
,
or
may also be caused by mistakes in user-supplied subroutines
funct or
h, by the formulation of the problem or by an awkward function. If there are no such mistakes, it is worth restarting the calculations from a different starting point (not the point at which the failure occurred) in order to avoid the region which caused the failure.
7
Accuracy
A successful exit (
) is made from
e04lbf when
is positive definite and when (B1, B2 and B3) or B4 hold, where
(Quantities with superscript
are the values at the
th iteration of the quantities mentioned in
Section 3.
is the
machine precision and
denotes the Euclidean norm.)
If
, then the vector in
x on exit,
, is almost certainly an estimate of the position of the minimum,
, to the accuracy specified by
xtol.
If
or
,
may still be a good estimate of
, but the following checks should be made. Let the largest of the first
elements of
hesd be
, let the smallest be
, and define
. The scalar
is usually a good estimate of the condition number of the projected Hessian matrix at
. If
-
(i)the sequence converges to at a superlinear or fast linear rate,
-
(ii), and
-
(iii),
then it is almost certain that
is a close approximation to the position of a minimum. When (ii) is true, then usually
is a close approximation to
. The quantities needed for these checks are all available via
monit; in particular the value of
cond in the last call of
monit before exit gives
.
Further suggestions about confirmation of a computed solution are given in the
E04 Chapter Introduction.
8
Parallelism and Performance
e04lbf 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.
The number of iterations required depends on the number of variables, the behaviour of
, the accuracy demanded and the distance of the starting point from the solution. The number of multiplications performed in an iteration of
e04lbf is
. In addition, each iteration makes one call of
h and at least one call of
funct. So, unless
and its derivatives can be evaluated very quickly, the run time will be dominated by the time spent in
funct and
h.
Ideally, the problem should be scaled so that, at the solution, and the corresponding values of the are each in the range , and so that at points one unit away from the solution, differs from its value at the solution by approximately one unit. This will usually imply that the Hessian matrix at the solution is well-conditioned. It is unlikely that you will be able to follow these recommendations very closely, but it is worth trying (by guesswork), as sensible scaling will reduce the difficulty of the minimization problem, so that e04lbf will take less computer time.
If a problem is genuinely unconstrained and has been scaled sensibly, the following points apply:
-
(a) will always be ,
-
(b)hesl and hesd will be factors of the full second derivative matrix with elements stored in the natural order,
-
(c)the elements of should all be close to zero at the final point,
-
(d)the values of the given by monit and on exit from e04lbf are unlikely to be of interest (unless they are negative, which would indicate that the modulus of one of the has reached for some reason),
-
(e)monit's argument gpjnrm simply gives the norm of the first derivative vector.
So the following routine (in which partitions of extended workspace arrays are used as
bl,
bu and
istate) could be used for unconstrained problems:
Subroutine unclbf(n,funct,h,monit,iprint,maxcal,eta,xtol, &
stepmx,x,hesl,lh,hesd,f,g,iwork,liwork,work, &
lwork,ifail)
! A ROUTINE TO APPLY E04LBF TO UNCONSTRAINED PROBLEMS.
! THE REAL ARRAY WORK MUST BE OF DIMENSION AT LEAST
! (9*N + max(1, N*(N-1)/2)). ITS FIRST 7*N + max(1, N*(N-1)/2)
! ELEMENTS WILL BE USED BY E04LBF AS THE ARRAY W. ITS LAST
! 2*N ELEMENTS WILL BE USED AS THE ARRAYS BL AND BU.
! THE INTEGER ARRAY IWORK MUST BE OF DIMENSION AT LEAST (N+2)
! ITS FIRST 2 ELEMENTS WILL BE USED BY E04LBF AS THE ARRAY IW.
! ITS LAST N ELEMENTS WILL BE USED AS THE ARRAY ISTATE.
! LIWORK AND LWORK MUST BE SET TO THE ACTUAL LENGTHS OF IWORK
! AND WORK RESPECTIVELY, AS DECLARED IN THE CALLING SEGMENT.
! OTHER PARAMETERS ARE AS FOR E04LBF.
! .. Parameters ..
Integer nout
Parameter (nout=6)
! .. Scalar Arguments ..
Real (Kind=nag_wp) eta, f, stepmx, xtol
Integer ifail, iprint, lh, liwork, lwork, maxcal, n
! .. Array Arguments ..
Real (Kind=nag_wp) g(n), hesd(n), hesl(lh), work(lwork), x(n)
Integer iwork(liwork)
! .. Subroutine Arguments ..
External funct, h, monit
! .. Local Scalars ..
Integer ibound, j, jbl, jbu, nh
Logical toobig
! .. External Subroutines ..
External e04lbf
! .. Executable Statements ..
! CHECK THAT SUFFICIENT WORKSPACE HAS BEEN SUPPLIED
nh = n*(n-1)/2
If (nh.eq.0) nh = 1
If (lwork.lt.9*n+nh .or. liwork.lt.n+2) Then
Write (nout,fmt=99999)
Stop
End If
! JBL AND JBU SPECIFY THE PARTS OF WORK USED AS BL AND BU
jbl = 7*n + nh + 1
jbu = jbl + n
! SPECIFY THAT THE PROBLEM IS UNCONSTRAINED
ibound = 4
Call e04lbf(n,funct,h,monit,iprint,maxcal,eta,xtol,stepmx, &
ibound,work(jbl),work(jbu),x,hesl,lh,hesd,iwork(3), &
f,g,iwork,liwork,work,lwork,ifail)
! CHECK THE PART OF IWORK WHICH WAS USED AS ISTATE IN CASE
! THE MODULUS OF SOME X(J) HAS REACHED E+6
toobig = .false.
Do 20 j = 1, n
If (iwork(2+j).lt.0) toobig = .true.
20 Continue
If ( .not. toobig) Return
Write (nout,fmt=99998)
Stop
99999 Format (' ***** INSUFFICIENT WORKSPACE HAS BEEN SUPPLIED *****')
99998 Format (' ***** A VARIABLE HAS REACHED E+6 IN MODULUS - NO UNCON', &
'STRAINED MINIMUM HAS BEEN FOUND *****')
End
10
Example
A program to minimize
subject to the bounds
starting from the initial guess
. Before calling
e04lbf, the program calls
e04hcf and
e04hdf to check the derivatives calculated by user-supplied subroutines
funct and
h.
10.1
Program Text
10.2
Program Data
None.
10.3
Program Results