# naginterfaces.library.opt.handle_​set_​linmatineq¶

naginterfaces.library.opt.handle_set_linmatineq(handle, dima, nnza, irowa, icola, a, blksizea=None, idblk=0)[source]

handle_set_linmatineq is a part of the NAG optimization modelling suite and defines one or more linear matrix constraints of the problem.

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

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

dimaint

, the dimension of the matrices , for .

nnzaint, array-like, shape

, for , gives the number of nonzero elements in the upper triangle of matrix . To define as a zero matrix, set . However, there must be at least one matrix with at least one nonzero.

irowaint, array-like, shape

Nonzero elements in upper triangle of matrices stored in coordinate storage. The first elements belong to , the following elements belong to , etc. See explanation above.

icolaint, array-like, shape

Nonzero elements in upper triangle of matrices stored in coordinate storage. The first elements belong to , the following elements belong to , etc. See explanation above.

afloat, array-like, shape

Nonzero elements in upper triangle of matrices stored in coordinate storage. The first elements belong to , the following elements belong to , etc. See explanation above.

blksizeaNone or int, array-like, shape , optional

If , sizes of the diagonal blocks.

If , is not referenced.

idblkint, optional

If , new matrix inequalities are created. This is the only value allowed at the moment; nonzero values are reserved for future releases of the NAG Library.

Returns
idblkint

The number of the last matrix inequality added. By definition, it is the number of matrix inequalities already defined plus .

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

Constraint: must match the current number of variables of the model in the .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

An error occurred in matrix , .

On entry, , and .

Constraint: .

(errno )

An error occurred in matrix , .

On entry, , and .

Constraint: .

(errno )

An error occurred in matrix , .

On entry, , and .

Constraint: (elements within the upper triangle).

(errno )

An error occurred in matrix , .

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.

(errno )

An error occurred in matrix , .

On entry, , and . Maximum column index in this row given by the block structure defined by is .

Constraint: all elements of must respect the block structure given by .

Notes

After the initialization function handle_init() has been called, handle_set_linmatineq may be used to add one or more linear matrix inequalities

to the problem definition. Here are symmetric matrices. The expression stands for a constraint on eigenvalues of a symmetric matrix , namely, all the eigenvalues should be non-negative, i.e., the matrix should be positive semidefinite.

Typically, this will be used in linear semidefinite programming problems (SDP)

or to define the linear part of bilinear matrix inequalities [equation](b) in (BMI-SDP)

handle_set_linmatineq can be called repeatedly to accumulate more matrix inequalities. See the E04 Introduction for more details about the NAG optimization modelling suite.

Input data organization

All the matrices , for , are symmetric and thus only their upper triangles are passed to the function. They are stored in sparse coordinate storage format (see the F11 Introduction), i.e., every nonzero from the upper triangles is coded as a triplet of row index, column index and the numeric value. These triplets of all (upper triangle) nonzeros from all matrices are passed to the function in three arrays: for row indices, for column indices and for the values. No particular order of nonzeros within one matrix is enforced but all nonzeros from must be stored first, followed by all nonzero from , followed by , etc.

The number of stored nonzeros from each matrix is given in , thus this array indicates which section of arrays , and belongs to which matrix. See Table [label omitted] and the example in Further Comments. See also sdp_read_sdpa() which uses the same data organization.

 irowa upper triangle upper triangle upper triangle icola nonzeros nonzeros ⋯ nonzeros a from A0 from A1 from An nnza[0] nnza[1] nnza[n]

There are two possibilities for defining more matrix inequality constraints

to the problem. The first is to call handle_set_linmatineq times and define a single matrix inequality at a time. This might be more straightforward and, therefore, it is recommended. Alternatively, it is possible to merge all constraints into one inequality and pass them in a single call to handle_set_linmatineq. It is easy to see that (4) can be equivalently expressed as one bigger matrix inequality with the following block diagonal structure

If denotes the dimension of inequality , the new merged inequality has dimension and each of the matrices is formed by stored as diagonal blocks. In such a case, is set to and to , the size of the th diagonal blocks. This might be useful in connection with sdp_read_sdpa().

On the other hand, if there is no block structure and just one matrix inequality is provided, should be set to and is not referenced.

Definition of Bilinear Matrix Inequalities (BMI)

handle_set_linmatineq is designed to be used together with handle_set_quadmatineq() to define bilinear matrix inequalities [equation](b). handle_set_linmatineq sets the linear part of the constraint and handle_set_quadmatineq() expands it by higher order terms. To distinquish which linear matrix inequality (or more precisely, which block) is to be expanded, handle_set_quadmatineq() needs the number of the block, . The blocks are numbered as they are added, starting from .

Whenever a matrix inequality (or a set of them expressed as diagonal blocks) is stored, the function returns of the last inequality added. is just the order of the inequality amongst all matrix inequalities accumulated through the calls. The first inequality has , the second one , etc. Therefore, if you call handle_set_linmatineq for the very first time with , it adds inequalities with from to and the function returns (the number of the last one). A subsequent call with would add only one inequality, this time with which would be returned.