e04rjf 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.
The routine may be called by the names e04rjf or nagf_opt_handle_set_linconstr.
3Description
After the handle has been initialized (e.g., e04raf has been called),
e04rjf 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 Infinite Bound Size 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 routine and any later alterations to Infinite Bound Size 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 e04rjf by referring to its idlc. An individual coefficient of the matrix can be set or modified by e04tjf and bounds of a single constraint can be set or modified by e04tdf. Note that it is also possible to temporarily disable and enable individual constraints in the model by e04tcfande04tbf, 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,
See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.
4References
None.
5Arguments
1: – Type (c_ptr)Input
On entry: the handle to the problem. It needs to be initialized (e.g., by e04raf) and must not be changed between calls to the NAG optimization modelling suite.
2: – IntegerInput
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.
Constraints:
;
if , .
3: – Real (Kind=nag_wp) arrayInput
4: – Real (Kind=nag_wp) arrayInput
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: – IntegerInput
On entry: nnzb gives the number of nonzeros in matrix .
Constraint:
.
6: – Integer arrayInput
7: – Integer arrayInput
8: – Real (Kind=nag_wp) arrayInput
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: – IntegerInput/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: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or 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).
6Error 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 properly initialized or it has been corrupted.
The problem cannot be modified right now, the solver is running.
On entry, . Constraint: .
On entry, . The given idlc does not match with any existing linear constraint. The maximum idlc is .
On entry, and . Constraint: If , .
On entry, .
Constraint: .
On entry, .
Constraint: .
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.
On entry, , , .
Constraint: .
On entry, , and .
Constraint: .
On entry, , , .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
Not applicable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e04rjf is not threaded in any implementation.
9Further Comments
9.1Internal Changes
Internal changes have been made to this routine 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. and 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.
10Example
This example demonstrates how to use the MPS file reader e04mxf and this suite of routines to define and solve a QP problem. e04mxf uses a different output format to the one required by e04rjf, 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 e04rjf as demonstrated in the example program.
The data file stores the following problem:
where
The optimal solution (to five figures) is
See also e04raf for links to further examples in this suite.