naginterfaces.library.opt.lsq_gencon_deriv¶
- naginterfaces.library.opt.lsq_gencon_deriv(bl, bu, y, objfun, x, comm, a=None, confun=None, istate=None, cjac=None, fjac=None, clamda=None, r=None, data=None, io_manager=None)[source]¶
lsq_gencon_deriv
is designed to minimize an arbitrary smooth sum of squares function subject to constraints (which may include simple bounds on the variables, linear constraints and smooth nonlinear constraints) using a Sequential Quadratic Programming (SQP) method. As many first derivatives as possible should be supplied by you; any unspecified derivatives are approximated by finite differences. See the description of the option ‘Derivative Level’, in Other Parameters. It is not intended for large sparse problems.lsq_gencon_deriv
may also be used for unconstrained, bound-constrained and linearly constrained optimization.Note: this function uses optional algorithmic parameters, see also:
lsq_gencon_deriv_option_file()
,lsq_gencon_deriv_option_string()
,nlp1_init()
.For full information please refer to the NAG Library document for e04us
https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/e04/e04usf.html
- Parameters
- blfloat, array-like, shape
must contain the lower bounds for all the constraints.
- bufloat, array-like, shape
must contain the upper bounds for all the constraints.
- yfloat, array-like, shape
The coefficients of the constant vector of the objective function.
- objfuncallable f = objfun(mode, needfi, x, fjac, nstate, data=None)
must calculate either the th element of the vector or all elements of and (optionally) its Jacobian () for a specified -element vector .
- Parameters
- modeint
Indicates which values must be assigned during each call of . Only the following values need be assigned:
and , where
.
and
.
and
All available elements of .
and
and all available elements of .
- needfiint
If , only the th element of needs to be evaluated at ; the remaining elements need not be set. This can result in significant computational savings when .
- xfloat, ndarray, shape
, the vector of variables at which and/or all available elements of its Jacobian are to be evaluated.
- fjacfloat, ndarray, shape , to be modified in place
On entry: is set to a special value.
On exit: if or and , the th row of must contain the available elements of the vector given by
evaluated at the point . See also the argument .
- nstateint
If , then
lsq_gencon_deriv
is calling for the first time. This argument setting allows you to save computation time if certain data must be read or calculated only once.- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- ffloat, array-like, shape
If and , must contain the value of at .
If or and , must contain the value of at , for .
- xfloat, array-like, shape
An initial estimate of the solution.
- commdict, communication object, modified in place
Communication structure.
This argument must have been initialized by a prior call to
nlp1_init()
.- aNone or float, array-like, shape , optional
Note: the required extent for this argument in dimension 2 is determined as follows: if : ; otherwise: .
The th row of contains the th row of the matrix of general linear constraints in (1). That is, the th row contains the coefficients of the th general linear constraint, for .
- confunNone or callable c = confun(mode, needc, x, cjac, nstate, data=None), optional
Note: if this argument is None then a NAG-supplied facility will be used.
must calculate the vector of nonlinear constraint functions and (optionally) its Jacobian () for a specified -element vector .
If there are no nonlinear constraints (i.e., ), will never be called by
lsq_gencon_deriv
and may be None. If there are nonlinear constraints, the first call to will occur before the first call to .- Parameters
- modeint
Indicates which values must be assigned during each call of . Only the following values need be assigned, for each value of such that :
.
All available elements in the th row of .
and all available elements in the th row of .
- needcint, ndarray, shape
The indices of the elements of and/or that must be evaluated by . If , the th element of and/or the available elements of the th row of (see argument ) must be evaluated at .
- xfloat, ndarray, shape
, the vector of variables at which the constraint functions and/or all available elements of the constraint Jacobian are to be evaluated.
- cjacfloat, ndarray, shape , to be modified in place
On entry: is set to a special value.
On exit: if and or , the th row of must contain the available elements of the vector given by
where is the partial derivative of the th constraint with respect to the th variable, evaluated at the point . See also the argument . The remaining rows of , corresponding to non-positive elements of , are ignored.
If all elements of the constraint Jacobian are known (i.e., or ), any constant elements may be assigned to one time only at the start of the optimization.
An element of that is not subsequently assigned in will retain its initial value throughout.
Constant elements may be loaded into either before the call to
lsq_gencon_deriv
or during the first call to (signalled by the value ).The ability to preload constants is useful when many Jacobian elements are identically zero, in which case may be initialized to zero and nonzero elements may be reset by .
Note that constant nonzero elements do affect the values of the constraints.
Thus, if is set to a constant value, it need not be reset in subsequent calls to , but the value must nonetheless be added to .
For example, if and , the term must be included in the definition of .
It must be emphasized that, if or , unassigned elements of are not treated as constant; they are estimated by finite differences, at nontrivial expense.
If you do not supply a value for the option ‘Difference Interval’, an interval for each element of is computed automatically at the start of the optimization.
The automatic procedure can usually identify constant elements of , which are then computed once only by finite differences.
- nstateint
If , then
lsq_gencon_deriv
is calling for the first time. This argument setting allows you to save computation time if certain data must be read or calculated only once.- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- cfloat, array-like, shape
If and or , must contain the value of the th constraint at . The remaining elements of , corresponding to the non-positive elements of , are ignored.
- istateNone or int, array-like, shape , optional
Need not be set if the (default) option ‘Cold Start’ is used.
If the option ‘Warm Start’ has been chosen, the elements of corresponding to the bounds and linear constraints define the initial working set for the procedure that finds a feasible point for the linear constraints and bounds.
The active set at the conclusion of this procedure and the elements of corresponding to nonlinear constraints then define the initial working set for the first QP subproblem.
More precisely, the first elements of refer to the upper and lower bounds on the variables, the next elements refer to the upper and lower bounds on , and the next elements refer to the upper and lower bounds on .
Possible values for are as follows:
Meaning
0
The corresponding constraint is not in the initial QP working set.
1
This inequality constraint should be in the working set at its lower bound.
2
This inequality constraint should be in the working set at its upper bound.
3
This equality constraint should be in the initial working set. This value must not be specified unless .
The values , and are also acceptable but will be modified by the function.
If
lsq_gencon_deriv
has been called previously with the same values of , and , already contains satisfactory information. (See also the description of the option ‘Warm Start’.) The function also adjusts (if necessary) the values supplied in to be consistent with .- cjacNone or float, array-like, shape , optional
Note: the required extent for this argument in dimension 2 is determined as follows: if : ; otherwise: .
In general, need not be initialized before the call to
lsq_gencon_deriv
. However, if , you may optionally set the constant elements of (see argument in the description of ). Such constant elements need not be re-assigned on subsequent calls to .- fjacNone or float, array-like, shape , optional
In general, need not be initialized before the call to
lsq_gencon_deriv
. However, if , you may optionally set the constant elements of (see argument in the description of ). Such constant elements need not be re-assigned on subsequent calls to .- clamdaNone or float, array-like, shape , optional
Need not be set if the (default) option ‘Cold Start’ is used.
If the option ‘Warm Start’ has been chosen, must contain a multiplier estimate for each nonlinear constraint with a sign that matches the status of the constraint specified by the array, for .
The remaining elements need not be set.
Note that if the th constraint is defined as ‘inactive’ by the initial value of the array (i.e., ), should be zero; if the th constraint is an inequality active at its lower bound (i.e., ), should be non-negative; if the th constraint is an inequality active at its upper bound (i.e., , should be non-positive.
If necessary, the function will modify to match these rules.
- rNone or float, array-like, shape , optional
Need not be initialized if the (default) option ‘Cold Start’ is used.
If the option ‘Warm Start’ has been chosen, must contain the upper triangular Cholesky factor of the initial approximation of the Hessian of the Lagrangian function, with the variables in the natural order.
Elements not in the upper triangular part of are assumed to be zero and need not be assigned.
- dataarbitrary, optional
User-communication data for callback functions.
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- Returns
- iteraint
The number of major iterations performed.
- istateint, ndarray, shape
The status of the constraints in the QP working set at the point returned in . The significance of each possible value of is as follows:
Meaning
This constraint violates its lower bound by more than the appropriate feasibility tolerance (see the options ‘Linear Feasibility Tolerance’ and ‘Nonlinear Feasibility Tolerance’). This value can occur only when no feasible point can be found for a QP subproblem.
This constraint violates its upper bound by more than the appropriate feasibility tolerance (see the options ‘Linear Feasibility Tolerance’ and ‘Nonlinear Feasibility Tolerance’). This value can occur only when no feasible point can be found for a QP subproblem.
The constraint is satisfied to within the feasibility tolerance, but is not in the QP working set.
This inequality constraint is included in the QP working set at its lower bound.
This inequality constraint is included in the QP working set at its upper bound.
This constraint is included in the QP working set as an equality. This value of can occur only when .
- cNone or float, ndarray, shape
If , contains the value of the th nonlinear constraint function at the final iterate, for .
If , is returned as None.
- cjacNone or float, ndarray, shape
If , contains the Jacobian matrix of the nonlinear constraint functions at the final iterate, i.e., contains the partial derivative of the th constraint function with respect to the th variable, for , for . (See the discussion of argument under .)
If , is returned as None.
- ffloat, ndarray, shape
contains the value of the th function at the final iterate, for .
- fjacfloat, ndarray, shape
The Jacobian matrix of the functions at the final iterate, i.e., contains the partial derivative of the th function with respect to the th variable, for , for . (See also the discussion of argument under .)
- clamdafloat, ndarray, shape
The values of the QP multipliers from the last QP subproblem. should be non-negative if and non-positive if .
- objffloat
The value of the objective function at the final iterate.
- rfloat, ndarray, shape
If , contains the upper triangular Cholesky factor of , an estimate of the transformed and reordered Hessian of the Lagrangian at (see (6)). If , contains the upper triangular Cholesky factor of , the approximate (untransformed) Hessian of the Lagrangian, with the variables in the natural order.
- xfloat, ndarray, shape
The final estimate of the solution.
- Other Parameters
- ‘Central Difference Interval’float
Default values are computed
If the algorithm switches to central differences because the forward-difference approximation is not sufficiently accurate, the value of is used as the difference interval for every element of . The switch to central differences is indicated by C at the end of each line of intermediate printout produced by the major iterations (see Further Comments). The use of finite differences is discussed further under the option ‘Difference Interval’.
If you supply a value for this option, a small value between and is appropriate.
- ‘Cold Start’valueless
Default
This option controls the specification of the initial working set in both the procedure for finding a feasible point for the linear constraints and bounds, and in the first QP subproblem thereafter. With a ‘Cold Start’, the first working set is chosen by
lsq_gencon_deriv
based on the values of the variables and constraints at the initial point. Broadly speaking, the initial working set will include equality constraints and bounds or inequality constraints that violate or ‘nearly’ satisfy their bounds (to within ‘Crash Tolerance’).With a ‘Warm Start’, you must set the array and define and as discussed in Parameters. values associated with bounds and linear constraints determine the initial working set of the procedure to find a feasible point with respect to the bounds and linear constraints. values associated with nonlinear constraints determine the initial working set of the first QP subproblem after such a feasible point has been found.
lsq_gencon_deriv
will override your specification of if necessary, so that a poor choice of the working set will not cause a fatal error. For instance, any elements of which are set to , or will be reset to zero, as will any elements which are set to when the corresponding elements of and are not equal. A ‘Warm Start’ will be advantageous if a good estimate of the initial working set is available – for example, whenlsq_gencon_deriv
is called repeatedly to solve related problems.- ‘Warm Start’valueless
This option controls the specification of the initial working set in both the procedure for finding a feasible point for the linear constraints and bounds, and in the first QP subproblem thereafter. With a ‘Cold Start’, the first working set is chosen by
lsq_gencon_deriv
based on the values of the variables and constraints at the initial point. Broadly speaking, the initial working set will include equality constraints and bounds or inequality constraints that violate or ‘nearly’ satisfy their bounds (to within ‘Crash Tolerance’).With a ‘Warm Start’, you must set the array and define and as discussed in Parameters. values associated with bounds and linear constraints determine the initial working set of the procedure to find a feasible point with respect to the bounds and linear constraints. values associated with nonlinear constraints determine the initial working set of the first QP subproblem after such a feasible point has been found.
lsq_gencon_deriv
will override your specification of if necessary, so that a poor choice of the working set will not cause a fatal error. For instance, any elements of which are set to , or will be reset to zero, as will any elements which are set to when the corresponding elements of and are not equal. A ‘Warm Start’ will be advantageous if a good estimate of the initial working set is available – for example, whenlsq_gencon_deriv
is called repeatedly to solve related problems.- ‘Crash Tolerance’float
Default
This value is used in conjunction with the option ‘Cold Start’ (the default value) when
lsq_gencon_deriv
selects an initial working set. If , the initial working set will include (if possible) bounds or general inequality constraints that lie within of their bounds. In particular, a constraint of the form will be included in the initial working set if . If or , the default value is used.- ‘Defaults’valueless
This special keyword may be used to reset all options to their default values.
- ‘Derivative Level’int
Default
This argument indicates which derivatives are provided in functions and . The possible choices for are the following.
Meaning
3
All elements of the objective Jacobian and the constraint Jacobian are provided by you.
2
All elements of the constraint Jacobian are provided, but some elements of the objective Jacobian are not specified by you.
1
All elements of the objective Jacobian are provided, but some elements of the constraint Jacobian are not specified by you.
0
Some elements of both the objective Jacobian and the constraint Jacobian are not specified by you.
The value should be used whenever possible, since
lsq_gencon_deriv
is more reliable (and will usually be more efficient) when all derivatives are exact.If or ,
lsq_gencon_deriv
will approximate unspecified elements of the objective Jacobian, using finite differences. The computation of finite difference approximations usually increases the total run-time, since a call to is required for each unspecified element. Furthermore, less accuracy can be attained in the solution (see Module 8 of Gill et al. (1981), for a discussion of limiting accuracy).If or ,
lsq_gencon_deriv
will approximate unspecified elements of the constraint Jacobian. One call to is needed for each variable for which partial derivatives are not available. For example, if the constraint Jacobian has the formwhere ‘’ indicates an element provided by you and ‘?’ indicates an unspecified element,
lsq_gencon_deriv
will call twice: once to estimate the missing element in column , and again to estimate the two missing elements in column . (Since columns and are known, they require no calls to .)At times, central differences are used rather than forward differences, in which case twice as many calls to and are needed. (The switch to central differences is not under your control.)
If or , the default value is used.
- ‘Difference Interval’float
Default values are computed
This option defines an interval used to estimate derivatives by finite differences in the following circumstances:
For verifying the objective and/or constraint gradients (see the description of the option ‘Verify’).
For estimating unspecified elements of the objective and/or constraint Jacobian matrix.
In general, a derivative with respect to the th variable is approximated using the interval , where , with the first point feasible with respect to the bounds and linear constraints. If the functions are well scaled, the resulting derivative approximation should be accurate to . See Gill et al. (1981) for a discussion of the accuracy in finite difference approximations.
If a difference interval is not specified, a finite difference interval will be computed automatically for each variable by a procedure that requires up to six calls of and for each element. This option is recommended if the function is badly scaled or you wish to have
lsq_gencon_deriv
determine constant elements in the objective and constraint gradients (see the descriptions of and in Parameters).If you supply a value for this option, a small value between and is appropriate.
- ‘Feasibility Tolerance’float
Default
The scalar defines the maximum acceptable absolute violations in linear and nonlinear constraints at a ‘feasible’ point; i.e., a constraint is considered satisfied if its violation does not exceed . If or , the default value is used. Using this keyword sets both options ‘Linear Feasibility Tolerance’ and ‘Nonlinear Feasibility Tolerance’ to , if . (Additional details are given under the descriptions of these options.)
- ‘Function Precision’float
Default
This argument defines , which is intended to be a measure of the accuracy with which the problem functions and can be computed. If or , the default value is used.
The value of should reflect the relative precision of ; i.e., acts as a relative precision when is large and as an absolute precision when is small. For example, if is typically of order and the first six significant digits are known to be correct, an appropriate value for would be . In contrast, if is typically of order and the first six significant digits are known to be correct, an appropriate value for would be . The choice of can be quite complicated for badly scaled problems; see Module 8 of Gill et al. (1981) for a discussion of scaling techniques. The default value is appropriate for most simple functions that are computed with full accuracy. However, when the accuracy of the computed function values is known to be significantly worse than full precision, the value of should be large enough so that
lsq_gencon_deriv
will not attempt to distinguish between function values that differ by less than the error inherent in the calculation.- ‘Hessian’str
Default
This option controls the contents of the upper triangular matrix (see Parameters).
lsq_gencon_deriv
works exclusively with the transformed and reordered Hessian , and hence extra computation is required to form the Hessian itself. If , contains the Cholesky factor of the transformed and reordered Hessian. If , the Cholesky factor of the approximate Hessian itself is formed and stored in . You should select if a ‘Warm Start’ will be used for the next call tolsq_gencon_deriv
.- ‘Infinite Bound Size’float
Default
If , defines the ‘infinite’ bound in the definition of the problem constraints. Any upper bound greater than or equal to will be regarded as (and similarly any lower bound less than or equal to will be regarded as ). If , the default value is used.
- ‘Infinite Step Size’float
Default
If , specifies the magnitude of the change in variables that is treated as a step to an unbounded solution. If the change in during an iteration would exceed the value of , the objective function is considered to be unbounded below in the feasible region. If , the default value is used.
- ‘JTJ Initial Hessian’valueless
Default
This option controls the initial value of the upper triangular matrix . If denotes the objective Jacobian matrix , is often a good approximation to the objective Hessian matrix (see also option ‘Reset Frequency’).
- ‘Unit Initial Hessian’valueless
This option controls the initial value of the upper triangular matrix . If denotes the objective Jacobian matrix , is often a good approximation to the objective Hessian matrix (see also option ‘Reset Frequency’).
- ‘Line Search Tolerance’float
Default
The value () controls the accuracy with which the step taken during each iteration approximates a minimum of the merit function along the search direction (the smaller the value of , the more accurate the linesearch). The default value requests an inaccurate search and is appropriate for most problems, particularly those with any nonlinear constraints.
If there are no nonlinear constraints, a more accurate search may be appropriate when it is desirable to reduce the number of major iterations – for example, if the objective function is cheap to evaluate, or if a substantial number of derivatives are unspecified. If or , the default value is used.
- ‘Linear Feasibility Tolerance’float
Default
The default value of is if or , and otherwise.
The scalars and define the maximum acceptable absolute violations in linear and nonlinear constraints at a ‘feasible’ point; i.e., a linear constraint is considered satisfied if its violation does not exceed , and similarly for a nonlinear constraint and . If or , the default value is used, for .
On entry to
lsq_gencon_deriv
, an iterative procedure is executed in order to find a point that satisfies the linear constraints and bounds on the variables to within the tolerance . All subsequent iterates will satisfy the linear constraints to within the same tolerance (unless is comparable to the finite difference interval).For nonlinear constraints, the feasibility tolerance defines the largest constraint violation that is acceptable at an optimal point. Since nonlinear constraints are generally not satisfied until the final iterate, the value of option ‘Nonlinear Feasibility Tolerance’ acts as a partial termination criterion for the iterative sequence generated by
lsq_gencon_deriv
(see also option ‘Optimality Tolerance’).These tolerances should reflect the precision of the corresponding constraints. For example, if the variables and the coefficients in the linear constraints are of order unity, and the latter are correct to about decimal digits, it would be appropriate to specify as .
- ‘Nonlinear Feasibility Tolerance’float
Default or
The default value of is if or , and otherwise.
The scalars and define the maximum acceptable absolute violations in linear and nonlinear constraints at a ‘feasible’ point; i.e., a linear constraint is considered satisfied if its violation does not exceed , and similarly for a nonlinear constraint and . If or , the default value is used, for .
On entry to
lsq_gencon_deriv
, an iterative procedure is executed in order to find a point that satisfies the linear constraints and bounds on the variables to within the tolerance . All subsequent iterates will satisfy the linear constraints to within the same tolerance (unless is comparable to the finite difference interval).For nonlinear constraints, the feasibility tolerance defines the largest constraint violation that is acceptable at an optimal point. Since nonlinear constraints are generally not satisfied until the final iterate, the value of option ‘Nonlinear Feasibility Tolerance’ acts as a partial termination criterion for the iterative sequence generated by
lsq_gencon_deriv
(see also option ‘Optimality Tolerance’).These tolerances should reflect the precision of the corresponding constraints. For example, if the variables and the coefficients in the linear constraints are of order unity, and the latter are correct to about decimal digits, it would be appropriate to specify as .
- ‘List’valueless
Option ‘List’ enables printing of each option specification as it is supplied. ‘Nolist’ suppresses this printing.
- ‘Nolist’valueless
Default
Option ‘List’ enables printing of each option specification as it is supplied. ‘Nolist’ suppresses this printing.
- ‘Major Iteration Limit’int
Default
The value of specifies the maximum number of major iterations allowed before termination. Setting and means that the workspace needed will be computed and printed, but no iterations will be performed. If , the default value is used.
- ‘Iteration Limit’int
Default
The value of specifies the maximum number of major iterations allowed before termination. Setting and means that the workspace needed will be computed and printed, but no iterations will be performed. If , the default value is used.
- ‘Iters’int
Default
The value of specifies the maximum number of major iterations allowed before termination. Setting and means that the workspace needed will be computed and printed, but no iterations will be performed. If , the default value is used.
- ‘Itns’int
Default
The value of specifies the maximum number of major iterations allowed before termination. Setting and means that the workspace needed will be computed and printed, but no iterations will be performed. If , the default value is used.
- ‘Major Print Level’int
The value of controls the amount of printout produced by the major iterations of
lsq_gencon_deriv
, as indicated below. A detailed description of the printed output is given in Further Comments (summary output at each major iteration and the final solution) and Monitoring Information (monitoring information at each major iteration). (See also the description of the option ‘Minor Print Level’.)The following printout is sent to the file object associated with the advisory I/O unit (see
FileObjManager
):Output
No output.
The final solution only.
One line of summary output ( characters; see Further Comments) for each major iteration (no printout of the final solution).
The final solution and one line of summary output for each major iteration.
The following printout is sent to the unit number given by the option ‘Monitoring File’:
Output
No output.
One long line of output ( characters; see Monitoring Information) for each major iteration (no printout of the final solution).
At each major iteration, the objective function, the Euclidean norm of the nonlinear constraint violations, the values of the nonlinear constraints (the vector ), the values of the linear constraints (the vector ), and the current values of the variables (the vector ).
At each major iteration, the diagonal elements of the matrix associated with the factorization (see (5)) of the QP working set, and the diagonal elements of , the triangular factor of the transformed and reordered Hessian (see (6)).
If and the unit number defined by the option ‘Monitoring File’ is the advisory unit number, the summary output for each major iteration is suppressed.
- ‘Print Level’int
Default for
lsq_gencon_deriv
The value of controls the amount of printout produced by the major iterations of
lsq_gencon_deriv
, as indicated below. A detailed description of the printed output is given in Further Comments (summary output at each major iteration and the final solution) and Monitoring Information (monitoring information at each major iteration). (See also the description of the option ‘Minor Print Level’.)The following printout is sent to the file object associated with the advisory I/O unit (see
FileObjManager
):Output
No output.
The final solution only.
One line of summary output ( characters; see Further Comments) for each major iteration (no printout of the final solution).
The final solution and one line of summary output for each major iteration.
The following printout is sent to the unit number given by the option ‘Monitoring File’:
Output
No output.
One long line of output ( characters; see Monitoring Information) for each major iteration (no printout of the final solution).
At each major iteration, the objective function, the Euclidean norm of the nonlinear constraint violations, the values of the nonlinear constraints (the vector ), the values of the linear constraints (the vector ), and the current values of the variables (the vector ).
At each major iteration, the diagonal elements of the matrix associated with the factorization (see (5)) of the QP working set, and the diagonal elements of , the triangular factor of the transformed and reordered Hessian (see (6)).
If and the unit number defined by the option ‘Monitoring File’ is the advisory unit number, the summary output for each major iteration is suppressed.
- ‘Minor Iteration Limit’int
Default
The value of specifies the maximum number of iterations for finding a feasible point with respect to the bounds and linear constraints (if any). The value of also specifies the maximum number of minor iterations for the optimality phase of each QP subproblem. If , the default value is used.
- ‘Minor Print Level’int
Default
The value of controls the amount of printout produced by the minor iterations of
lsq_gencon_deriv
(i.e., the iterations of the quadratic programming algorithm), as indicated below. A detailed description of the printed output is given in Further Comments (summary output at each minor iteration and the final QP solution) and Monitoring Information (monitoring information at each minor iteration). (See also the description of the option ‘Major Print Level’.)The following printout is sent to the file object associated with the advisory I/O unit (see
FileObjManager
):Output
No output.
The final QP solution only.
One line of summary output ( characters; see Further Comments) for each minor iteration (no printout of the final QP solution).
The final QP solution and one line of summary output for each minor iteration.
The following printout is sent to the unit number given by the option ‘Monitoring File’:
Output
No output.
One long line of output ( characters; see Monitoring Information) for each minor iteration (no printout of the final QP solution).
At each minor iteration, the current estimates of the QP multipliers, the current estimate of the QP search direction, the QP constraint values, and the status of each QP constraint.
At each minor iteration, the diagonal elements of the matrix associated with the factorization (see (5)) of the QP working set, and the diagonal elements of the Cholesky factor of the transformed Hessian (see (6)).
If and the unit number defined by the option ‘Monitoring File’ is the advisory unit number, the summary output for each major iteration is suppressed.
- ‘Monitoring File’int
Default
If and or and , monitoring information produced by
lsq_gencon_deriv
at every iteration is sent to a file with logical unit number . If and/or and , no monitoring information is produced.- ‘Optimality Tolerance’float
Default
The argument () specifies the accuracy to which you wish the final iterate to approximate a solution of the problem. Broadly speaking, indicates the number of correct figures desired in the objective function at the solution. For example, if is and
lsq_gencon_deriv
terminates successfully, the final value of should have approximately six correct figures. If or , the default value is used.lsq_gencon_deriv
will terminate successfully if the iterative sequence of values is judged to have converged and the final point satisfies the first-order Kuhn–Tucker conditions (see Overview). The sequence of iterates is considered to have converged at ifwhere is the search direction and the step length. An iterate is considered to satisfy the first-order conditions for a minimum if
and
where is the projected gradient, is the gradient of with respect to the free variables, is the violation of the th active nonlinear constraint, and is the ‘Nonlinear Feasibility Tolerance’.
- ‘Reset Frequency’int
Default
If , this argument allows you to reset the approximate Hessian matrix to every iterations, where is the objective Jacobian matrix (see also the description of the option ‘JTJ Initial Hessian’).
At any point where there are no nonlinear constraints active and the values of are small in magnitude compared to the norm of , will be a good approximation to the objective Hessian . Under these circumstances, frequent resetting can significantly improve the convergence rate of
lsq_gencon_deriv
.Resetting is suppressed at any iteration during which there are nonlinear constraints active.
If , the default value is used.
- ‘Start Objective Check At Variable’int
Default
These keywords take effect only if . They may be used to control the verification of Jacobian elements computed by functions and . For example, if the first columns of the objective Jacobian appeared to be correct in an earlier run, so that only column remains questionable, it is reasonable to specify . If the first variables appear linearly in the subfunctions, so that the corresponding Jacobian elements are constant, the above choice would also be appropriate.
If or , the default value is used, for . If or , the default value is used, for .
- ‘Stop Objective Check At Variable’int
Default
These keywords take effect only if . They may be used to control the verification of Jacobian elements computed by functions and . For example, if the first columns of the objective Jacobian appeared to be correct in an earlier run, so that only column remains questionable, it is reasonable to specify . If the first variables appear linearly in the subfunctions, so that the corresponding Jacobian elements are constant, the above choice would also be appropriate.
If or , the default value is used, for . If or , the default value is used, for .
- ‘Start Constraint Check At Variable’int
Default
These keywords take effect only if . They may be used to control the verification of Jacobian elements computed by functions and . For example, if the first columns of the objective Jacobian appeared to be correct in an earlier run, so that only column remains questionable, it is reasonable to specify . If the first variables appear linearly in the subfunctions, so that the corresponding Jacobian elements are constant, the above choice would also be appropriate.
If or , the default value is used, for . If or , the default value is used, for .
- ‘Stop Constraint Check At Variable’int
Default
These keywords take effect only if . They may be used to control the verification of Jacobian elements computed by functions and . For example, if the first columns of the objective Jacobian appeared to be correct in an earlier run, so that only column remains questionable, it is reasonable to specify . If the first variables appear linearly in the subfunctions, so that the corresponding Jacobian elements are constant, the above choice would also be appropriate.
If or , the default value is used, for . If or , the default value is used, for .
- ‘Step Limit’float
Default
If specifies the maximum change in variables at the first step of the linesearch. In some cases, such as or , even a moderate change in the elements of can lead to floating-point overflow. The argument is, therefore, used to encourage evaluation of the problem functions at meaningful points. Given any major iterate , the first point at which and are evaluated during the linesearch is restricted so that
The linesearch may go on and evaluate and at points further from if this will result in a lower value of the merit function (indicated by L at the end of each line of output produced by the major iterations; see Further Comments). If L is printed for most of the iterations, should be set to a larger value.
Wherever possible, upper and lower bounds on should be used to prevent evaluation of nonlinear functions at wild values. The default value should not affect progress on well-behaved functions, but values such as or may be helpful when rapidly varying functions are present. If a small value of ‘Step Limit’ is selected, a good starting point may be required. An important application is to the class of nonlinear least squares problems. If , the default value is used.
- ‘Verify Level’int
Default
These keywords refer to finite difference checks on the gradient elements computed by and . (Unspecified gradient elements are not checked.) The possible choices for are the following:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to .
Individual gradient elements will also be checked using a reliable (but more expensive) test.
It is possible to specify to in several ways. For example, the nonlinear objective gradient (if any) will be verified if either ‘Verify Objective Gradients’ or is specified. Similarly, the objective and the constraint gradients will be verified if or or ‘Verify’ is specified.
If , no checking will be performed.
If , gradients will be verified at the first point that satisfies the linear constraints and bounds.
If , only a ‘cheap’ test will be performed, requiring one call to and (if appropriate) one call to .
If , a more reliable (but more expensive) check will be made on individual gradient elements, within the ranges specified by the ‘Start Objective Check At Variable’ and ‘Stop Objective Check At Variable’ keywords. A result of the form OK or BAD? is printed by
lsq_gencon_deriv
to indicate whether or not each element appears to be correct. If a gradient element is determined to be extremely poor (i.e., if it appears to have no significant digits of accuracy at all), thenlsq_gencon_deriv
will also exit with an error indicator in argument .If , the action is the same as for , except that it will take place at the user-specified initial value of .
If or or , the default value is used.
We suggest that be used whenever a new function function is being developed.
- ‘Verify’valueless
These keywords refer to finite difference checks on the gradient elements computed by and . (Unspecified gradient elements are not checked.) The possible choices for are the following:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to .
Individual gradient elements will also be checked using a reliable (but more expensive) test.
It is possible to specify to in several ways. For example, the nonlinear objective gradient (if any) will be verified if either ‘Verify Objective Gradients’ or is specified. Similarly, the objective and the constraint gradients will be verified if or or ‘Verify’ is specified.
If , no checking will be performed.
If , gradients will be verified at the first point that satisfies the linear constraints and bounds.
If , only a ‘cheap’ test will be performed, requiring one call to and (if appropriate) one call to .
If , a more reliable (but more expensive) check will be made on individual gradient elements, within the ranges specified by the ‘Start Objective Check At Variable’ and ‘Stop Objective Check At Variable’ keywords. A result of the form OK or BAD? is printed by
lsq_gencon_deriv
to indicate whether or not each element appears to be correct. If a gradient element is determined to be extremely poor (i.e., if it appears to have no significant digits of accuracy at all), thenlsq_gencon_deriv
will also exit with an error indicator in argument .If , the action is the same as for , except that it will take place at the user-specified initial value of .
If or or , the default value is used.
We suggest that be used whenever a new function function is being developed.
- ‘Verify Constraint Gradients’valueless
These keywords refer to finite difference checks on the gradient elements computed by and . (Unspecified gradient elements are not checked.) The possible choices for are the following:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to .
Individual gradient elements will also be checked using a reliable (but more expensive) test.
It is possible to specify to in several ways. For example, the nonlinear objective gradient (if any) will be verified if either ‘Verify Objective Gradients’ or is specified. Similarly, the objective and the constraint gradients will be verified if or or ‘Verify’ is specified.
If , no checking will be performed.
If , gradients will be verified at the first point that satisfies the linear constraints and bounds.
If , only a ‘cheap’ test will be performed, requiring one call to and (if appropriate) one call to .
If , a more reliable (but more expensive) check will be made on individual gradient elements, within the ranges specified by the ‘Start Objective Check At Variable’ and ‘Stop Objective Check At Variable’ keywords. A result of the form OK or BAD? is printed by
lsq_gencon_deriv
to indicate whether or not each element appears to be correct. If a gradient element is determined to be extremely poor (i.e., if it appears to have no significant digits of accuracy at all), thenlsq_gencon_deriv
will also exit with an error indicator in argument .If , the action is the same as for , except that it will take place at the user-specified initial value of .
If or or , the default value is used.
We suggest that be used whenever a new function function is being developed.
- ‘Verify Gradients’valueless
These keywords refer to finite difference checks on the gradient elements computed by and . (Unspecified gradient elements are not checked.) The possible choices for are the following:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to .
Individual gradient elements will also be checked using a reliable (but more expensive) test.
It is possible to specify to in several ways. For example, the nonlinear objective gradient (if any) will be verified if either ‘Verify Objective Gradients’ or is specified. Similarly, the objective and the constraint gradients will be verified if or or ‘Verify’ is specified.
If , no checking will be performed.
If , gradients will be verified at the first point that satisfies the linear constraints and bounds.
If , only a ‘cheap’ test will be performed, requiring one call to and (if appropriate) one call to .
If , a more reliable (but more expensive) check will be made on individual gradient elements, within the ranges specified by the ‘Start Objective Check At Variable’ and ‘Stop Objective Check At Variable’ keywords. A result of the form OK or BAD? is printed by
lsq_gencon_deriv
to indicate whether or not each element appears to be correct. If a gradient element is determined to be extremely poor (i.e., if it appears to have no significant digits of accuracy at all), thenlsq_gencon_deriv
will also exit with an error indicator in argument .If , the action is the same as for , except that it will take place at the user-specified initial value of .
If or or , the default value is used.
We suggest that be used whenever a new function function is being developed.
- ‘Verify Objective Gradients’valueless
These keywords refer to finite difference checks on the gradient elements computed by and . (Unspecified gradient elements are not checked.) The possible choices for are the following:
Meaning
No checks are performed.
Only a ‘cheap’ test will be performed, requiring one call to .
Individual gradient elements will also be checked using a reliable (but more expensive) test.
It is possible to specify to in several ways. For example, the nonlinear objective gradient (if any) will be verified if either ‘Verify Objective Gradients’ or is specified. Similarly, the objective and the constraint gradients will be verified if or or ‘Verify’ is specified.
If , no checking will be performed.
If , gradients will be verified at the first point that satisfies the linear constraints and bounds.
If , only a ‘cheap’ test will be performed, requiring one call to and (if appropriate) one call to .
If , a more reliable (but more expensive) check will be made on individual gradient elements, within the ranges specified by the ‘Start Objective Check At Variable’ and ‘Stop Objective Check At Variable’ keywords. A result of the form OK or BAD? is printed by
lsq_gencon_deriv
to indicate whether or not each element appears to be correct. If a gradient element is determined to be extremely poor (i.e., if it appears to have no significant digits of accuracy at all), thenlsq_gencon_deriv
will also exit with an error indicator in argument .If , the action is the same as for , except that it will take place at the user-specified initial value of .
If or or , the default value is used.
We suggest that be used whenever a new function function is being developed.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, the equal bounds on are infinite, because and , but : and .
- (errno )
On entry, the bounds on are inconsistent: and .
- (errno )
On entry with a Warm Start, .
- (errno )
On entry, the equal bounds on variable are infinite, because and , but : and .
- (errno )
On entry, the equal bounds on linear constraint are infinite, because and , but : and .
- (errno )
On entry, the equal bounds on nonlinear constraint are infinite, because and , but : and .
- (errno )
On entry, the bounds on variable are inconsistent: and .
- (errno )
On entry, the bounds on linear constraint are inconsistent: and .
- (errno )
On entry, the bounds on nonlinear constraint are inconsistent: and .
- Warns
- NagAlgorithmicWarning
- (errno )
Optimal solution found, but requested accuracy not achieved.
- (errno )
No feasible point for the linear constraints.
- (errno )
No feasible point for the nonlinear constraints.
- (errno )
Too many major iterations.
- (errno )
Current point cannot be improved upon.
- (errno )
Large errors found in the derivatives.
- NagCallbackTerminateWarning
- (errno )
User requested termination by setting negative in or .
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
lsq_gencon_deriv
is designed to solve the nonlinear least squares programming problem – the minimization of a smooth nonlinear sum of squares function subject to a set of constraints on the variables. The problem is assumed to be stated in the following form:where (the objective function) is a nonlinear function which can be represented as the sum of squares of subfunctions , the are constant, is an constant matrix, and is an element vector of nonlinear constraint functions. (The matrix and the vector may be empty.) The objective function and the constraint functions are assumed to be smooth, i.e., at least twice-continuously differentiable. (The method of
lsq_gencon_deriv
will usually solve (1) if any isolated discontinuities are away from the solution.)Note that although the bounds on the variables could be included in the definition of the linear constraints, we prefer to distinguish between them for reasons of computational efficiency. For the same reason, the linear constraints should not be included in the definition of the nonlinear constraints. Upper and lower bounds are specified for all the variables and for all the constraints. An equality constraint can be specified by setting . If certain bounds are not present, the associated elements of or can be set to special values that will be treated as or . (See the description of the option ‘Infinite Bound Size’.)
You must supply an initial estimate of the solution to (1), together with functions that define , and as many first partial derivatives as possible; unspecified derivatives are approximated by finite differences.
The subfunctions are defined by the array and , and the nonlinear constraints are defined by . On every call, these functions must return appropriate values of and . You should also provide the available partial derivatives. Any unspecified derivatives are approximated by finite differences for a discussion of the option ‘Derivative Level’. Note that if there are any nonlinear constraints, then the first call to will precede the first call to .
For maximum reliability, it is preferable for you to provide all partial derivatives (see Module 8 of Gill et al. (1981) for a detailed discussion). If all gradients cannot be provided, it is similarly advisable to provide as many as possible. While developing and , the option ‘Verify’ should be used to check the calculation of any known gradients.
- References
Gill, P E, Murray, W and Wright, M H, 1981, Practical Optimization, Academic Press
Hock, W and Schittkowski, K, 1981, Test Examples for Nonlinear Programming Codes. Lecture Notes in Economics and Mathematical Systems (187), Springer–Verlag