NAG Library Routine Document
e04rnf
(handle_set_linmatineq)
1
Purpose
e04rnf is a part of the NAG optimization modelling suite and defines one or more linear matrix constraints of the problem.
2
Specification
Fortran Interface
Subroutine e04rnf ( |
handle,
nvar,
dima,
nnza,
nnzasum,
irowa,
icola,
a,
nblk,
blksizea,
idblk,
ifail) |
Integer, Intent (In) | :: |
nvar,
dima,
nnza(nvar+1),
nnzasum,
irowa(nnzasum),
icola(nnzasum),
nblk,
blksizea(nblk) | Integer, Intent (Inout) | :: |
idblk,
ifail | Real (Kind=nag_wp), Intent (In) | :: |
a(nnzasum) | Type (c_ptr), Intent (In) | :: |
handle |
|
C Header Interface
#include nagmk26.h
void |
e04rnf_ (
void **handle,
const Integer *nvar,
const Integer *dima,
const Integer nnza[],
const Integer *nnzasum,
const Integer irowa[],
const Integer icola[],
const double a[],
const Integer *nblk,
const Integer blksizea[],
Integer *idblk,
Integer *ifail) |
|
3
Description
After the initialization routine
e04raf has been called,
e04rnf 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)
e04rnf can be called repeatedly to accumulate more matrix inequalities. See
e04raf 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 routine 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
e04rdf 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
e04rnf 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
e04rnf. 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
e04rdf.
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)
e04rnf is designed to be used together with
e04rpf to define bilinear matrix inequalities
(3)(b).
e04rnf sets the linear part of the constraint and
e04rpf expands it by higher order terms. To distinquish which linear matrix inequality (or more precisely, which block) is to be expanded,
e04rpf 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 routine 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
e04rnf for the very first time with
, it adds
inequalities with
idblk from
to
and the routine 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: – Type (c_ptr)Input
-
On entry: the handle to the problem. It needs to be initialized by
e04raf 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
e04raf.
- 3: – IntegerInput
-
On entry: , the dimension of the matrices
, for .
Constraint:
.
- 4: – Integer arrayInput
-
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: – Integer arrayInput
- 7: – Integer arrayInput
- 8: – Real (Kind=nag_wp) arrayInput
-
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: – Integer arrayInput
-
On entry: if
, sizes
of the diagonal blocks.
If
,
blksizea is not referenced.
Constraints:
- ;
- .
- 11: – IntegerInput/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 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: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
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
e04raf or it has been corrupted.
-
The problem cannot be modified in this phase any more, the solver has already been called.
-
On entry, .
Constraint: .
On entry,
, expected
.
Constraint:
nvar must match the value given during initialization of
handle.
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
-
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.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
e04rnf 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
e04rnf, 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 routine. 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
e04raf.
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 (e04rnfe.f90)
10.2
Program Data
Program Data (e04rnfe.d)
10.3
Program Results
Program Results (e04rnfe.r)