naginterfaces.library.opt.bounds_mod_deriv2_easy¶
- naginterfaces.library.opt.bounds_mod_deriv2_easy(ibound, funct2, hess2, bl, bu, x, data=None)[source]¶
bounds_mod_deriv2_easy
is an easy-to-use modified-Newton algorithm for finding a minimum of a function, subject to fixed upper and lower bounds on the independent variables, when first and second derivatives of are available. It is intended for functions which are continuous and 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 e04ly
https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/e04/e04lyf.html
- Parameters
- iboundint
Indicates 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 you are supplying all the and individually.
If there are no bounds on any .
If all the bounds are of the form .
If and .
- funct2callable (fc, gc) = funct2(xc, data=None)
You must supply this function to calculate the values of the function and its first derivatives at any point .
It should be tested separately before being used in conjunction with
bounds_mod_deriv2_easy
(see the E04 Introduction).- Parameters
- xcfloat, ndarray, shape
The point at which the function and its derivatives are required.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- fcfloat
The value of the function at the current point .
- gcfloat, array-like, shape
must be set to the value of the first derivative at the point , for .
- hess2callable (heslc, hesdc) = hess2(xc, lh, data=None)
You must supply this function to evaluate the elements of the matrix of second derivatives of at any point .
It should be tested separately before being used in conjunction with
bounds_mod_deriv2_easy
(see the E04 Introduction).- Parameters
- xcfloat, ndarray, shape
The point at which the derivatives are required.
- lhint
The length of the array .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- heslcfloat, array-like, shape
must place the strict lower triangle of the second derivative matrix in , stored by rows, i.e., set , for , for . (The upper triangle is not required because the matrix is symmetric.)
- hesdcfloat, array-like, shape
Must contain the diagonal elements of the second derivative matrix, i.e., set , for .
- blfloat, array-like, shape
The lower bounds .
If is set to , must be set to , for . (If a lower bound is not specified for any , the corresponding should be set to .)
If is set to , you must set to ;
bounds_mod_deriv2_easy
will then set the remaining elements of equal to .- bufloat, array-like, shape
The upper bounds .
If is set to , must be set to , for . (If an upper bound is not specified for any the corresponding should be set to .)
If is set to , you must set to ;
bounds_mod_deriv2_easy
will then set the remaining elements of equal to .- xfloat, array-like, shape
must be set to a guess at the th component of the position of the minimum, for . The function checks the gradient and the Hessian matrix at the starting point, and is more likely to detect any error in your programming if the initial are nonzero and mutually distinct.
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- blfloat, ndarray, shape
The lower bounds actually used by
bounds_mod_deriv2_easy
.- bufloat, ndarray, shape
The upper bounds actually used by
bounds_mod_deriv2_easy
.- xfloat, ndarray, shape
The lowest point found during the calculations. Thus, if no exception or warning is raised on exit, is the th component of the position of the minimum.
- ffloat
The value of corresponding to the final point stored in .
- gfloat, ndarray, shape
The value of corresponding to the final point stored in , for ; the value of for variables not on a bound 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 )
There have been function evaluations.
- (errno )
The modulus of a variable has become very large. There may be a mistake in your supplied functions, your problem has no finite solution, or the problem needs rescaling.
- Warns
- NagAlgorithmicWarning
- (errno )
The conditions for a minimum have not all been satisfied, but a lower point could not be found.
- (errno )
It is probable that a local minimum has been found, but it cannot be guaranteed.
- (errno )
It is possible that a local minimum has been found, but it cannot be guaranteed.
- (errno )
It is unlikely that a local minimum has been found.
- (errno )
It is very unlikely that a local minimum has been found.
- (errno )
It is very likely that you have made an error forming the gradient.
- (errno )
It is very likely that you have made an error forming the 2nd derivatives.
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
bounds_mod_deriv2_easy
is applicable to problems of the form:when first and second derivatives of are available.
Special provision is made for problems which actually have no bounds on the , problems which have only non-negativity bounds and problems in which and . You must supply a function to calculate the values of and its first derivatives at any point and a function to calculate the second derivatives.
From a starting point you supplied there is generated, on the basis of estimates of the curvature of , a sequence of feasible points which is intended to converge to a local minimum of the constrained function.
- References
Gill, P E and Murray, W, 1976, Minimization subject to bounds on the variables, NPL Report NAC 72, National Physical Laboratory