naginterfaces.library.opt.handle_​set_​nlnls

naginterfaces.library.opt.handle_set_nlnls(handle, nres, irowrd=None, icolrd=None)[source]

handle_set_nlnls is a part of the NAG optimization modelling suite and defines the residual functions for nonlinear regression problems (such as nonlinear least squares and general nonlinear data fitting) with the given number of residuals and, optionally, the sparsity structure of their first derivatives.

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

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e04/e04rmf.html

Parameters
handleHandle

The handle to the problem. It needs to be initialized (e.g., by handle_init()) and must not be changed between calls to the NAG optimization modelling suite.

nresint

, the number of residuals in the objective function.

If , no objective function will be defined and and will not be referenced.

irowrdNone or int, array-like, shape , optional

Arrays and store the sparsity structure (pattern) of the first derivative matrix as nonzeros in coordinate storage (CS) format (see the F11 Introduction). The matrix has dimensions . specifies one-based row indices and specifies one-based column indices. No particular order of elements is expected, but elements should not repeat and the same order should be used when the first derivative matrix is evaluated for the solver.

If and are both None then the first derivative matrix is considered dense and and will not be referenced.

The ordering is assumed to be column-wise, namely the function will behave as if and the vectors and filled as:

;

.

icolrdNone or int, array-like, shape , optional

Arrays and store the sparsity structure (pattern) of the first derivative matrix as nonzeros in coordinate storage (CS) format (see the F11 Introduction). The matrix has dimensions . specifies one-based row indices and specifies one-based column indices. No particular order of elements is expected, but elements should not repeat and the same order should be used when the first derivative matrix is evaluated for the solver.

If and are both None then the first derivative matrix is considered dense and and will not be referenced.

The ordering is assumed to be column-wise, namely the function will behave as if and the vectors and filled as:

;

.

Raises
NagValueError
(errno )

has not been initialized.

(errno )

does not belong to the NAG optimization modelling suite, has not been initialized properly or is corrupted.

(errno )

has not been initialized properly or is corrupted.

(errno )

The problem cannot be modified right now, the solver is running.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, more than one element of first derivative matrix has row index and column index .

Constraint: each element of first derivative matrix must have a unique row and column index.

Notes

After the has been initialized (e.g., handle_init() has been called), handle_set_nlnls may be used to define the residual functions in the objective function of nonlinear least squares or general nonlinear data fitting problems. If the objective function has already been defined, it will be overwritten. It will typically be used in data fitting or calibration problems of the form

where is an -dimensional variable vector, are nonlinear residuals (see the E04 Introduction), and is a type of loss function. For example, the model of a least squares problem can be written as

The values of the residuals, and possibly their derivatives, will be communicated to the solver by a user-supplied function. handle_set_nlnls also allows the structured first derivative matrix

to be declared as being dense or sparse. If declared as sparse, its sparsity structure must be specified by handle_set_nlnls. If handle_set_nlnls is called with , any existing objective function is removed, no new one is added and the problem will be solved as a feasible point problem. Note that it is possible to temporarily disable and enable individual residuals in the model by handle_disable() and handle_enable(), respectively.

See the E04 Introduction for more details about the NAG optimization modelling suite.