# NAG CPP Interfacenagcpp::opt::handle_set_linconstr (e04rj)

Settings help

CPP Name Style:

## 1Purpose

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

## 2Specification

```#include "e04/nagcpp_e04rj.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
```
```template <typename COMM, typename BL, typename BU, typename IROWB, typename ICOLB, typename B>

void function handle_set_linconstr(COMM &comm, const BL &bl, const BU &bu, const IROWB &irowb, const ICOLB &icolb, const B &b, OptionalE04RJ opt)```
```template <typename COMM, typename BL, typename BU, typename IROWB, typename ICOLB, typename B>

void function handle_set_linconstr(COMM &comm, const BL &bl, const BU &bu, const IROWB &irowb, const ICOLB &icolb, const B &b)```

## 3Description

After the handle has been initialized (e.g., handle_​init has been called), handle_set_linconstr may be used to add to the problem a new block of ${m}_{B}$ linear constraints
 $lB≤Bx≤uB$
where $B$ is a general ${m}_{B}×n$ rectangular matrix, $n$ is the current number of decision variables in the model and ${l}_{B}$ and ${u}_{B}$ are ${m}_{B}$-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 $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 which is common among all solvers in the suite. 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 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 handle_set_linconstr by referring to its idlc. An individual coefficient ${b}_{\mathrm{ij}}$ of the matrix $B$ can be set or modified by e04tjf (no CPP interface) and bounds of a single constraint can be set or modified by e04tdf (no CPP interface). Note that it is also possible to temporarily disable and enable individual constraints in the model by e04tcf (no CPP interface) and e04tbf (no CPP interface), 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 x∈ℝn cTx (a) subject to lB≤Bx≤uB, (b) lx≤x≤ux , (c)$ (1)
 $minimize x∈ℝn 12 xTHx + cTx (a) subject to lB≤Bx≤uB, (b) lx≤x≤ux , (c)$ (2)
 $minimize x∈ℝn 12 xTHx + cTx (a) subject to 12 xTQkx + rkTx + sk≤0 , k=1,…,mQ , (b) lB≤Bx≤uB, (c) lx≤x≤ux , (d)$ (3)
Nonlinear Programming (NLP)
 $minimize x∈ℝn f(x) (a) subject to lg≤g(x)≤ug, (b) 12 xTQkx + rkTx + sk≤0 , k=1,…,mQ , (c) lB≤Bx≤uB, (d) lx≤x≤ux, (e)$ (4)
or 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)$ (5)
See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

## 5Arguments

1: $\mathbf{comm}$CommE04RA Input/Output
Communication structure. An object of either the derived class CommE04RA or its base class NoneCopyableComm can be supplied. It is recommended that the derived class is used. If the base class is supplied it must first be initialized via a call to opt::handle_init (e04ra).
2: $\mathbf{bl}\left({\mathbf{nclin}}\right)$double array Input
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-1\right)={\mathbf{bu}}\left(j-1\right)=\beta$, where $|\beta |<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left(j-1\right)\le -\mathit{bigbnd}$; to specify a nonexistent upper bound, set ${\mathbf{bu}}\left(j-1\right)\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{bl}}\left(\mathit{j}-1\right)\le {\mathbf{bu}}\left(\mathit{j}-1\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• ${\mathbf{bl}}\left(\mathit{j}-1\right)<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• ${\mathbf{bu}}\left(\mathit{j}-1\right)>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• if ${\mathbf{bl}}\left(\mathit{j}-1\right)={\mathbf{bu}}\left(\mathit{j}-1\right)$, $|{\mathbf{bl}}\left(\mathit{j}-1\right)|<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$.
3: $\mathbf{bu}\left({\mathbf{nclin}}\right)$double array Input
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-1\right)={\mathbf{bu}}\left(j-1\right)=\beta$, where $|\beta |<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left(j-1\right)\le -\mathit{bigbnd}$; to specify a nonexistent upper bound, set ${\mathbf{bu}}\left(j-1\right)\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{bl}}\left(\mathit{j}-1\right)\le {\mathbf{bu}}\left(\mathit{j}-1\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• ${\mathbf{bl}}\left(\mathit{j}-1\right)<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• ${\mathbf{bu}}\left(\mathit{j}-1\right)>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$;
• if ${\mathbf{bl}}\left(\mathit{j}-1\right)={\mathbf{bu}}\left(\mathit{j}-1\right)$, $|{\mathbf{bl}}\left(\mathit{j}-1\right)|<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nclin}}$.
4: $\mathbf{irowb}\left({\mathbf{nnzb}}\right)$types::f77_integer array 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 ${m}_{B}×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 ${b}_{ij}={\mathbf{b}}\left(l-1\right)$ where $i={\mathbf{irowb}}\left(l-1\right)$ and $j={\mathbf{icolb}}\left(\mathit{l}-1\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}-1\right)\le {\mathbf{nclin}}$, $1\le {\mathbf{icolb}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzb}}$.
5: $\mathbf{icolb}\left({\mathbf{nnzb}}\right)$types::f77_integer array 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 ${m}_{B}×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 ${b}_{ij}={\mathbf{b}}\left(l-1\right)$ where $i={\mathbf{irowb}}\left(l-1\right)$ and $j={\mathbf{icolb}}\left(\mathit{l}-1\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}-1\right)\le {\mathbf{nclin}}$, $1\le {\mathbf{icolb}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzb}}$.
6: $\mathbf{b}\left({\mathbf{nnzb}}\right)$double array 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 ${m}_{B}×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 ${b}_{ij}={\mathbf{b}}\left(l-1\right)$ where $i={\mathbf{irowb}}\left(l-1\right)$ and $j={\mathbf{icolb}}\left(\mathit{l}-1\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}-1\right)\le {\mathbf{nclin}}$, $1\le {\mathbf{icolb}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzb}}$.
7: $\mathbf{opt}$OptionalE04RJ Input/Output
Optional parameter container, derived from Optional.
Container for:
idlctypes::f77_integer
This optional parameter may be set using the method OptionalE04RJ::idlc and accessed via OptionalE04RJ::get_idlc.
Default: $0$
On entry: if ${\mathbf{idlc}}=0$, a new block of linear constraints is added to the model; otherwise, ${\mathbf{idlc}}>0$ refers to the number of an existing linear constraint which will be replaced and nclin must be set to one.
Constraint: ${\mathbf{idlc}}\ge 0$.
On exit: if ${\mathbf{idlc}}=0$, the number of the last linear constraint added. By definition, it is the number of linear constraints already defined plus nclin. Otherwise, ${\mathbf{idlc}}>0$ stays unchanged.

1: $\mathbf{nclin}$
${m}_{B}$, the number of linear constraints (number of rows of the matrix $B$) in this block.
2: $\mathbf{nnzb}$
nnzb gives the number of nonzeros in matrix $B$

## 6Exceptions and Warnings

Errors or warnings detected by the function:
All errors and warnings have an associated numeric error code field, errorid, stored either as a member of the thrown exception object (see errorid), or as a member of opt.ifail, depending on how errors and warnings are being handled (see Error Handling for more details).
Raises: ErrorException
$\mathbf{errorid}=1$
comm::handle has not been initialized.
$\mathbf{errorid}=1$
comm::handle does not belong to the NAG optimization modelling suite,
has not been initialized properly or is corrupted.
$\mathbf{errorid}=1$
comm::handle has not been initialized properly or is corrupted.
$\mathbf{errorid}=2$
The problem cannot be modified right now, the solver is running.
$\mathbf{errorid}=4$
On entry, ${\mathbf{idlc}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{idlc}}\ge 0$.
$\mathbf{errorid}=4$
On entry, ${\mathbf{idlc}}=⟨\mathit{value}⟩$.
The given idlc does not match with any existing linear constraint.
The maximum idlc is $⟨\mathit{\text{value}}⟩$.
$\mathbf{errorid}=6$
On entry, ${\mathbf{nnzb}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{nnzb}}\ge 0$.
$\mathbf{errorid}=6$
On entry, ${\mathbf{nclin}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{nclin}}\ge 0$.
$\mathbf{errorid}=6$
On entry, ${\mathbf{idlc}}=⟨\mathit{value}⟩$ and ${\mathbf{nclin}}=⟨\mathit{value}⟩$.
Constraint: If ${\mathbf{idlc}}>0$, ${\mathbf{nclin}}=1$.
$\mathbf{errorid}=8$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{irowb}}\left[i-1\right]=⟨\mathit{value}⟩$ and
${\mathbf{nclin}}=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{irowb}}\left[i-1\right]\le {\mathbf{nclin}}$.
$\mathbf{errorid}=8$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{icolb}}\left[i-1\right]=⟨\mathit{value}⟩$ and
$n=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{icolb}}\left[i-1\right]\le n$.
$\mathbf{errorid}=8$
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{errorid}=10$
On entry, $j=⟨\mathit{value}⟩$, ${\mathbf{bl}}\left[j-1\right]=⟨\mathit{value}⟩$ and
${\mathbf{bu}}\left[j-1\right]=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{bl}}\left[j-1\right]\le {\mathbf{bu}}\left[j-1\right]$.
$\mathbf{errorid}=10$
On entry, $j=⟨\mathit{value}⟩$, ${\mathbf{bl}}\left[j-1\right]=⟨\mathit{value}⟩$,
$\mathit{bigbnd}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{bl}}\left[j-1\right]<\mathit{bigbnd}$.
$\mathbf{errorid}=10$
On entry, $j=⟨\mathit{value}⟩$, ${\mathbf{bu}}\left[j-1\right]=⟨\mathit{value}⟩$,
$\mathit{bigbnd}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{bu}}\left[j-1\right]>-\mathit{bigbnd}$.
$\mathbf{errorid}=10601$
On entry, argument $⟨\mathit{\text{value}}⟩$ must be a vector of size $⟨\mathit{\text{value}}⟩$ array.
Supplied argument has $⟨\mathit{\text{value}}⟩$ dimensions.
$\mathbf{errorid}=10601$
On entry, argument $⟨\mathit{\text{value}}⟩$ must be a vector of size $⟨\mathit{\text{value}}⟩$ array.
Supplied argument was a vector of size $⟨\mathit{\text{value}}⟩$.
$\mathbf{errorid}=10601$
On entry, argument $⟨\mathit{\text{value}}⟩$ must be a vector of size $⟨\mathit{\text{value}}⟩$ array.
The size for the supplied array could not be ascertained.
$\mathbf{errorid}=10602$
On entry, the raw data component of $⟨\mathit{\text{value}}⟩$ is null.
$\mathbf{errorid}=10603$
On entry, unable to ascertain a value for $⟨\mathit{\text{value}}⟩$.
$\mathbf{errorid}=10605$
On entry, the communication class $⟨\mathit{\text{value}}⟩$ has not been initialized correctly.
$\mathbf{errorid}=-99$
An unexpected error has been triggered by this routine.
$\mathbf{errorid}=-399$
Your licence key may have expired or may not have been installed correctly.
$\mathbf{errorid}=-999$
Dynamic memory allocation failed.

Not applicable.

## 8Parallelism and Performance

Please see the description for the underlying computational routine in this section of the FL Interface documentation.