NAG Library Function Document
nag_opt_handle_set_linmatineq (e04rnc)
1 Purpose
nag_opt_handle_set_linmatineq (e04rnc) is a part of the NAG optimization modelling suite and defines one or more linear matrix constraints of the problem.
2 Specification
#include <nag.h> |
#include <nage04.h> |
void |
nag_opt_handle_set_linmatineq (void *handle,
Integer nvar,
Integer dima,
const Integer nnza[],
Integer nnzasum,
const Integer irowa[],
const Integer icola[],
const double a[],
Integer nblk,
const Integer blksizea[],
Integer *idblk,
NagError *fail) |
|
3 Description
After the initialization function
nag_opt_handle_init (e04rac) has been called, nag_opt_handle_set_linmatineq (e04rnc) may be used to add one or more linear matrix inequalities
to the problem definition. Here
are
by
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
(3)(b) in (BMI-SDP)
nag_opt_handle_set_linmatineq (e04rnc) can be called repeatedly to accumulate more matrix inequalities. See
nag_opt_handle_init (e04rac) for more details.
All the matrices
, for
, are symmetric and thus only their upper triangles are passed to the routine. They are stored in sparse coordinate storage format (see
Section 2.1.1 in the f11 Chapter 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:
irowa for row indices,
icola for column indices and
a 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
irowa,
icola and
a belongs to which
matrix. See
Table 1 and the example in
Section 9. See also
nag_opt_sdp_read_sdpa (e04rdc) which uses the same data organization.
irowa |
upper triangle |
upper triangle |
|
upper triangle
|
icola |
nonzeros |
nonzeros |
|
nonzeros |
a |
|
|
|
|
|
|
|
|
|
Table 1
Coordinate storage format of matrices in input arrays
There are two possibilities for defining more matrix inequality constraints
to the problem. The first is to call nag_opt_handle_set_linmatineq (e04rnc)
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 nag_opt_handle_set_linmatineq (e04rnc). 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,
nblk is set to
and
to
, the size of the
th diagonal blocks. This might be useful in connection with
nag_opt_sdp_read_sdpa (e04rdc).
On the other hand, if there is no block structure and just one matrix inequality is provided,
nblk should be set to
and
blksizea is not referenced.
3.2 Definition of Bilinear Matrix Inequalities (BMI)
nag_opt_handle_set_linmatineq (e04rnc) is designed to be used together with
nag_opt_handle_set_quadmatineq (e04rpc) to define bilinear matrix inequalities
(3)(b). nag_opt_handle_set_linmatineq (e04rnc) sets the linear part of the constraint and
nag_opt_handle_set_quadmatineq (e04rpc) expands it by higher order terms. To distinquish which linear matrix inequality (or more precisely, which block) is to be expanded,
nag_opt_handle_set_quadmatineq (e04rpc) needs the number of the block,
idblk. 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
idblk of the last inequality added.
idblk 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 nag_opt_handle_set_linmatineq (e04rnc) for the very first time with
, it adds
inequalities with
idblk 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.
4 References
None.
5 Arguments
- 1:
– void *Input
-
On entry: the handle to the problem. It needs to be initialized by
nag_opt_handle_init (e04rac) and
must not be changed.
- 2:
– IntegerInput
-
On entry:
, the number of decision variables
in the problem. It must be unchanged from the value set during the initialization of the handle by
nag_opt_handle_init (e04rac).
- 3:
– IntegerInput
-
On entry: , the dimension of the matrices
, for .
Constraint:
.
- 4:
– const IntegerInput
-
On entry: , 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.
Constraints:
- ;
- .
- 5:
– IntegerInput
-
On entry: the dimension of the arrays
irowa,
icola and
a, at least the total number of all nonzeros in all matrices
.
Constraints:
- ;
- .
- 6:
– const IntegerInput
- 7:
– const IntegerInput
- 8:
– const doubleInput
-
On entry: 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.
Constraints:
- , ;
- irowa and icola match the block diagonal pattern set by blksizea.
- 9:
– IntegerInput
-
On entry: , number of diagonal blocks in matrices. As explained above it is equivalent to the number of matrix inequalities supplied in this call.
Constraint:
.
- 10:
– const IntegerInput
-
On entry: if
, sizes
of the diagonal blocks.
If
,
blksizea is not referenced and may be
NULL.
Constraints:
- ;
- .
- 11:
– Integer *Input/Output
-
On entry: 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 C Library.
Constraint:
.
On exit: the number of the last matrix inequality added. By definition, it is the number of the matrix inequalities already defined plus
nblk.
- 12:
– NagError *Input/Output
-
The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_HANDLE
-
The supplied
handle does not define a valid handle to the data structure for the NAG optimization modelling suite. It has not been initialized by
nag_opt_handle_init (e04rac) or it has been corrupted.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
- NE_INT_ARRAY_1
-
On entry, and .
Constraint: .
On entry, .
Constraint: .
- NE_INT_ARRAY_2
-
On entry, and .
Constraint: .
- NE_INTARR_INT
-
On entry, and .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_INVALID_CS
-
An error occurred in matrix , (counting indices ).
On entry, , and .
Constraint: .
An error occurred in matrix , (counting indices ).
On entry, , and .
Constraint: .
An error occurred in matrix , (counting indices ).
On entry, , and .
Constraint: (elements within the upper triangle).
An error occurred in matrix
,
(counting indices
).
On entry,
,
and
. Maximum column index in this row given by the block structure defined by
blksizea is
.
Constraint: all elements of
must respect the block structure given by
blksizea.
An error occurred in matrix , (counting indices ).
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.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
- NE_PHASE
-
The problem cannot be modified in this phase any more, the solver has already been called.
- NE_REF_MATCH
-
On entry, .
Constraint: .
On entry,
, expected
.
Constraint:
nvar must match the value given during initialization of
handle.
7 Accuracy
Not applicable.
8 Parallelism and Performance
nag_opt_handle_set_linmatineq (e04rnc) is not threaded in any implementation.
The following example demonstrates how the elements of the
matrices are organized within the input arrays. Let us assume that there are two blocks defined (
). The first has dimension
by
(
) and the second
by
(
). For simplicity, the number of variables is
. Please note that the values were chosen to ease orientation rather than to define a valid problem.
Both inequalities will be passed in a single call to nag_opt_handle_set_linmatineq (e04rnc), therefore the matrices are merged into the following block diagonal form:
All matrices are symmetric and therefore only the upper triangles are passed to the function. The coordinate storage format is used. Note that elements within the same matrix do not need to be in any specific order. The table below shows one of the ways the arrays could be populated.
irowa |
|
|
|
icola |
|
|
|
a |
|
|
|
|
|
|
|
nnza |
|
|
|
10 Example
There are various problems which can be successfully reformulated and solved as an SDP problem. The following example shows how a maximization of the minimal eigenvalue of a matrix depending on certain parameters can be utilized in statistics.
For further examples, please refer to
Section 10 in nag_opt_handle_init (e04rac).
Given a series of
vectors of length
,
this example solves the SDP problem:
This formulation comes from an area of statistics called experimental design and corresponds to finding an approximate optimal design for a linear regression.
A linear regression model has the form:
where
is a vector of observed values,
is a design matrix of (known) independent variables and
is a vector of errors. In experimental design it is assumed that each row of
is chosen from a set of
possible vectors,
. The goal of experimental design is to choose the rows of
so that the error covariance is ‘small’. For an
optimal design this is defined as the
that maximizes the minimum eigenvalue of
.
In this example we construct the
optimal design for a polynomial regression model of the form:
where
.
10.1 Program Text
Program Text (e04rnce.c)
10.2 Program Data
Program Data (e04rnce.d)
10.3 Program Results
Program Results (e04rnce.r)