E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE04RJF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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

## 2  Specification

 SUBROUTINE E04RJF ( HANDLE, NCLIN, BL, BU, NNZB, IROWB, ICOLB, B, IDLC, IFAIL)
 INTEGER NCLIN, NNZB, IROWB(NNZB), ICOLB(NNZB), IDLC, IFAIL REAL (KIND=nag_wp) BL(NCLIN), BU(NCLIN), B(NNZB) TYPE (C_PTR) HANDLE

## 3  Description

After the initialization routine E04RAF has been called, E04RJF may be used to define the linear constraints ${l}_{B}\le Bx\le {u}_{B}$ of the problem unless the linear constraints have already been defined. This will typically be used for problems, such as quadratic programming (QP)
 $minimize x∈ℝn 12 xTHx + cTx (a) subject to lB≤Bx≤uB (b) lx≤x≤ux , (c)$ (1)
nonlinear programming (NLP)
 $minimize x∈ℝn fx (a) subject to lg≤gx≤ug (b) lB≤Bx≤uB (c) lx≤x≤ux (d)$ (2)
linear semidefinite programming (SDP)
 $minimize x∈ℝn cTx (a) subject to ∑ i=1 n xi Aik - A0k ⪰ 0 , k=1,…,mA (b) lB≤Bx≤uB (c) lx≤x≤ux (d)$ (3)
or semidefinite programming with bilinear matrix inequalities (BMI-SDP)
 $minimize x∈ℝn 12 xTHx + cTx (a) subject to ∑ i,j=1 n xi xj Qijk + ∑ i=1 n xi Aik - A0k ⪰ 0 , k=1,…,mA (b) lB≤Bx≤uB (c) lx≤x≤ux (d)$ (4)
where $n$ is the number of decision variables, $B$ is a general ${m}_{B}×n$ rectangular matrix and ${l}_{B}$ and ${u}_{B}$ are ${m}_{B}$-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 $j$th constraint may be defined as an equality by setting ${l}_{j}={u}_{j}$. If certain bounds are not present, the associated elements of ${l}_{B}$ or ${u}_{B}$ may be set to special values that are treated as $-\infty$ or $+\infty$. See the description of the optional parameter Infinite Bound Size of the solvers in the suite, E04STF and E04SVF. Its value is denoted as $\mathit{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.

None.

## 5  Arguments

1:     $\mathrm{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:     $\mathrm{NCLIN}$ – INTEGERInput
On entry: ${m}_{B}$, the number of linear constraints (number of rows of the matrix $B$).
If ${\mathbf{NCLIN}}=0$, no linear constraints will be defined and BL, BU, NNZB, IROWB, ICOLB and B will not be referenced.
Constraint: ${\mathbf{NCLIN}}\ge 0$.
3:     $\mathrm{BL}\left({\mathbf{NCLIN}}\right)$ – REAL (KIND=nag_wp) arrayInput
4:     $\mathrm{BU}\left({\mathbf{NCLIN}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: BL and BU define lower and upper bounds of the linear constraints, ${l}_{B}$ and ${u}_{B}$, respectively. To define the $j$th constraint as equality, set ${\mathbf{BL}}\left(j\right)={\mathbf{BU}}\left(j\right)=\beta$, where $\left|\beta \right|<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{BL}}\left(j\right)\le -\mathit{bigbnd}$; to specify a nonexistent upper bound, set ${\mathbf{BU}}\left(j\right)\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{BL}}\left(\mathit{j}\right)\le {\mathbf{BU}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NCLIN}}$;
• ${\mathbf{BL}}\left(\mathit{j}\right)<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NCLIN}}$;
• ${\mathbf{BU}}\left(\mathit{j}\right)>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NCLIN}}$;
• if ${\mathbf{BL}}\left(\mathit{j}\right)={\mathbf{BU}}\left(\mathit{j}\right)$, $\left|{\mathbf{BL}}\left(\mathit{j}\right)\right|<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{NCLIN}}$.
5:     $\mathrm{NNZB}$ – INTEGERInput
On entry: NNZB gives the number of nonzeros in matrix $B$.
Constraint: if ${\mathbf{NCLIN}}>0$, ${\mathbf{NNZB}}>0$.
6:     $\mathrm{IROWB}\left({\mathbf{NNZB}}\right)$ – INTEGER arrayInput
7:     $\mathrm{ICOLB}\left({\mathbf{NNZB}}\right)$ – INTEGER arrayInput
8:     $\mathrm{B}\left({\mathbf{NNZB}}\right)$ – 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 ${m}_{B}×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 ${b}_{ij}={\mathbf{B}}\left(l\right)$ where $i={\mathbf{IROWB}}\left(l\right)$ and $j={\mathbf{ICOLB}}\left(\mathit{l}\right)$, for $\mathit{l}=1,2,\dots ,{\mathbf{NNZB}}$. No particular order of elements is expected, but elements should not repeat.
Constraint: $1\le {\mathbf{IROWB}}\left(\mathit{l}\right)\le {\mathbf{NCLIN}}$, $1\le {\mathbf{ICOLB}}\left(\mathit{l}\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{NNZB}}$.
9:     $\mathrm{IDLC}$ – INTEGERInput/Output
Note: IDLC is reserved for future releases of the NAG Library.
On entry: if ${\mathbf{IDLC}}=0$, new linear constraints are added to the problem definition. This is the only value allowed at the moment.
Constraint: ${\mathbf{IDLC}}=0$.
On exit: the number of the last linear constraint added, thus NCLIN.
10:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ 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\text{​ 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 $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{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.
${\mathbf{IFAIL}}=2$
The problem cannot be modified in this phase any more, the solver has already been called.
${\mathbf{IFAIL}}=3$
A set of linear constraints has already been defined.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{IDLC}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IDLC}}=0$.
${\mathbf{IFAIL}}=6$
On entry, ${\mathbf{NCLIN}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NCLIN}}\ge 0$.
On entry, ${\mathbf{NNZB}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NNZB}}>0$.
${\mathbf{IFAIL}}=8$
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{ICOLB}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{ICOLB}}\left(\mathit{i}\right)\le n$.
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{IROWB}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{NCLIN}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{IROWB}}\left(\mathit{i}\right)\le {\mathbf{NCLIN}}$.
On entry, more than one element of B has row index $〈\mathit{\text{value}}〉$ and column index $〈\mathit{\text{value}}〉$.
Constraint: each element of B must have a unique row and column index.
${\mathbf{IFAIL}}=10$
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{BL}}\left(j\right)=〈\mathit{\text{value}}〉$, $\mathit{bigbnd}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{BL}}\left(j\right)<\mathit{bigbnd}$.
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{BL}}\left(j\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{BU}}\left(j\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{BL}}\left(j\right)\le {\mathbf{BU}}\left(j\right)$.
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{BU}}\left(j\right)=〈\mathit{\text{value}}〉$, $\mathit{bigbnd}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{BU}}\left(j\right)>-\mathit{bigbnd}$.
${\mathbf{IFAIL}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{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.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8  Parallelism and Performance

E04RJF is not threaded in any implementation.

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.$

### 10.1  Program Text

Program Text (e04rjfe.f90)

### 10.2  Program Data

Program Options (e04rjfe.opt)

### 10.3  Program Results

Program Results (e04rjfe.r)