e04lb 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.
Syntax
C# |
---|
public static void e04lb( int n, E04..::..E04LB_FUNCT funct, E04..::..E04LB_H h, E04..::..E04LB_MONIT monit, int iprint, int maxcal, double eta, double xtol, double stepmx, int ibound, double[] bl, double[] bu, double[] x, double[] hesl, double[] hesd, int[] istate, out double f, double[] g, out int ifail ) |
Visual Basic |
---|
Public Shared Sub e04lb ( _ n As Integer, _ funct As E04..::..E04LB_FUNCT, _ h As E04..::..E04LB_H, _ monit As E04..::..E04LB_MONIT, _ iprint As Integer, _ maxcal As Integer, _ eta As Double, _ xtol As Double, _ stepmx As Double, _ ibound As Integer, _ bl As Double(), _ bu As Double(), _ x As Double(), _ hesl As Double(), _ hesd As Double(), _ istate As Integer(), _ <OutAttribute> ByRef f As Double, _ g As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void e04lb( int n, E04..::..E04LB_FUNCT^ funct, E04..::..E04LB_H^ h, E04..::..E04LB_MONIT^ monit, int iprint, int maxcal, double eta, double xtol, double stepmx, int ibound, array<double>^ bl, array<double>^ bu, array<double>^ x, array<double>^ hesl, array<double>^ hesd, array<int>^ istate, [OutAttribute] double% f, array<double>^ g, [OutAttribute] int% ifail ) |
F# |
---|
static member e04lb : n : int * funct : E04..::..E04LB_FUNCT * h : E04..::..E04LB_H * monit : E04..::..E04LB_MONIT * iprint : int * maxcal : int * eta : float * xtol : float * stepmx : float * ibound : int * bl : float[] * bu : float[] * x : float[] * hesl : float[] * hesd : float[] * istate : int[] * f : float byref * g : float[] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: the number of independent variables.Constraint: .
- funct
- Type: NagLibrary..::..E04..::..E04LB_FUNCTfunct must evaluate the function and its first derivatives at any point . (However, if you do not wish to calculate or its first derivatives at a particular , there is the option of setting a parameter to cause e04lb to terminate immediately.)
A delegate of type E04LB_FUNCT.
- h
- Type: NagLibrary..::..E04..::..E04LB_Hh must calculate the second derivatives of at any point . (As with funct, there is the option of causing e04lb to terminate immediately.)
A delegate of type E04LB_H.
- monit
- Type: NagLibrary..::..E04..::..E04LB_MONITIf , you must supply monit which is suitable for monitoring the minimization process. monit must not change the values of any of its parameters.If , a monit with the correct parameter list should still be supplied, although it will not be called.
A delegate of type E04LB_MONIT.
- iprint
- Type: System..::..Int32On entry: the frequency with which monit is to be called.
- monit is called once every iprint iterations and just before exit from e04lb.
- 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: .
- maxcal
- Type: System..::..Int32On entry: the maximum permitted number of evaluations of , i.e., the maximum permitted number of calls of funct.Suggested value: .Constraint: .
- eta
- Type: System..::..DoubleOn entry: every iteration of e04lb 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 e04lb, 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: .
- xtol
- Type: System..::..DoubleOn 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 [Accuracy].)If the problem is scaled roughly as described in [Further Comments] 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.)Suggested value: .Constraint: .
- stepmx
- Type: System..::..DoubleOn 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.)e04lb will ensure that, for each iteration,where is the iteration number. Thus, if the problem has more than one solution, e04lb 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: .
- ibound
- Type: System..::..Int32On 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 methods. In e04lb it produces the same effect as .)
Constraint: .
- bl
- Type: array<System..::..Double>[]()[][]An array of size [n]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., .)On exit: the lower bounds actually used by e04lb, e.g., if , .
- bu
- Type: array<System..::..Double>[]()[][]An array of size [n]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., .)On exit: the upper bounds actually used by e04lb, e.g., if , .
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]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.
- hesl
- Type: array<System..::..Double>[]()[][]An array of size [lh]On exit: during the determination of a direction (see [Description]), 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 e04lb (see [Accuracy]).
- hesd
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: during the determination of a direction (see [Description]), 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 e04lb (see [Accuracy]).
- istate
- Type: array<System..::..Int32>[]()[][]An array of size [n]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.
- f
- Type: System..::..Double%On exit: the function value at the final point given in x.
- g
- Type: array<System..::..Double>[]()[][]An array of size [n]
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
e04lb 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.
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
Error Indicators and Warnings
Note: e04lb may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(IW, LIW, W, LW) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , or , or , or , or , or , or , or , or for some if , or if , or ,
- 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 met, but a lower point could not be found.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.
- 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 .
The values , or may also be caused by mistakes in user-supplied delegates 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.
Accuracy
A successful exit () is made from e04lb 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 [Description]. 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
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 .
(i) | the sequence converges to at a superlinear or fast linear rate, |
(ii) | , and |
(iii) | , |
Further suggestions about confirmation of a computed solution are given in the E04 class.
Parallelism and Performance
None.
Further Comments
Timing
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 e04lb 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.
Scaling
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 e04lb will take less computer time.
Unconstrained Minimization
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 e04lb 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 parameter gpjnrm simply gives the norm of the first derivative vector. |