NAG Library Chapter Introduction
E04 – Minimizing or Maximizing a Function
1 Scope of the Chapter
An optimization problem involves minimizing a function (called the
objective function) of several variables, possibly subject to
restrictions on the values of the variables defined by a set of
constraint functions. Most routines in the Library are
concerned with function minimization only, since the problem of
maximizing a given objective function F(x) is equivalent to
minimizing
.
Some routines allow you to specify whether you are solving a minimization or
maximization problem, carrying out the required transformation of the objective
function in the latter case.
In general routines in this chapter find a local minimum of a function , that is a point s.t. for all near .
The
Chapter E05 contains routines to find the global minimum of a function
. At a global minimum
for all
.
The
Chapter H contains routines typically regarded as belonging to the field of operations research.
This introduction is only a brief guide to the subject of optimization designed for the casual user. Anyone with a difficult or protracted problem to solve will find it beneficial to consult a more detailed text, such as
Gill et al. (1981) or
Fletcher (1987).
If you are unfamiliar with the mathematics of the subject you may find some sections difficult at first reading; if so, you should
concentrate on
Sections 2.1,
2.2,
2.5,
2.6 and
3.
2 Background to the Problems
2.1 Types of Optimization Problems
The solution of optimization problems by a single, all-purpose, method is cumbersome and inefficient. Optimization problems are therefore classified into particular categories, where each category is defined by the properties of the objective and constraint functions, as illustrated by some examples below.
Properties of Objective Function |
Properties of Constraints |
Nonlinear |
Nonlinear |
Sums of squares of nonlinear functions |
Sparse linear |
Quadratic |
Linear |
Sums of squares of linear functions |
Bounds |
Linear |
None |
For instance, a specific problem category involves the minimization of a nonlinear objective function subject to bounds on the variables. In the following sections we define the particular categories of problems that can be solved by routines contained in this chapter. Not every category is given special treatment in the current version of the Library; however, the long-term objective is to provide a comprehensive set of routines to solve problems in all such categories.
2.1.1 Unconstrained minimization
In unconstrained minimization problems there are no constraints on the variables. The problem can be stated mathematically as follows:
where
, that is,
.
2.1.2 Nonlinear least squares problems
Special consideration is given to the problem for which the function to be minimized can be expressed as a sum of squared functions. The least squares problem can be stated mathematically as follows:
where the
th element of the
-vector
is the function
.
2.1.3 Minimization subject to bounds on the variables
These problems differ from the unconstrained problem in that at least one of the variables is subject to a simple bound (or restriction) on its value, e.g., , but no constraints of a more general form are present.
The problem can be stated mathematically as follows:
subject to
, for
.
This format assumes that upper and lower bounds exist on all the variables. By conceptually allowing and all the variables need not be restricted.
2.1.4 Minimization subject to linear constraints
A general linear constraint is defined as a constraint function that is linear in more than one of the variables, e.g.,
. The various types of linear constraint are reflected in the following mathematical statement of the problem:
subject to the
equality constraints: |
|
; |
inequality constraints: |
|
; |
|
|
; |
range constraints: |
|
|
|
|
|
bounds constraints: |
|
|
where each
is a vector of length
;
,
and
are constant scalars; and any of the categories may be empty.
Although the bounds on could be included in the definition of general linear constraints, we prefer to distinguish between them for reasons of computational efficiency.
If
is a linear function, the linearly-constrained problem is termed a linear programming problem (LP); if
is a quadratic function, the problem is termed a quadratic programming problem (QP). For further discussion of LP and QP problems, including the dual formulation of such problems, see
Dantzig (1963).
2.1.5 Minimization subject to nonlinear constraints
A problem is included in this category if at least one constraint function is nonlinear, e.g.,
. The mathematical statement of the problem is identical to that for the linearly-constrained case, except for the addition of the following constraints:
equality constraints: |
|
; |
inequality constraints: |
|
; |
range constraints: |
|
, |
|
|
|
where each
is a nonlinear function;
and
are constant scalars; and any category may be empty. Note that we do not include a separate category for constraints of the form
, since this is equivalent to
.
Although the general linear constraints could be included in the definition of nonlinear constraints, again we prefer to distinguish between them for reasons of computational efficiency.
If
is a nonlinear function, the nonlinearly-constrained problem is termed a nonlinear programming problem (NLP). For further discussion of NLP problems, see
Gill et al. (1981) or
Fletcher (1987).
2.1.6 Minimization subject to bounds on the objective function
In all of the above problem categories it is assumed that
where
and
. Problems in which
and/or
are finite can be solved by adding an extra constraint of the appropriate type (i.e., linear or nonlinear) depending on the form of
. Further advice is given in
Section 3.5.
2.1.7 Multi-objective optimization
Sometimes a problem may have two or more objective functions which are to be optimized at the same time. Such problems are called multi-object, multi-criteria or multi-attribute optimization. If the constraints are linear and the objectives are all linear then the terminology ‘goal programming’ is also used.
Techniques used in this chapter and in
Chapter E05 may be employed to address such problems.
2.2 Geometric Representation and Terminology
To illustrate the nature of optimization problems it is useful to consider the following example in two dimensions:
(This function is used as the example function in the documentation for the unconstrained routines.)
Figure 1
Figure 1 is a contour diagram of
. The contours labelled
are isovalue contours, or lines along which the function
takes specific constant values. The point
is a
local unconstrained minimum, that is, the value of
(
) is less than at all the neighbouring points. A function may have several such minima. The lowest of the local minima is termed a
global minimum. In the problem illustrated in
Figure 1,
is the only local minimum. The point
is said to be a
saddle point because it is a minimum along the line AB, but a maximum along CD.
If we add the constraint
(a simple bound) to the problem of minimizing
, the solution remains unaltered. In
Figure 1 this constraint is represented by the straight line passing through
, and the shading on the line indicates the unacceptable region (i.e.,
). The region in
satisfying the constraints of an optimization problem is termed the
feasible region. A point satisfying the constraints is defined as a
feasible point.
If we add the nonlinear constraint
, represented by the curved shaded line in
Figure 1, then
is not a feasible point because
. The solution of the new constrained problem is
, the feasible point with the smallest function value (where
).
2.2.1 Gradient vector
The vector of first partial derivatives of
is called the
gradient vector, and is denoted by
, i.e.,
For the function illustrated in
Figure 1,
The gradient vector is of importance in optimization because it must be zero at an unconstrained minimum of any function with continuous first derivatives.
2.2.2 Hessian matrix
The matrix of second partial derivatives of a function is termed its Hessian matrix. The Hessian matrix of is denoted by , and its th element is given by . If has continuous second derivatives, then must be positive definite at any unconstrained minimum of .
2.2.3 Jacobian matrix; matrix of constraint normals
In nonlinear least squares problems, the matrix of first partial derivatives of the vector-valued function is termed the Jacobian matrix of and its th component is .
The vector of first partial derivatives of the constraint
is denoted by
The matrix whose columns are the vectors
is termed the
matrix of constraint normals. At a point
, the vector
is orthogonal (normal) to the isovalue contour of
passing through
; this relationship is illustrated for a two-dimensional function in
Figure 2.
Figure 2
Note that if is a linear constraint involving , then its vector of first partial derivatives is simply the vector .
2.3 Sufficient Conditions for a Solution
All nonlinear functions will be assumed to have continuous second derivatives in the neighbourhood of the solution.
2.3.1 Unconstrained minimization
The following conditions are sufficient for the point
to be an unconstrained local minimum of
:
(i) |
; and |
(ii) |
is positive definite, |
where
denotes the Euclidean length of
.
2.3.2 Minimization subject to bounds on the variables
At the solution of a bounds-constrained problem, variables which are not on their bounds are termed free variables. If it is known in advance which variables are on their bounds at the solution, the problem can be solved as an unconstrained problem in just the free variables; thus, the sufficient conditions for a solution are similar to those for the unconstrained case, applied only to the free variables.
Sufficient conditions for a feasible point
to be the solution of a bounds-constrained problem are as follows:
(i) |
; and |
(ii) |
is positive definite; and |
(iii) |
; , |
where
is the gradient of
with respect to the free variables, and
is the Hessian matrix of
with respect to the free variables. The extra condition (iii) ensures that
cannot be reduced by moving off one or more of the bounds.
2.3.3 Linearly-constrained minimization
For the sake of simplicity, the following description does not include a specific treatment of bounds or range constraints, since the results for general linear inequality constraints can be applied directly to these cases.
At a solution
, of a linearly-constrained problem, the constraints which hold as equalities are called the
active or
binding constraints. Assume that there are
active constraints at the solution
, and let
denote the matrix whose columns are the columns of
corresponding to the active constraints, with
the vector similarly obtained from
; then
The matrix
is defined as an
matrix satisfying:
The columns of
form an orthogonal basis for the set of vectors orthogonal to the columns of
.
Define
- , the projected gradient vector of ;
- , the projected Hessian matrix of .
At the solution of a linearly-constrained problem, the projected gradient vector must be zero, which implies that the gradient vector
can be written as a linear combination of the columns of
, i.e.,
. The scalar
is defined as the
Lagrange multiplier corresponding to the
th active constraint. A simple interpretation of the
th Lagrange multiplier is that it gives the gradient of
along the
th active constraint normal; a convenient definition of the Lagrange multiplier vector (although not a recommended method for computation) is:
Sufficient conditions for
to be the solution of a linearly-constrained problem are:
(i) |
is feasible, and ; and |
(ii) |
, or equivalently, ; and |
(iii) |
is positive definite; and |
(iv) |
if corresponds to a constraint ;
if corresponds to a constraint .
The sign of is immaterial for equality constraints, which by definition are always active. |
2.3.4 Nonlinearly-constrained minimization
For nonlinearly-constrained problems, much of the terminology is defined exactly as in the linearly-constrained case. The set of active constraints at
again means the set of constraints that hold as equalities at
, with corresponding definitions of
and
: the vector
contains the active constraint functions, and the columns of
are the gradient vectors of the active constraints. As before,
is defined in terms of
as a matrix such that:
where the dependence on
has been suppressed for compactness.
The projected gradient vector is the vector . At the solution of a nonlinearly-constrained problem, the projected gradient must be zero, which implies the existence of Lagrange multipliers corresponding to the active constraints, i.e., .
The
Lagrangian function is given by:
We define
as the gradient of the Lagrangian function;
as its Hessian matrix, and
as its projected Hessian matrix, i.e.,
.
Sufficient conditions for
to be the solution of a nonlinearly-constrained problem are:
(i) |
is feasible, and ; and |
(ii) |
, or, equivalently, ; and |
(iii) |
is positive definite; and |
(iv) |
if corresponds to a constraint of the form .
The sign of is immaterial for equality constraints, which by definition are always active. |
Note that condition (ii) implies that the projected gradient of the Lagrangian function must also be zero at , since the application of annihilates the matrix .
2.4 Background to Optimization Methods
All the algorithms contained in this chapter generate an iterative sequence
that converges to the solution
in the limit, except for some special problem categories (i.e., linear and quadratic programming). To terminate computation of the sequence, a convergence test is performed to determine whether the current estimate of the solution is an adequate approximation. The convergence tests are discussed in
Section 2.6.
Most of the methods construct a sequence
satisfying:
where the vector
is termed the
direction of search, and
is the
steplength. The steplength
is chosen so that
and is computed using one of the techniques for one-dimensional optimization referred to in
Section 2.4.1.
2.4.1 One-dimensional optimization
The Library contains two special routines for minimizing a function of a single variable. Both routines are based on safeguarded polynomial approximation. One routine requires function evaluations only and fits a quadratic polynomial whilst the other requires function and gradient evaluations and fits a cubic polynomial. See Section 4.1 of
Gill et al. (1981).
2.4.2 Methods for unconstrained optimization
The distinctions among methods arise primarily from the need to use varying levels of information about derivatives of
in defining the search direction. We describe three basic approaches to unconstrained problems, which may be extended to other problem categories. Since a full description of the methods would fill several volumes, the discussion here can do little more than allude to the processes involved, and direct you to other sources for a full explanation.
(a) |
Newton-type Methods (Modified Newton Methods)
Newton-type methods use the Hessian matrix , or a finite difference approximation to , to define the search direction. The routines in the Library either require a subroutine that computes the elements of directly, or they approximate by finite differences.
Newton-type methods are the most powerful methods available for general problems and will find the minimum of a quadratic function in one iteration. See Sections 4.4 and 4.5.1 of Gill et al. (1981). |
(b) |
Quasi-Newton Methods
Quasi-Newton methods approximate the Hessian by a matrix which is modified at each iteration to include information obtained about the curvature of along the current search direction . Although not as robust as Newton-type methods, quasi-Newton methods can be more efficient because is not computed directly, or approximated by finite differences. Quasi-Newton methods minimize a quadratic function in iterations, where is the number of variables. See Section 4.5.2 of Gill et al. (1981). |
(c) |
Conjugate-gradient Methods
Unlike Newton-type and quasi-Newton methods, conjugate-gradient methods do not require the storage of an by matrix and so are ideally suited to solve large problems. Conjugate-gradient type methods are not usually as reliable or efficient as Newton-type, or quasi-Newton methods. See Section 4.8.3 of Gill et al. (1981). |
2.4.3 Methods for nonlinear least squares problems
These methods are similar to those for unconstrained optimization, but exploit the special structure of the Hessian matrix to give improved computational efficiency.
Since
the Hessian matrix
is of the form
where
is the Jacobian matrix of
, and
is the Hessian matrix of
.
In the neighbourhood of the solution,
is often small compared to
(for example, when
represents the goodness-of-fit of a nonlinear model to observed data). In such cases,
may be an adequate approximation to
, thereby avoiding the need to compute or approximate second derivatives of
. See Section 4.7 of
Gill et al. (1981).
2.4.4 Methods for handling constraints
Bounds on the variables are dealt with by fixing some of the variables on their bounds and adjusting the remaining free variables to minimize the function. By examining estimates of the Lagrange multipliers it is possible to adjust the set of variables fixed on their bounds so that eventually the bounds active at the solution should be correctly identified. This type of method is called an active set method. One feature of such methods is that, given an initial feasible point, all approximations are feasible. This approach can be extended to general linear constraints. At a point, , the set of constraints which hold as equalities being used to predict, or approximate, the set of active constraints is called the working set.
Nonlinear constraints are more difficult to handle. If at all possible, it is usually beneficial to avoid including nonlinear constraints during the formulation of the problem. The methods currently implemented in the Library handle nonlinearly constrained problems by transforming them into a sequence of quadratic programming problems. A feature of such methods is that
is not guaranteed to be feasible except in the limit, and this is certainly true of the routines currently in the Library. See Chapter 6, particularly Sections 6.4 and 6.5, of
Gill et al. (1981).
Anyone interested in a detailed description of methods for optimization should consult the references.
2.4.5 Methods for handling multi-objective optimization
Suppose we have objective functions
,
, all of which we need to minimize at the same time. There are two main approaches to this problem:
(a) |
Combine the individual objectives into one composite objective. Typically this might be a weighted sum of the objectives, e.g.,
Here you choose the weights to express the relative importance of the corresponding objective. Ideally each of the should be of comparable size at a solution. |
(b) |
Order the objectives in order of importance. Suppose are ordered such that is more important than , for . Then in the lexicographical approach to multi-objective optimization a sequence of subproblems are solved. Firstly solve the problem for objective function and denote by the value of this minimum. If subproblems have been solved with results then subproblem becomes subject to , for plus the other constraints. |
Clearly the bounds on might be relaxed at your discretion.
In general, if NAG routines from the
Chapter E04 are used then only local minima are found. This means that a better solution to an individual objective might be found without worsening the optimal solutions to the other objectives. Ideally you seek a Pareto solution; one in which an improvement in one objective can only be achieved by a worsening of another objective.
To obtain a Pareto solution routines from
Chapter E05 might be used or, alternatively, a pragmatic attempt to derive a global minimum might be tried (see
E05UCF). In this approach a variety of different minima are computed for each subproblem by starting from a range of different starting points. The best solution achieved is taken to be the global minimum. The more starting points chosen the greater confidence you might have in the computed global minimum.
2.5 Scaling
Scaling (in a broadly defined sense) often has a significant influence on the performance of optimization methods. Since convergence tolerances and other criteria are necessarily based on an implicit definition of ‘small’ and ‘large’, problems with unusual or unbalanced scaling may cause difficulties for some algorithms. Although there are currently no user-callable scaling routines in the Library, scaling is automatically performed by default in the routines which solve sparse LP, QP or NLP problems and in some newer dense solver routines. The following sections present some general comments on problem scaling.
2.5.1 Transformation of variables
One method of scaling is to transform the variables from their original representation, which may reflect the physical nature of the problem, to variables that have certain desirable properties in terms of optimization. It is generally helpful for the following conditions to be satisfied:
(i) |
the variables are all of similar magnitude in the region of interest; |
(ii) |
a fixed change in any of the variables results in similar changes in . Ideally, a unit change in any variable produces a unit change in ; |
(iii) |
the variables are transformed so as to avoid cancellation error in the evaluation of . |
Normally, you should restrict yourself to linear transformations of variables, although occasionally nonlinear transformations are possible. The most common such transformation (and often the most appropriate) is of the form
where
is a diagonal matrix with constant coefficients. Our experience suggests that more use should be made of the transformation
where
is a constant vector.
Consider, for example, a problem in which the variable
represents the position of the peak of a Gaussian curve to be fitted to data for which the extreme values are
and
; therefore
is known to lie in the range
–
. One possible scaling would be to define a new variable
, given by
A better transformation, however, is given by defining
as
Frequently, an improvement in the accuracy of evaluation of
can result if the variables are scaled before the routines to evaluate
are coded. For instance, in the above problem just mentioned of Gaussian curve-fitting,
may always occur in terms of the form
, where
is a constant representing the mean peak position.
2.5.2 Scaling the objective function
The objective function has already been mentioned in the discussion of scaling the variables. The solution of a given problem is unaltered if is multiplied by a positive constant, or if a constant value is added to . It is generally preferable for the objective function to be of the order of unity in the region of interest; thus, if in the original formulation is always of the order of (say), then the value of should be multiplied by when evaluating the function within an optimization routine. If a constant is added or subtracted in the computation of , usually it should be omitted, i.e., it is better to formulate as rather than as or even . The inclusion of such a constant in the calculation of can result in a loss of significant figures.
2.5.3 Scaling the constraints
A ‘well scaled’ set of constraints has two main properties. Firstly, each constraint should be well-conditioned with respect to perturbations of the variables. Secondly, the constraints should be balanced with respect to each other, i.e., all the constraints should have ‘equal weight’ in the solution process.
The solution of a linearly- or nonlinearly-constrained problem is unaltered if the th constraint is multiplied by a positive weight . At the approximation of the solution determined by a Library routine, any active linear constraints will (in general) be satisfied ‘exactly’ (i.e., to within the tolerance defined by machine precision) if they have been properly scaled. This is in contrast to any active nonlinear constraints, which will not (in general) be satisfied ‘exactly’ but will have ‘small’ values (for example, , , and so on). In general, this discrepancy will be minimized if the constraints are weighted so that a unit change in produces a similar change in each constraint.
A second reason for introducing weights is related to the effect of the size of the constraints on the Lagrange multiplier estimates and, consequently, on the active set strategy. This means that different sets of weights may cause an algorithm to produce different sequences of iterates. Additional discussion is given in
Gill et al. (1981).
2.6 Analysis of Computed Results
2.6.1 Convergence criteria
The convergence criteria inevitably vary from routine to routine, since in some cases more information is available to be checked (for example, is the Hessian matrix positive definite?), and different checks need to be made for different problem categories (for example, in constrained minimization it is necessary to verify whether a trial solution is feasible). Nonetheless, the underlying principles of the various criteria are the same; in non-mathematical terms, they are:
(i) |
is the sequence converging? |
(ii) |
is the sequence converging? |
(iii) |
are the necessary and sufficient conditions for the solution satisfied? |
The decision as to whether a sequence is converging is necessarily speculative. The criterion used in the present routines is to assume convergence if the relative change occurring between two successive iterations is less than some prescribed quantity. Criterion (iii) is the most reliable but often the conditions cannot be checked fully because not all the required information may be available.
2.6.2 Checking results
Little a priori guidance can be given as to the quality of the solution found by a nonlinear optimization algorithm, since no guarantees can be given that the methods will not fail. Therefore, you should always check the computed solution even if the routine reports success. Frequently a ‘solution’ may have been found even when the routine does not report a success. The reason for this apparent contradiction is that the routine needs to assess the accuracy of the solution. This assessment is not an exact process and consequently may be unduly pessimistic. Any ‘solution’ is in general only an approximation to the exact solution, and it is possible that the accuracy you have specified is too stringent.
Further confirmation can be sought by trying to check whether or not convergence tests are almost satisfied, or whether or not some of the sufficient conditions are nearly satisfied. When it is thought that a routine has returned a
nonzero value of IFAIL
only because the requirements for ‘success’ were too stringent it may be worth restarting with increased convergence tolerances.
For nonlinearly-constrained problems, check whether the solution returned is feasible, or nearly feasible; if not, the solution returned is not an adequate solution.
Confidence in a solution may be increased by resolving the problem with a different initial approximation to the solution. See Section 8.3 of
Gill et al. (1981) for further information.
2.6.3 Monitoring progress
Many of the routines in the chapter have facilities to allow you to monitor the progress of the minimization process, and you are encouraged to make use of these facilities. Monitoring information can be a great aid in assessing whether or not a satisfactory solution has been obtained, and in indicating difficulties in the minimization problem or in the ability of the routine to cope with the problem.
The behaviour of the function, the estimated solution and first derivatives can help in deciding whether a solution is acceptable and what to do in the event of a return with a
nonzero value of IFAIL.
2.6.4 Confidence intervals for least squares solutions
When estimates of the parameters in a nonlinear least squares problem have been found, it may be necessary to estimate the variances of the parameters and the fitted function. These can be calculated from the Hessian of at the solution.
In many least squares problems, the Hessian is adequately approximated at the solution by
(see
Section 2.4.3). The Jacobian,
, or a factorization of
is returned by all the comprehensive least squares routines and, in addition, a routine is available in the Library to estimate variances of the parameters following the use of most of the nonlinear least squares routines, in the case that
is an adequate approximation.
Let
be the inverse of
, and
be the sum of squares, both calculated at the solution
; an unbiased estimate of the
variance of the
th parameter
is
and an unbiased estimate of the covariance of
and
is
If
is the true solution, then the
confidence interval on
is
where
is the
percentage point of the
-distribution with
degrees of freedom.
In the majority of problems, the residuals
, for
, contain the difference between the values of a model function
calculated for
different values of the independent variable
, and the corresponding observed values at these points. The minimization process determines the parameters, or constants
, of the fitted function
. For any value,
, of the independent variable
, an unbiased estimate of the
variance of
is
The
confidence interval on
at the point
is
For further details on the analysis of least squares solutions see
Bard (1974) and
Wolberg (1967).
3 Recommendations on Choice and Use of Available Routines
The choice of routine depends on several factors: the type of problem (unconstrained, etc.); the level of derivative information available (function values only, etc.); your experience (there are easy-to-use versions of some routines); whether or not storage is a problem; whether or not the routine is to be used in a multithreaded environment; and whether computational time has a high priority. Not all choices are catered for in the current version of the Library.
3.1 Easy-to-use and Comprehensive Routines
Many routines appear in the Library in two forms: a comprehensive form and an easy-to-use form. The objective in the easy-to-use forms is to make the routine simple to use by including in the calling sequence only those parameters absolutely essential to the definition of the problem, as opposed to parameters relevant to the solution method. If you are an experienced user the comprehensive routines have additional parameters which enable you to improve their efficiency by ‘tuning’ the method to a particular problem. If you are a casual or inexperienced user, this feature is of little value and may in some cases cause a failure because of a poor choice of some parameters.
In the easy-to-use routines, these extra parameters are determined either by fixing them at a known safe and reasonably efficient value, or by an auxiliary routine which generates a ‘good’ value automatically.
For routines introduced since Mark 12 of the Library a different approach has been adopted towards the choice of easy-to-use and comprehensive routines. The optimization routine has an easy-to-use parameter list, but additional parameters may be changed from their default values by calling an ‘option’ setting routine before the call to the main optimization routine. This approach has the advantages of allowing the options to be given in the form of keywords and requiring only those options that are to be different from their default values to be set.
3.2 Thread Safe Routines
Many of the routines in this chapter come in pairs, with each routine in the pair having exactly the same functionality, except that one of them has additional parameters in order to make it safe for use in multithreaded applications. The routine that is safe for use in multithreaded applicatons has an ‘A’ as the last character in the name, in place of the usual ‘F’.
An example of such a pair is
E04ABA and
E04ABF.
All ‘F’ routines not scheduled for withdrawal from the Library and where there is no ‘A’ version of that routine are thread safe provided that the implementation as a whole is considered thread safe (refer to the Users' Note for your implementation).
3.3 Reverse Communication Routines
Most of the routines in this chapter are called just once in order to compute the minimum of a given objective function subject to a set of constraints on the variables. The objective function and nonlinear constraints (if any) are specified by you and written as subroutines to a very rigid format described in the relevant routine document.
This chapter also contains a pair of
reverse communication routines,
E04UFF/E04UFA, which solve dense NLP problems using a sequential quadratic programming method. These may be convenient to use when the minimization routine is being called from a computer language which does not fully support procedure arguments in a way that is compatible with the Library. See
Section 3.2.3 in the Essential Introduction for more information about reverse communication routines.
3.4 Service Routines
One of the most common errors in the use of optimization routines is that user-supplied subroutines do not evaluate the relevant partial derivatives correctly. Because exact gradient information normally enhances efficiency in all areas of optimization, you are encouraged to provide analytical derivatives whenever possible. However, mistakes in the computation of derivatives can result in serious and obscure run-time errors. Consequently, service routines are provided to perform an elementary check on the gradients you supplied. These routines are inexpensive to use in terms of the number of calls they require to user-supplied subroutines.
The appropriate checking routines are as follows:
It should be noted that routines
E04UFF/E04UFA,
E04USF/E04USA,
E04VHF and
E04WDF
each incorporate a check on the gradients being supplied. This involves verifying the gradients at the first point that satisfies the linear constraints and bounds. There is also an option to perform a more reliable (but more expensive) check on the individual gradient elements being supplied. Note that the checks are not infallible.
A second type of service routine computes a set of finite differences to be used when approximating first derivatives. Such differences are required as input parameters by some routines that use only function evaluations.
E04YCF estimates selected elements of the variance-covariance matrix for the computed regression parameters following the use of a nonlinear least squares routine.
E04XAF/E04XAA estimates the gradient and Hessian of a function at a point, given a routine to calculate function values only, or estimates the Hessian of a function at a point, given a routine to calculate function and gradient values.
3.5 Function Evaluations at Infeasible Points
All the routines for constrained problems will ensure that any evaluations of the objective function occur at points which approximately satisfy any simple bounds or linear constraints. Satisfaction of such constraints is only approximate because routines which estimate derivatives by finite differences may require function evaluations at points which just violate such constraints even though the current iteration just satisfies them.
There is no attempt to ensure that the current iteration satisfies any nonlinear constraints. If you wish to prevent your objective function being evaluated outside some known region (where it may be undefined or not practically computable), you may try to confine the iteration within this region by imposing suitable simple bounds or linear constraints (but beware as this may create new local minima where these constraints are active).
Note also that some routines allow you to return the parameter
(IFLAG or MODE)
with a negative value to force an immediate clean exit from the minimization routine when the objective function (or nonlinear constraints where appropriate) cannot be evaluated.
3.6 Related Problems
Apart from the standard types of optimization problem, there are other related problems which can be solved by routines in this or other chapters of the Library.
H02BBF solves
dense integer LP problems,
H02CBF solves
dense integer QP problems,
H02CEF solves
sparse integer QP problems and
H03ABF solves a special type of such problem known as a
‘transportation’ problem.
Several routines in
Chapters F04 and
F08 solve
linear least squares problems, i.e.,
where
.
E02GAF solves an overdetermined system of linear equations in the
norm, i.e., minimizes
, with
as above, and
E02GBF solves the same problem subject to linear inequality constraints.
E02GCF solves an overdetermined system of linear equations in the
norm, i.e., minimizes
, with
as above.
Chapter E05 contains routines for global minimization.
Section 2.4.5 describes how a multi-objective optimization problem might be addressed using routines from this chapter and from
Chapter E05.
3.7 Choosing Between Variant Routines for Some Problems
As evidenced by the wide variety of routines available in
Chapter E04, it is clear that no single algorithm can solve all optimization problems. It is important to try to match the problem to the most suitable routine, and that is what the decision trees in
Section 4 help to do.
Sometimes in
Chapter E04 more than one routine is available to solve precisely the same minimization problem. Thus, for example, the general nonlinear programming routines
E04UCF/E04UCA and
E04WDF are based on similar methods. Experience shows that although both routines can usually solve the same problem and get similar results, sometimes one routine will be faster, sometimes one might find a different local minimum to the other, or, in difficult cases, one routine may obtain a solution when the other one fails.
After using one of these routines, if the results obtained are unacceptable for some reason, it may be worthwhile trying the other routine instead. In the absence of any other information, in the first instance you are recommended to try using
E04UCF/E04UCA, and if that proves unsatisfactory, try using
E04WDF. Although the algorithms used are very similar, the two routines each have slightly different optional parameters which may allow the course of the computation to be altered in different ways.
Other pairs of routines which solve the same kind of problem are
E04NQF (recommended first choice) or
E04NKF/E04NKA, for sparse quadratic or linear programming problems, and
E04UGF/E04UGA or
E04VHF, for sparse nonlinear programming. In these cases the parameter lists are not so similar as
E04UCF/E04UCA or
E04WDF, but the same considerations apply.
4 Decision Trees
Tree 1: Selection chart for unconstrained problems
Only one variable? |
|
Are first derivatives available? |
|
E04BBF |
yes | yes |
| no | | | no | |
|
E04ABF |
|
|
Does the function have many discontinuities? |
|
E04CBF |
yes |
| no | |
Is store size a problem? |
|
E04DGF |
yes |
| no | |
Is the function a sum of squares? |
|
Are you an experienced user? |
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04HEF |
yes | yes | yes | yes |
| no | | | no | | | no | | | no | |
|
|
|
Are there more than ten variables? |
|
E04GBF |
| | | yes |
| | | | no | |
|
|
|
E04GDF |
| | |
| | |
|
|
E04FCF |
| |
| |
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04HYF |
| yes | yes |
| | no | | | no | |
|
|
Are there more than ten variables? |
|
E04GYF |
| | yes |
| | | no | |
|
|
E04GZF |
| |
| |
|
E04FYF |
|
|
Are you an experienced user? |
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04LBF |
yes | yes | yes |
| no | | | no | | | no | |
|
|
Is computational cost critical? |
|
E04UCF, E04UFF, E04UGF, E04VHF or E04WDF |
| | yes |
| | | no | |
|
|
E04KDF |
| |
| |
|
E04UCF, E04UFF, E04UGF, E04VHF or E04WDF |
|
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04LYF |
yes | yes |
| no | | | no | |
|
Is computational cost critical? |
|
E04KYF |
| yes |
| | no | |
|
E04KZF |
|
|
E04JYF |
|
Tree 2: Selection chart for bound-constrained, linearly-constrained and nonlinearly-constrained problems
Are there any nonlinear constraints? |
|
Is the objective function a sum of squares? (A least squares problem) |
|
E04USF |
yes | yes |
| no | | | no | |
|
Are the constraints sparse? |
|
E04UGF or E04VHF |
| yes |
| | no | |
|
E04UCF, E04UFF or E04WDF |
|
|
Is the objective function linear? (An LP problem) |
|
See Tree 3 |
yes |
| no | |
Is the objective function quadratic? (A or least squares problem) |
|
Is the problem a least squares problem? |
|
Are the constraints simple bounds? |
|
E04PCF |
yes | yes | yes |
| no | | | no | | | no | |
|
|
E04NCF and E04PCF |
| |
| |
|
See Tree 3 |
|
|
Is the objective function a sum of squares? (A least squares problem) |
|
E04USF |
yes |
| no | |
Are the constraints simple bounds? |
|
Are you an experienced user? |
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04LBF |
yes | yes | yes | yes |
| no | | | no | | | no | | | no | |
|
|
|
E04KDF, E04UCF, E04UFF, E04UGF or E04VHF |
| | |
| | |
|
|
E04UCF, E04UFF, E04UGF, E04VHF or E04WDF |
| |
| |
|
Are first derivatives available? |
|
Are second derivatives available? |
|
E04LYF |
| yes | yes |
| | no | | | no | |
|
|
Is computational cost critical? |
|
E04KYF |
| | yes |
| | | no | |
|
|
E04KZF |
| |
| |
|
E04JCF or E04JYF |
|
|
E04UCF, E04UFF, E04UGF or E04VHF |
|
Tree 3: Linear and Quadratic Programming (LP and QP)
5 Functionality Index
Constrained minimum of a sum of squares, nonlinear constraints, | | |
using function values and optionally first derivatives, sequential QP method, | | |
Convex QP problem or linearly-constrained linear least squares problem (dense) | | E04NCF |
Linear least squares with bounds on the variables | | E04PCF |
Linear programming (LP) problem (dense) | | E04MFF |
LP or QP problem (sparse) | | E04NKF |
Minimum, function of one variable, | | |
using function values only | | E04ABF |
Minimum, function of several variables, nonlinear constraints, | | |
using function values and optionally first derivatives, sequential QP method, | | |
Minimum, function of several variables, nonlinear constraints (comprehensive), | | |
using function values and optionally first derivatives, sequential QP method, | | |
reverse communication (dense) | | E04UFF |
Minimum, function of several variables, simple bounds, | | |
using first and second derivatives, modified Newton algorithm | | E04LBF |
Minimum, function of several variables, simple bounds (comprehensive), | | |
using first derivatives, modified Newton algorithm | | E04KDF |
Minimum, function of several variables, simple bounds (easy-to-use), | | |
using first and second derivatives, modified Newton algorithm | | E04LYF |
modified Newton algorithm | | E04KZF |
using function values only, by quadratic approximation | | E04JCF |
using function values only, quasi-Newton algorithm | | E04JYF |
Quadratic programming (QP) problem (dense) | | E04NFF |
check user's routine for calculating, | | |
first derivatives of function | | E04HCF |
Hessian of a sum of squares | | E04YBF |
Jacobian of first derivatives | | E04YAF |
second derivatives of function | | E04HDF |
convert MPS data file defining LP or QP problem to format required by E04NQF (recommended) | | E04MXF |
convert MPSX data file defining LP or QP problem to format required by E04NQF | | E04MZF |
covariance matrix for nonlinear least squares problem | | E04YCF |
determine Jacobian sparsity structure before a call of E04VHF | | E04VJF |
estimate gradient and/or Hessian of a function | | E04XAF |
initialization routine for, | | |
retrieve integer optional parameter values used by, | | |
retrieve real optional parameter values used by, | | |
supply integer optional parameter values to, | | |
supply optional parameter values from external file for, | | |
supply optional parameter values to, | | |
supply real optional parameter values to, | | |
Unconstrained minimum, function of several variables, | | |
using first derivatives, pre-conditioned conjugate gradient algorithm | | E04DGF |
using function values only, simplex algorithm | | E04CBF |
Unconstrained minimum of a sum of squares (comprehensive): | | |
combined Gauss–Newton and modified Newton algorithm | | E04GDF |
combined Gauss–Newton and quasi-Newton algorithm | | E04GBF |
using function values only, | | |
combined Gauss–Newton and modified Newton algorithm | | E04FCF |
using second derivatives, | | |
combined Gauss–Newton and modified Newton algorithm | | E04HEF |
Unconstrained minimum of a sum of squares (easy-to-use): | | |
combined Gauss–Newton and modified Newton algorithm | | E04GZF |
combined Gauss–Newton and quasi-Newton algorithm | | E04GYF |
using function values only, | | |
combined Gauss–Newton and modified Newton algorithm | | E04FYF |
using second derivatives, | | |
combined Gauss–Newton and modified Newton algorithm | | E04HYF |
6 Auxiliary Routines Associated with Library Routine Parameters
E04CBK | nagf_opt_uncon_simplex_dummy_monit See the description of the parameter
MONIT in E04CBF. |
E04FCV | nagf_opt_lsq_uncon_quasi_deriv_comp_lsqlin_fun See the description of the parameter
LSQLIN in E04GBF. |
E04FDZ | nagf_opt_lsq_dummy_lsqmon See the description of the parameter
LSQMON in E04FCF, E04GDF and E04HEF. |
E04HEV | nagf_opt_lsq_uncon_quasi_deriv_comp_lsqlin_deriv See the description of the parameter
LSQLIN in E04GBF. |
E04JCP | nagf_opt_bounds_bobyqa_func_dummy_monfun See the description of the parameter
MONFUN in E04JCF. |
E54NFU | nagf_opt_qp_dense_sample_qphess See the description of the parameter
QPHESS in E04NFF/E04NFA and H02CBF. |
E04NFU | nagf_opt_qp_dense_sample_qphess_old See the description of the parameter
QPHESS in E04NFF/E04NFA and H02CBF. |
E54NKU | nagf_opt_qpconvex1_sparse_dummy_qphx See the description of the parameter
QPHX in E04NKF/E04NKA and H02CEF. |
E04NKU | nagf_opt_qpconvex1_sparse_dummy_qphx_old See the description of the parameter
QPHX in E04NKF/E04NKA and H02CEF. |
E04NSH | nagf_opt_qpconvex2_sparse_dummy_qphx See the description of the parameter
QPHX in E04NQF. |
E04UDM | nagf_opt_nlp1_dummy_confun See the description of the parameter
CONFUN in E04UCF/E04UCA and E04USF/E04USA. |
E04UGN | nagf_opt_nlp1_sparse_dummy_objfun See the description of the parameter
OBJFUN in E04UGF/E04UGA. |
E04UGM | nagf_opt_nlp1_sparse_dummy_confun See the description of the parameter
CONFUN in E04UGF/E04UGA. |
E04WDP | nagf_opt_nlp2_dummy_confun See the description of the parameter
CONFUN in E04WDF. |
7 Routines Withdrawn or Scheduled for Withdrawal
The following lists all those routines that have been withdrawn since Mark 18 of the Library or are scheduled for withdrawal at one of the next two marks.
8 References
Bard Y (1974) Nonlinear Parameter Estimation Academic Press
Dantzig G B (1963) Linear Programming and Extensions Princeton University Press
Fletcher R (1987) Practical Methods of Optimization (2nd Edition) Wiley
Gill P E and Murray W (ed.) (1974) Numerical Methods for Constrained Optimization Academic Press
Gill P E, Murray W and Wright M H (1981) Practical Optimization Academic Press
Murray W (ed.) (1972) Numerical Methods for Unconstrained Optimization Academic Press
Wolberg J R (1967) Prediction Analysis Van Nostrand