# NAG CPP Interfacenagcpp::opt::handle_set_group (e04rb)

Settings help

CPP Name Style:

## 1Purpose

handle_set_group is a part of the NAG optimization modelling suite and modifies a model by either adding a new, or replacing, or deleting an existing quadratic or rotated quadratic cone constraint.

## 2Specification

```#include "e04/nagcpp_e04rb.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
```
```template <typename COMM, typename GROUP>

void function handle_set_group(COMM &comm, const string gtype, const GROUP &group, types::f77_integer &idgroup, OptionalE04RB opt)```
```template <typename COMM, typename GROUP>

void function handle_set_group(COMM &comm, const string gtype, const GROUP &group, types::f77_integer &idgroup)```

## 3Description

After the handle has been initialized (e.g., handle_​init has been called), handle_set_group may be used to edit a model by adding, replacing, or deleting a cone constraint $i$ of dimension ${m}_{i}$. The supported cones are quadratic cone and rotated quadratic cone, also known as second-order cones, which are defined as follows:
• Quadratic cone:
 $K q mi ≔ {z=(z1,z2,…,zmi)∈ℝmi : z12≥ ∑ j=2 mi zj2, z1≥0} .$ (1)
• Rotated quadratic cone:
 $K r mi ≔ {z=(z1,z2,…,zmi)∈ℝmi : 2z1z2≥ ∑ j=3 mi zj2, z1≥0, z2≥0} .$ (2)
The cone constraint is defined by its type and a subset (group) of variables. Let index set ${G}^{i}\subseteq \left\{1,2,\dots ,n\right\}$ denote variable indices, then ${x}_{{G}^{i}}$ will denote the subvector of variables $x\in {ℝ}^{n}$.
For example, if ${m}_{i}=3$ and ${G}^{i}=\left\{4,1,2\right\}$, then a quadratic cone constraint
 $xGi = (x4,x1,x2) ∈ Kq3$
implies the inequality constraints
 $x42 ≥ x12 + x22 , x4 ≥ 0 .$
Typically, this function will be used to build Second-order Cone Programming (SOCP) problems which might be formulated in the following way:
 $minimize x∈ℝn cTx (a) subject to lB≤Bx≤uB, (b) lx≤x≤ux , (c) xGi∈Kmi, i=1,…,r, (d)$ (3)
where ${\mathcal{K}}^{{m}_{i}}$ is either a quadratic cone or a rotated quadratic cone of dimension ${m}_{i}$.
handle_set_group can be called repeatedly to add, replace or delete one cone constraint at a time. Note that it is also possible to temporarily disable and enable individual cone constraints in the model by calling e04tcf (no CPP interface) and e04tbf (no CPP interface), respectively. 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{gtype}$string Input
On entry: the type of the cone constraint. gtype is case insensitive.
${\mathbf{gtype}}=\text{'QUAD'}$ or $\text{'Q'}$
The group defines a quadratic cone.
${\mathbf{gtype}}=\text{'RQUAD'}$ or $\text{'R'}$
The group defines a rotated quadratic cone.
Constraint: ${\mathbf{gtype}}=\text{'QUAD'}$, $\text{'Q'}$, $\text{'RQUAD'}$ or $\text{'R'}$.
3: $\mathbf{group}\left({\mathbf{lgroup}}\right)$types::f77_integer array Input
On entry: ${G}^{i}$, the indices of the variables in the constraint. If ${\mathbf{lgroup}}=0$, group is not referenced.
Constraint: $1\le {\mathbf{group}}\left(\mathit{k}-1\right)\le n$, for $\mathit{k}=1,2,\dots ,{\mathbf{lgroup}}$, where $n$ is the number of decision variables in the problem. The elements must not repeat.
4: $\mathbf{idgroup}$types::f77_integer Input/Output
On entry:
${\mathbf{idgroup}}=0$
A new cone constraint is created.
${\mathbf{idgroup}}>0$
$i$, the ID number of the existing constraint to be deleted or replaced.
Constraint: ${\mathbf{idgroup}}\ge 0$.
On exit: if ${\mathbf{idgroup}}=0$ on entry, the ID number of the new cone constraint is returned. By definition, this is the number of cone constraints already defined plus one. Otherwise, idgroup remains unchanged.
5: $\mathbf{opt}$OptionalE04RB Input/Output
Optional parameter container, derived from Optional.

### 5.1Additional Quantities

1: $\mathbf{lgroup}$
${m}_{i}$, the number of variables in the group.

## 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{idgroup}}=⟨\mathit{value}⟩$.
The given idgroup does not match with any cone constraint already defined.
$\mathbf{errorid}=5$
On entry, ${\mathbf{lgroup}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{lgroup}}\ge 0$.
$\mathbf{errorid}=5$
On entry, ${\mathbf{gtype}}=⟨\mathit{value}⟩$ and ${\mathbf{lgroup}}=⟨\mathit{value}⟩$.
Constraint: if ${\mathbf{gtype}}=\text{"QUAD"}\text{​ or ​}\text{"Q"}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 2$.
$\mathbf{errorid}=5$
On entry, ${\mathbf{gtype}}=⟨\mathit{value}⟩$ and ${\mathbf{lgroup}}=⟨\mathit{value}⟩$.
Constraint: if ${\mathbf{gtype}}=\text{"RQUAD"}\text{​ or ​}\text{"R"}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 3$.
$\mathbf{errorid}=6$
On entry, ${\mathbf{gtype}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{gtype}}=\text{"QUAD"},\text{"Q"},\text{"RQUAD"}\text{​ or ​}\text{"R"}$.
$\mathbf{errorid}=7$
On entry, ${\mathbf{idgroup}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{idgroup}}\ge 0$.
$\mathbf{errorid}=8$
On entry, $k=⟨\mathit{value}⟩$, ${\mathbf{group}}\left[k-1\right]=⟨\mathit{value}⟩$ and
$n=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{group}}\left[k-1\right]\le n$.
$\mathbf{errorid}=9$
On entry, ${\mathbf{group}}\left[i-1\right]={\mathbf{group}}\left[j-1\right]=⟨\mathit{value}⟩$
for $i=⟨\mathit{value}⟩$ and $j=⟨\mathit{value}⟩$.
Constraint: elements in group cannot repeat.
$\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.

## 10Example

### 10.1Example Program

Source File Data Results
ex_e04rb.cpp None ex_e04rb.r