NAG CL Interface
e04rjc (handle_set_linconstr)
1
Purpose
e04rjc is a part of the NAG optimization modelling suite and adds a new block of linear constraints to the problem or modifies an individual linear constraint.
2
Specification
The function may be called by the names: e04rjc or nag_opt_handle_set_linconstr.
3
Description
After the
handle has been initialized (e.g.,
e04rac has been called),
e04rjc may be used to add to the problem a new block of
linear constraints
where
is a general
rectangular matrix,
is the current number of decision variables in the model and
and
are
-dimensional vectors defining the lower and upper bounds, respectively. The call can be repeated to add multiple blocks to the model.
Note that the bounds are specified for all the constraints of this block. This form allows full generality in specifying various types of constraint. In particular, the th constraint may be defined as an equality by setting . If certain bounds are not present, the associated elements of or may be set to special values that are treated as or . See the description of the optional parameter which is common among all solvers in the suite. Its value is denoted as further in this text. Note that the bounds are interpreted based on its value at the time of calling this function and any later alterations to will not affect these constraints.
The linear constraints can be edited. To identify the individual constraints, they are numbered starting with
, see
idlc. A single constraint (i.e., a single row of the matrix
) can be modified (replaced) by
e04rjc by referring to its
idlc. An individual coefficient
of the matrix
can be set or modified by
e04tjc and bounds of a single constraint can be set or modified by
e04tdc. Note that it is also possible to temporarily disable and enable individual constraints in the model by
e04tcc and
e04tbc, respectively.
Linear constraints may be present in many different types of problems, for simplicity of the notation, only one block of linear constraints is presented. For example,
Linear Programming (LP)
Quadratic Programming (QP)
Quadratically Constrained Quadratic Programming (QCQP)
Nonlinear Programming (NLP)
or linear
Semidefinite Programming (SDP)
See
Section 4.1 in the
E04 Chapter Introduction for more details about the NAG optimization modelling suite.
4
References
None.
5
Arguments
-
1:
– void *
Input
-
On entry: the handle to the problem. It needs to be initialized (e.g., by
e04rac) and
must not be changed between calls to the NAG optimization modelling suite.
-
2:
– Integer
Input
-
On entry:
, the number of linear constraints (number of rows of the matrix
) in this block.
If
, no linear constraints will be added and
bl,
bu,
nnzb,
irowb,
icolb and
b will not be referenced and may be
NULL.
Constraints:
- ;
- if , .
-
3:
– const double
Input
-
4:
– const double
Input
-
On entry:
bl and
bu define lower and upper bounds of the linear constraints,
and
, respectively. To define the
th constraint as equality, set
, where
. To specify a nonexistent lower bound (i.e.,
), set
; to specify a nonexistent upper bound, set
.
Constraints:
- , for ;
- , for ;
- , for ;
- if , , for .
-
5:
– Integer
Input
-
On entry:
nnzb gives the number of nonzeros in matrix
.
Constraint:
.
-
6:
– const Integer
Input
-
7:
– const Integer
Input
-
8:
– const double
Input
-
On entry: arrays
irowb,
icolb and
b store
nnzb nonzeros of the sparse matrix
in coordinate storage (CS) format (see
Section 2.1.1 in the
F11 Chapter Introduction). The matrix
has dimensions
, where
is the current number of decision variables in the model.
irowb specifies one-based row indices,
icolb specifies one-based column indices and
b specifies the values of the nonzero elements in such a way that
where
and
, for
. No particular order of elements is expected, but elements should not repeat.
Constraint:
, , for .
-
9:
– Integer *
Input/Output
-
On entry: if
, a new block of linear constraints is added to the model; otherwise,
refers to the number of an existing linear constraint which will be replaced and
nclin must be set to one.
Constraint:
.
On exit: if
, the number of the last linear constraint added. By definition, it is the number of linear constraints already defined plus
nclin. Otherwise,
stays unchanged.
-
10:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_BOUND
-
On entry, , , .
Constraint: .
On entry, , and .
Constraint: .
On entry, , , .
Constraint: .
- 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 properly initialized or it has been corrupted.
- NE_INT
-
On entry, and .
Constraint: If , .
On entry, .
Constraint: .
On entry, .
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.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_INVALID_CS
-
On entry, , and .
Constraint: .
On entry, , and .
Constraint: .
On entry, more than one element of
b has row index
and column index
.
Constraint: each element of
b 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 8 in the Introduction to the NAG Library CL Interface for further information.
- NE_PHASE
-
The problem cannot be modified right now, the solver is running.
- NE_REF_MATCH
-
On entry, .
Constraint: .
On entry,
.
The given
idlc does not match with any existing linear constraint.
The maximum
idlc is
.
7
Accuracy
Not applicable.
8
Parallelism and Performance
e04rjc is not threaded in any implementation.
9.1
Internal Changes
Internal changes have been made to this function as follows:
- At Mark 27.1: Previously, it was not possible to define more than one block of the linear constraints, modify the constraints or to edit the model once a solver had been called. These limitations have been removed and the associated error codes were removed. NE_REF_MATCH and NE_INT have been extended to reflect the new use of idlc.
For details of all known issues which have been reported for the NAG Library please refer to the
Known Issues.
10
Example
This example demonstrates how to use the MPS file reader
e04mxc and this suite of functions to define and solve a QP problem.
e04mxc uses a different output format to the one required by
e04rjc, in particular, it uses the compressed column storage (CCS) (see
Section 2.1.3 in the
F11 Chapter Introduction) instead of the coordinate storage and the linear objective vector is included in the system matrix. Therefore, a simple transformation is needed before calling
e04rjc as demonstrated in the example program.
The data file stores the following problem:
where
The optimal solution (to five figures) is
See also
e04rac for links to further examples in this suite.
10.1
Program Text
10.2
Program Data
10.3
Program Results