naginterfaces.library.opt.handle_​set_​group

naginterfaces.library.opt.handle_set_group(handle, gtype, idgroup, group=None)[source]

handle_set_group is a part of the NAG optimization modelling suite and modifies a model by either adding a new, or replacing, or deleting an existing quadratic or rotated quadratic cone constraint.

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

https://www.nag.com/numeric/nl/nagdoc_28.7/flhtml/e04/e04rbf.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.

gtypestr

The type of the cone constraint. is case insensitive.

or

The group defines a quadratic cone.

or

The group defines a rotated quadratic cone.

idgroupint

A new cone constraint is created.

, the ID number of the existing constraint to be deleted or replaced.

groupNone or int, array-like, shape , optional

, the indices of the variables in the constraint. If , is not referenced.

Returns
idgroupint

If on entry, the ID number of the new cone constraint is returned. By definition, this is the number of cone constraints already defined plus one. Otherwise, remains 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 cone constraint already defined.

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: if or , or .

(errno )

On entry, and .

Constraint: if or , or .

(errno )

On entry, .

Constraint: , , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, for and .

Constraint: elements in cannot repeat.

Notes

After the has been initialized (e.g., handle_init() has been called), handle_set_group may be used to edit a model by adding, replacing, or deleting a cone constraint of dimension . The supported cones are quadratic cone and rotated quadratic cone, also known as second-order cones, which are defined as follows:

  • Quadratic cone:

  • Rotated quadratic cone:

The cone constraint is defined by its type and a subset (group) of variables. Let index set denote variable indices, then will denote the subvector of variables .

For example, if and , then a quadratic cone constraint

implies the inequality constraints

Typically, this function will be used to build Second-order Cone Programming (SOCP) problems which might be formulated in the following way:

where is either a quadratic cone or a rotated quadratic cone of dimension .

handle_set_group can be called repeatedly to add, replace or delete one cone constraint at a time. Note that it is also possible to temporarily disable and enable individual cone constraints in the model by calling handle_disable() and handle_enable(), respectively. See the E04 Introduction for more details about the NAG optimization modelling suite.