naginterfaces.library.opt.handle_​set_​qconstr

naginterfaces.library.opt.handle_set_qconstr(handle, s, idqc, idxr=None, r=None, irowq=None, icolq=None, q=None)[source]

handle_set_qconstr is a part of the NAG optimization modelling suite and defines a new, or edits an existing, quadratic objective function or constraint of the problem.

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

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/e04/e04rsf.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.

sfloat

The constant term in quadratic constraint.

If , will not be referenced.

idqcint

A new quadratic constraint is created.

Specifies the index of an existing constraint to be replaced. i.e., replaces the th constraint.

A new quadratic objective is created and will replace any previously defined objective function.

idxrNone or int, array-like, shape , optional

The nonzero elements of the sparse vector . must contain the index of in the vector, for . No particular order is expected, but elements should not repeat. Note that is the current number of variables in the problem.

rNone or float, array-like, shape , optional

The nonzero elements of the sparse vector . must contain the index of in the vector, for . No particular order is expected, but elements should not repeat. Note that is the current number of variables in the problem.

irowqNone or int, array-like, shape , optional

Arrays , and store the nonzeros of the upper triangle of the matrix in coordinate storage (CS) format (see the F11 Introduction). specifies one-based row indices, specifies one-based column indices and specifies the values of the nonzero elements in such a way that where , , for . No particular order is expected, but elements should not repeat.

icolqNone or int, array-like, shape , optional

Arrays , and store the nonzeros of the upper triangle of the matrix in coordinate storage (CS) format (see the F11 Introduction). specifies one-based row indices, specifies one-based column indices and specifies the values of the nonzero elements in such a way that where , , for . No particular order is expected, but elements should not repeat.

qNone or float, array-like, shape , optional

Arrays , and store the nonzeros of the upper triangle of the matrix in coordinate storage (CS) format (see the F11 Introduction). specifies one-based row indices, specifies one-based column indices and specifies the values of the nonzero elements in such a way that where , , for . No particular order is expected, but elements should not repeat.

Returns
idqcint

If on entry, then is overwritten with the index of the new quadratic constraint. By definition, this is the number of quadratic constraints already defined plus one. Otherwise, stays unchanged.

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, .

The given does not match with any quadratic constraint already defined.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

and cannot be zero at the same time.

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, more than one element of has index .

Constraint: each element of must have a unique index.

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: (elements within the upper triangle).

(errno )

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

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

Notes

After the has been initialized (e.g., handle_init() has been called), handle_set_qconstr may be used to edit a model by adding or replacing a quadratic objective function or constraint of the form

and

respectively. If a factor of such that is available, handle_set_qconstr_fac() should be called instead.

The matrix is a sparse symmetric matrix. Typically handle_set_qconstr would be used together with Second-order Cone Programming (SOCP) solver handle_solve_socp_ipm() if is positive semidefinite which implies the problem is convex. Otherwise, if the problem is nonconvex, a general nonlinear optimization solver (such as handle_solve_ipopt()) may be used. It is also acceptable if is a zero matrix, in which case the corresponding objective function or constraint becomes linear. Note that it is possible to temporarily disable and enable individual constraints in the model by handle_disable() and handle_enable(), respectively. See the E04 Introduction for more details about the NAG optimization modelling suite.