NAG Library Routine Document

e04rjf  (handle_set_linconstr)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

e04rjf is a part of the NAG optimization modelling suite and defines the block of linear constraints of the problem.

2
Specification

Fortran Interface
Subroutine e04rjf ( handle, nclin, bl, bu, nnzb, irowb, icolb, b, idlc, ifail)
Integer, Intent (In):: nclin, nnzb, irowb(nnzb), icolb(nnzb)
Integer, Intent (Inout):: idlc, ifail
Real (Kind=nag_wp), Intent (In):: bl(nclin), bu(nclin), b(nnzb)
Type (c_ptr), Intent (In):: handle
C Header Interface
#include nagmk26.h
void  e04rjf_ ( void **handle, const Integer *nclin, const double bl[], const double bu[], const Integer *nnzb, const Integer irowb[], const Integer icolb[], const double b[], Integer *idlc, Integer *ifail)

3
Description

After the initialization routine e04raf has been called, e04rjf may be used to define the linear constraints lBBxuB of the problem unless the linear constraints have already been defined. This will typically be used for problems, such as 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)
nonlinear programming (NLP)
minimize xn fx   (a) subject to lggxug   (b) lBBxuB   (c) lxxux   (d) (3)
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) (4)
where n is the number of decision variables, B is a general mB×n rectangular matrix and lB and uB are mB-dimensional vectors. Note that upper and lower bounds are specified for all the constraints. 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 routine and any later alterations to Infinite Bound Size will not affect these constraints.
See e04raf for more details.

4
References

None.

5
Arguments

1:     handle – Type (c_ptr)Input
On entry: the handle to the problem. It needs to be initialized by e04raf and must not be changed.
2:     nclin – IntegerInput
On entry: mB, the number of linear constraints (number of rows of the matrix B).
If nclin=0, no linear constraints will be defined and bl, bu, nnzb, irowb, icolb and b will not be referenced.
Constraint: nclin0.
3:     blnclin – Real (Kind=nag_wp) arrayInput
4:     bunclin – Real (Kind=nag_wp) arrayInput
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 blj=buj=β, where β<bigbnd. To specify a nonexistent lower bound (i.e., lj=-), set blj-bigbnd; to specify a nonexistent upper bound, set bujbigbnd.
Constraints:
  • bljbuj, for j=1,2,,nclin;
  • blj<bigbnd, for j=1,2,,nclin;
  • buj>-bigbnd, for j=1,2,,nclin;
  • if blj=buj, blj<bigbnd, for j=1,2,,nclin.
5:     nnzb – IntegerInput
On entry: nnzb gives the number of nonzeros in matrix B.
Constraint: if nclin>0, nnzb>0.
6:     irowbnnzb – Integer arrayInput
7:     icolbnnzb – Integer arrayInput
8:     bnnzb – Real (Kind=nag_wp) arrayInput
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, the number of variables in the problem, was set in nvar during the initialization of the handle by e04raf. 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=bl where i=irowbl and j=icolbl, for l=1,2,,nnzb. No particular order of elements is expected, but elements should not repeat.
Constraint: 1irowblnclin, 1icolbln, for l=1,2,,nnzb.
9:     idlc – IntegerInput/Output
Note: idlc is reserved for future releases of the NAG Library.
On entry: if idlc=0, new linear constraints are added to the problem definition. This is the only value allowed at the moment.
Constraint: idlc=0.
On exit: the number of the last linear constraint added, thus nclin.
10:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. 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 -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
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.
ifail=2
The problem cannot be modified in this phase any more, the solver has already been called.
ifail=3
A set of linear constraints has already been defined.
ifail=4
On entry, idlc=value.
Constraint: idlc=0.
ifail=6
On entry, nclin=value.
Constraint: nclin0.
On entry, nnzb=value.
Constraint: nnzb>0.
ifail=8
On entry, i=value, icolbi=value and n=value.
Constraint: 1icolbin.
On entry, i=value, irowbi=value and nclin=value.
Constraint: 1irowbinclin.
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.
ifail=10
On entry, j=value, blj=value, bigbnd=value.
Constraint: blj<bigbnd.
On entry, j=value, blj=value and buj=value.
Constraint: bljbuj.
On entry, j=value, buj=value, bigbnd=value.
Constraint: buj>-bigbnd.
ifail=-99
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.
ifail=-399
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.
ifail=-999
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

e04rjf is not threaded in any implementation.

9
Further Comments

None.

10
Example

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:
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.45555T.  
See also Section 10 in e04raf for links to further examples in this suite.

10.1
Program Text

Program Text (e04rjfe.f90)

10.2
Program Data

Program Options (e04rjfe.opt)

10.3
Program Results

Program Results (e04rjfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017