# NAG FL Interfacee04rbf (handle_​set_​group)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e04rbf 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

Fortran Interface
 Subroutine e04rbf (
 Integer, Intent (In) :: lgroup, group(lgroup) Integer, Intent (Inout) :: idgroup, ifail Character (*), Intent (In) :: gtype Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04rbf_ (void **handle, const char *gtype, const Integer *lgroup, const Integer group[], Integer *idgroup, Integer *ifail, const Charlen length_gtype)
The routine may be called by the names e04rbf or nagf_opt_handle_set_group.

## 3Description

After the handle has been initialized (e.g., e04raf has been called), e04rbf 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:
 $K q mi ≔ {z=(z1,z2,…,zmi)∈ℝmi : z12≥ ∑ j=2 mi zj2, z1≥0} .$ (1)
 $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 routine 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}$.
e04rbf 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 and e04tbf, respectively. See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

## 5Arguments

1: $\mathbf{handle}$Type (c_ptr) Input
On entry: the handle to the problem. It needs to be initialized (e.g., by e04raf) and must not be changed between calls to the NAG optimization modelling suite.
2: $\mathbf{gtype}$Character(*) 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{lgroup}$Integer Input
On entry: ${m}_{i}$, the number of variables in the group.
If ${\mathbf{lgroup}}=0$, gtype and group will not be referenced, and the constraint with ID number idgroup will be deleted from the model.
Constraints:
• if ${\mathbf{gtype}}=\text{'QUAD'}$ or $\text{'Q'}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 2$;
• if ${\mathbf{gtype}}=\text{'RQUAD'}$ or $\text{'R'}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 3$.
4: $\mathbf{group}\left({\mathbf{lgroup}}\right)$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}\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.
5: $\mathbf{idgroup}$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.
6: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{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).

## 6Error 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 properly initialized or it has been corrupted.
${\mathbf{ifail}}=2$
The problem cannot be modified right now, the solver is running.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{idgroup}}=⟨\mathit{\text{value}}⟩$.
The given idgroup does not match with any cone constraint already defined.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{gtype}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{lgroup}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{gtype}}=\text{'QUAD'}$ or $\text{'Q'}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 2$.
On entry, ${\mathbf{gtype}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{lgroup}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{gtype}}=\text{'RQUAD'}$ or $\text{'R'}$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 3$.
On entry, ${\mathbf{lgroup}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lgroup}}\ge 0$.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{gtype}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{gtype}}=\text{'QUAD'}$, $\text{'Q'}$, $\text{'RQUAD'}$ or $\text{'R'}$.
${\mathbf{ifail}}=7$
On entry, ${\mathbf{idgroup}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{idgroup}}\ge 0$.
${\mathbf{ifail}}=8$
On entry, $k=⟨\mathit{\text{value}}⟩$, ${\mathbf{group}}\left(k\right)=⟨\mathit{\text{value}}⟩$ and $n=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{group}}\left(k\right)\le n$.
${\mathbf{ifail}}=9$
On entry, ${\mathbf{group}}\left(i\right)={\mathbf{group}}\left(j\right)=⟨\mathit{\text{value}}⟩$ for $i=⟨\mathit{\text{value}}⟩$ and $j=⟨\mathit{\text{value}}⟩$.
Constraint: elements in group cannot repeat.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.