naginterfaces.library.opt.bounds_​mod_​deriv_​comp

naginterfaces.library.opt.bounds_mod_deriv_comp(funct, monit, eta, ibound, bl, bu, x, lh, iprint=1, maxcal=None, xtol=0.0, delta=0.0, stepmx=100000.0, data=None, io_manager=None)[source]

bounds_mod_deriv_comp is a comprehensive modified Newton algorithm for finding:

  • an unconstrained minimum of a function of several variables;

  • a minimum of a function of several variables subject to fixed upper and/or lower bounds on the variables.

First derivatives are required. The function is intended for functions which have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities).

For full information please refer to the NAG Library document for e04kd

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/e04/e04kdf.html

Parameters
functcallable (fc, gc) = funct(iflag, xc, data=None)

must evaluate the function and its first derivatives at a specified point. (However, if you do not wish to calculate or its first derivatives at a particular , there is the option of setting an argument to cause bounds_mod_deriv_comp to terminate immediately.)

Parameters
iflagint

Will have been set to or . The value indicates that only the first derivatives of need be supplied, and the value indicates that both itself and its first derivatives must be calculated.

xcfloat, ndarray, shape

The point at which the , or and the , are required.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
fcfloat

Unless on entry, must set to the value of the objective function at the current point .

gcfloat, array-like, shape

must set to the value of the first derivative at the point , for .

monitcallable monit(xc, fc, gc, istate, gpjnrm, cond, posdef, niter, nf, data=None)

If , you must supply which is suitable for monitoring the minimization process. must not change the values of any of its arguments.

If , a with the correct argument list must still be supplied, although it will not be called.

Parameters
xcfloat, ndarray, shape

The coordinates of the current point .

fcfloat

The value of at the current point .

gcfloat, ndarray, shape

The value of at the current point , for .

istateint, ndarray, shape

Information about which variables are currently fixed on their bounds and which are free.

If is negative, is currently:

  • fixed on its upper bound if

  • fixed on its lower bound if

  • effectively a constant (i.e., ) if

If is positive, its value gives the position of in the sequence of free variables.

gpjnrmfloat

The Euclidean norm of the current projected gradient vector .

condfloat

The ratio of the largest to the smallest elements of the diagonal factor of the approximated projected Hessian matrix. This quantity is usually a good estimate of the condition number of the projected Hessian matrix. (If no variables are currently free, is set to zero.)

posdefbool

Specifies or according to whether or not the approximation to the second derivative matrix for the current subspace, , is positive definite.

niterint

The number of iterations (as outlined in Notes) which have been performed by bounds_mod_deriv_comp so far.

nfint

The number of evaluations of so far, i.e., the number of calls of with set to . Each such call of also calculates the first derivatives of . (In addition to these calls monitored by , is called with set to not more than times per iteration.)

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

etafloat

Every iteration of bounds_mod_deriv_comp involves a linear minimization (i.e., minimization of with respect to ). specifies how accurately these linear minimizations are to be performed. The minimum with respect to will be located more accurately for small values of (say, ) than large values (say, ).

Although accurate linear minimizations will generally reduce the number of iterations (and hence the number of calls of to estimate the second derivatives), they will tend to increase the number of calls of needed for each linear minimization.

On balance, it is usually more efficient to perform a low accuracy linear minimization when is small and a high accuracy minimization when is large.

Suggested value:

if

if

if

If , eta should be set to (also when the problem is effectively one-dimensional even though ; i.e., if for all except one of the variables the lower and upper bounds are equal).

iboundint

Indicates whether the problem is unconstrained or bounded. If there are bounds on the variables, can be used to indicate whether the facility for dealing with bounds of special forms is to be used. It must be set to one of the following values:

If the variables are bounded and you are supplying all the and individually.

If the problem is unconstrained.

If the variables are bounded, but all the bounds are of the form .

If all the variables are bounded, and and .

If the problem is unconstrained. (The option is provided for consistency with other functions. In bounds_mod_deriv_comp it produces the same effect as )

blfloat, array-like, shape

The fixed lower bounds .

If is set to , you must set to , for . (If a lower bound is not specified for any , the corresponding should be set to a large negative number, e.g., .)

If is set to , you must set to ; bounds_mod_deriv_comp will then set the remaining elements of equal to .

If is set to , or , will be initialized by bounds_mod_deriv_comp.

bufloat, array-like, shape

The fixed upper bounds .

If is set to , you must set to , for . (If an upper bound is not specified for any variable, the corresponding should be set to a large positive number, e.g., .)

If is set to , you must set to ; bounds_mod_deriv_comp will then set the remaining elements of equal to .

If is set to , or , will be initialized by bounds_mod_deriv_comp.

xfloat, array-like, shape

must be set to a guess at the th component of the position of the minimum, for .

lhint

The dimension of the array .

iprintint, optional

The frequency with which is to be called.

is called once every iterations and just before exit from bounds_mod_deriv_comp.

is just called at the final point.

is not called at all.

should normally be set to a small positive number.

maxcalNone or int, optional

Note: if this argument is None then a default value will be used, determined as follows: .

The maximum permitted number of evaluations of , i.e., the maximum permitted number of calls of with set to . It should be borne in mind that, in addition to the calls of which are limited directly by , there will be calls of (with set to ) to evaluate only first derivatives.

xtolfloat, optional

The accuracy in to which the solution is required.

If is the true value of at the minimum, then , the estimated position before a normal exit, is such that where .

For example, if the elements of are not much larger than in modulus, and if is set to , then is usually accurate to about five decimal places. (For further details see Accuracy.)

If the problem is scaled as described in Further Comments and is the machine precision, then is probably the smallest reasonable choice for .

This is because, normally, to machine accuracy, , for any where is the th column of the identity matrix.

If you set to (or any positive value less than ), bounds_mod_deriv_comp will use instead of .

deltafloat, optional

The differencing interval to be used for approximating the second derivatives of . Thus, for the finite difference approximations, the first derivatives of are evaluated at points which are apart. If is the machine precision, will usually be a suitable setting for . If you set to (or to any positive value less than ), bounds_mod_deriv_comp will automatically use as the differencing interval.

stepmxfloat, optional

An estimate of the Euclidean distance between the solution and the starting point supplied by you. (For maximum efficiency a slight overestimate is preferable.)

bounds_mod_deriv_comp will ensure that, for each iteration,

where is the iteration number.

Thus, if the problem has more than one solution, bounds_mod_deriv_comp is most likely to find the one nearest to the starting point.

On difficult problems, a realistic choice can prevent the sequence of entering a region where the problem is ill-behaved and can also help to avoid possible overflow in the evaluation of .

However, an underestimate of can lead to inefficiency.

dataarbitrary, optional

User-communication data for callback functions.

io_managerFileObjManager, optional

Manager for I/O in this routine.

Returns
blfloat, ndarray, shape

The lower bounds actually used by bounds_mod_deriv_comp, e.g., if , .

bufloat, ndarray, shape

The upper bounds actually used by bounds_mod_deriv_comp, e.g., if , .

xfloat, ndarray, shape

The final point . Thus, if no exception or warning is raised on exit, is the th component of the estimated position of the minimum.

heslfloat, ndarray, shape

During the determination of a direction (see Notes), is decomposed into the product , where is a unit lower triangular matrix and is a diagonal matrix. (The matrices , , and are all of dimension , where is the number of variables free from their bounds. consists of those rows and columns of the full estimated second derivative matrix which relate to free variables. is chosen so that is positive definite.)

and are used to store the factors and .

The elements of the strict lower triangle of are stored row by row in the first positions of .

The diagonal elements of are stored in the first positions of .

In the last factorization before a normal exit, the matrix will be zero, so that and will contain, on exit, the factors of the final estimated second derivative matrix .

The elements of are useful for deciding whether to accept the results produced by bounds_mod_deriv_comp (see Accuracy).

hesdfloat, ndarray, shape

During the determination of a direction (see Notes), is decomposed into the product , where is a unit lower triangular matrix and is a diagonal matrix. (The matrices , , and are all of dimension , where is the number of variables free from their bounds. consists of those rows and columns of the full estimated second derivative matrix which relate to free variables. is chosen so that is positive definite.)

and are used to store the factors and .

The elements of the strict lower triangle of are stored row by row in the first positions of .

The diagonal elements of are stored in the first positions of .

In the last factorization before a normal exit, the matrix will be zero, so that and will contain, on exit, the factors of the final estimated second derivative matrix .

The elements of are useful for deciding whether to accept the results produced by bounds_mod_deriv_comp (see Accuracy).

istateint, ndarray, shape

Information about which variables are currently on their bounds and which are free. If is:

  • equal to , is fixed on its upper bound;

  • equal to , is fixed on its lower bound;

  • equal to , is effectively a constant (i.e., );

  • positive, gives the position of in the sequence of free variables.

ffloat

The function value at the final point given in .

gfloat, ndarray, shape

The first derivative vector corresponding to the final point given in . The components of corresponding to free variables should normally be close to zero.

Raises
NagValueError
(errno )

On entry, and for some .

(errno )

On entry, and .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

There have been function evaluations.

(errno )

The conditions for a minimum have not all been satisfied, but a lower point could not be found.

(errno )

No further progress can be made.

NagCallbackTerminateWarning
(errno )

User requested termination by setting negative in .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

bounds_mod_deriv_comp is applicable to problems of the form:

Special provision is made for unconstrained minimization (i.e., problems which actually have no bounds on the ), problems which have only non-negativity bounds, and problems in which and . It is possible to specify that a particular should be held constant. You must supply a starting point, and a to calculate the value of and its first derivatives at any point .

A typical iteration starts at the current point where (say) variables are free from their bounds. The vector , whose elements are the derivatives of with respect to the free variables, is known. The matrix of second derivatives with respect to the free variables, , is estimated by finite differences. (Note that and are both of dimension .) The equations

are solved to give a search direction . (The matrix is chosen so that is positive definite.)

is then expanded to an -vector by the insertion of appropriate zero elements, is found such that is approximately a minimum (subject to the fixed bounds) with respect to ; and is replaced by . (If a saddle point is found, a special search is carried out so as to move away from the saddle point.) If any variable actually reaches a bound, it is fixed and is reduced for the next iteration.

There are two sets of convergence criteria – a weaker and a stronger. Whenever the weaker criteria are satisfied, the Lagrange multipliers are estimated for all the active constraints. If any Lagrange multiplier estimate is significantly negative, then one of the variables associated with a negative Lagrange multiplier estimate is released from its bound and the next search direction is computed in the extended subspace (i.e., is increased). Otherwise minimization continues in the current subspace until the stronger convergence criteria are satisfied. If at this point there are no negative or near-zero Lagrange multiplier estimates, the process is terminated.

If you specify that the problem is unconstrained, bounds_mod_deriv_comp sets the to and the to . Thus, provided that the problem has been sensibly scaled, no bounds will be encountered during the minimization process and bounds_mod_deriv_comp will act as an unconstrained minimization algorithm.

References

Gill, P E and Murray, W, 1973, Safeguarded steplength algorithms for optimization using descent methods, NPL Report NAC 37, National Physical Laboratory

Gill, P E and Murray, W, 1974, Newton-type methods for unconstrained and linearly constrained optimization, Math. Programming (7), 311–350

Gill, P E and Murray, W, 1976, Minimization subject to bounds on the variables, NPL Report NAC 72, National Physical Laboratory