NAG CL Interface
e04rjc (handle_​set_​linconstr)

Settings help

CL Name Style:


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

#include <nag.h>
void  e04rjc (void *handle, Integer nclin, const double bl[], const double bu[], Integer nnzb, const Integer irowb[], const Integer icolb[], const double b[], Integer *idlc, NagError *fail)
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 mB linear constraints
lBBxuB  
where B is a general mB×n rectangular matrix, n is the current number of decision variables in the model and lB and uB are mB-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 jth constraint may be defined as an equality by setting lj=uj. If certain bounds are not present, the associated elements of lB or uB 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 bigbnd 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 Infinite Bound Size will not affect these constraints.
The linear constraints can be edited. To identify the individual constraints, they are numbered starting with 1, see idlc. A single constraint (i.e., a single row of the matrix B) can be modified (replaced) by e04rjc by referring to its idlc. An individual coefficient bij of the matrix B 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)
minimize xn cTx   (a) subject to   lBBxuB,   (b) lxxux ,   (c) (1)
Quadratic Programming (QP)
minimize xn 12 xTHx + cTx   (a) subject to   lBBxuB,   (b) lxxux ,   (c) (2)
Quadratically Constrained Quadratic Programming (QCQP)
minimize xn 12 xTHx + cTx   (a) subject to   12 xTQkx + rkTx + sk0 ,  k=1,,mQ ,   (b) lBBxuB,   (c) lxxux ,   (d) (3)
Nonlinear Programming (NLP)
minimize xn f(x)   (a) subject to lgg(x)ug,   (b) 12 xTQkx + rkTx + sk0 ,  k=1,,mQ ,   (c) lBBxuB,   (d) lxxux,   (e) (4)
or linear Semidefinite Programming (SDP)
minimize xn cTx   (a) subject to   i=1 n xi Aik - A0k 0 ,  k=1,,mA ,   (b) lBBxuB,   (c) lxxux.   (d) (5)
See Section 4.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

4 References

None.

5 Arguments

1: handle 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: nclin Integer Input
On entry: mB, the number of linear constraints (number of rows of the matrix B) in this block.
If nclin=0, no linear constraints will be added and bl, bu, nnzb, irowb, icolb and b will not be referenced and may be NULL.
Constraints:
  • nclin0;
  • if idlc>0, nclin=1.
3: bl[nclin] const double Input
4: bu[nclin] const double Input
On entry: bl and bu define lower and upper bounds of the linear constraints, lB and uB, respectively. To define the jth constraint as equality, set bl[j-1]=bu[j-1]=β, where |β|<bigbnd. To specify a nonexistent lower bound (i.e., lj=-), set bl[j-1]-bigbnd; to specify a nonexistent upper bound, set bu[j-1]bigbnd.
Constraints:
  • bl[j-1]bu[j-1], for j=1,2,,nclin;
  • bl[j-1]<bigbnd, for j=1,2,,nclin;
  • bu[j-1]>-bigbnd, for j=1,2,,nclin;
  • if bl[j-1]=bu[j-1], |bl[j-1]|<bigbnd, for j=1,2,,nclin.
5: nnzb Integer Input
On entry: nnzb gives the number of nonzeros in matrix B.
Constraint: nnzb0.
6: irowb[nnzb] const Integer Input
7: icolb[nnzb] const Integer Input
8: b[nnzb] const double Input
On entry: arrays irowb, icolb and b store nnzb nonzeros of the sparse matrix B in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). The matrix B has dimensions mB×n, where n 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 bij=b[l-1] where i=irowb[l-1] and j=icolb[l-1], for l=1,2,,nnzb. No particular order of elements is expected, but elements should not repeat.
Constraint: 1irowb[l-1]nclin, 1icolb[l-1]n, for l=1,2,,nnzb.
9: idlc Integer * Input/Output
On entry: if idlc=0, a new block of linear constraints is added to the model; otherwise, idlc>0 refers to the number of an existing linear constraint which will be replaced and nclin must be set to one.
Constraint: idlc0.
On exit: if idlc=0, the number of the last linear constraint added. By definition, it is the number of linear constraints already defined plus nclin. Otherwise, idlc>0 stays unchanged.
10: fail 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 value had an illegal value.
NE_BOUND
On entry, j=value, bl[j-1]=value, bigbnd=value.
Constraint: bl[j-1]<bigbnd.
On entry, j=value, bl[j-1]=value and bu[j-1]=value.
Constraint: bl[j-1]bu[j-1].
On entry, j=value, bu[j-1]=value, bigbnd=value.
Constraint: bu[j-1]>-bigbnd.
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, idlc=value and nclin=value.
Constraint: If idlc>0, nclin=1.
On entry, nclin=value.
Constraint: nclin0.
On entry, nnzb=value.
Constraint: nnzb0.
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, i=value, icolb[i-1]=value and n=value.
Constraint: 1icolb[i-1]n.
On entry, i=value, irowb[i-1]=value and nclin=value.
Constraint: 1irowb[i-1]nclin.
On entry, more than one element of b has row index value and column index value.
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, idlc=value.
Constraint: idlc0.
On entry, idlc=value.
The given idlc does not match with any existing linear constraint.
The maximum idlc is value.

7 Accuracy

Not applicable.

8 Parallelism and Performance

e04rjc is not threaded in any implementation.

9 Further Comments

9.1 Internal Changes

Internal changes have been made to this function as follows:
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:
minimize cT x + 12 xT H x   subject to   lB Bx uB, -2 Ax 2,  
where
c= ( -4.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -0.1 -0.3 ) ,   H= ( 2 1 1 1 1 0 0 0 0 1 2 1 1 1 0 0 0 0 1 1 2 1 1 0 0 0 0 1 1 1 2 1 0 0 0 0 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) ,  
B= ( 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 4.0 1.0 2.0 3.0 4.0 -2.0 1.0 1.0 1.0 1.0 1.0 -1.0 1.0 -1.0 1.0 1.0 1.0 1.0 1.0 ) ,  
lB= ( -2.0 -2.0 -2.0 )   and   uB= ( 1.5 1.5 4.0 ) .  
The optimal solution (to five figures) is
x*=(2.0,-0.23333,-0.26667,-0.3,-0.1,2.0,2.0,-1.7777,-0.45555)T.  
See also e04rac for links to further examples in this suite.

10.1 Program Text

Program Text (e04rjce.c)

10.2 Program Data

Program Options (e04rjce.opt)

10.3 Program Results

Program Results (e04rjce.r)