# NAG CL Interfacee04rbc (handle_​set_​group)

## 1Purpose

e04rbc 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
 void e04rbc (void *handle, const char *gtype, Integer lgroup, const Integer group[], Integer *idgroup, NagError *fail)
The function may be called by the names: e04rbc or nag_opt_handle_set_group.

## 3Description

After the initialization function e04rac has been called, e04rbc 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)
• 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 quadratic cone or rotated quadratic cone of dimension ${m}_{i}$.
e04rbc can be called repeatedly to add, replace or delete one cone constraint at a time. See Section 4.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

## 5Arguments

1: $\mathbf{handle}$void * Input
On entry: the handle to the problem. It needs to be initialized by e04rac and must not be changed between calls to the NAG optimization modelling suite.
2: $\mathbf{gtype}$const char * Input
On entry: the type of the cone constraint, case insensitive.
${\mathbf{gtype}}="QUAD"$ or $"Q"$
The group defines a quadratic cone.
${\mathbf{gtype}}="RQUAD"$ or $"R"$
The group defines a rotated quadratic cone.
Constraint: ${\mathbf{gtype}}="QUAD"$, $"Q"$, $"RQUAD"$ or $"R"$.
3: $\mathbf{lgroup}$Integer Input
On entry: ${m}_{i}$, the number of the variables in the group.
If ${\mathbf{lgroup}}=0$, gtype and group will not be referenced and may be NULL, and the constraint with ID number idgroup will be deleted from the model.
Constraints:
• if ${\mathbf{gtype}}="QUAD"$ or $"Q"$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 2$;
• if ${\mathbf{gtype}}="RQUAD"$ or $"R"$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 3$.
4: $\mathbf{group}\left[{\mathbf{lgroup}}\right]$const Integer Input
On entry: ${G}^{i}$, the indices of the variables in the constraint. If ${\mathbf{lgroup}}=0$, group is not referenced and may be NULL.
Constraint: $1\le {\mathbf{group}}\left[\mathit{k}\right]\le n$, for $\mathit{k}=0,1,\dots ,{\mathbf{lgroup}}$, where $n$ is the number of decision variables in the problem. The elements must not repeat and each variable can appear in one cone at most, see Section 9.
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 the cone constraints already defined plus one. Otherwise, idgroup stays unchanged.
6: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_HANDLE
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 e04rac or it has been corrupted.
NE_INDICES
On entry, $k=〈\mathit{\text{value}}〉$, ${\mathbf{group}}\left[k-1\right]=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{group}}\left[k-1\right]\le n$.
NE_INT
On entry, ${\mathbf{idgroup}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{idgroup}}\ge 0$.
On entry, ${\mathbf{lgroup}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lgroup}}\ge 0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_PHASE
The problem cannot be modified in this phase any more, the solver has already been called.
NE_REF_MATCH
On entry, ${\mathbf{idgroup}}=〈\mathit{\text{value}}〉$.
The given idgroup does not match with any cone constraint already defined.
NE_REPEAT_CONEVAR_DF
On entry, variable with index $i=〈\mathit{\text{value}}〉$ has been defined in a cone in a previous call to this function.
Constraint: each variable may be defined in one cone constraint at most.
NE_REPEAT_CONEVAR_SM
On entry, ${\mathbf{group}}\left[i-1\right]={\mathbf{group}}\left[j-1\right]=〈\mathit{\text{value}}〉$ for $i=〈\mathit{\text{value}}〉$ and $j=〈\mathit{\text{value}}〉$.
Constraint: elements in group cannot repeat.
NE_STANDARD_ERRORS
On entry, ${\mathbf{gtype}}=〈\mathit{\text{value}}〉$ and ${\mathbf{lgroup}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{gtype}}="QUAD"$ or $"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}}="RQUAD"$ or $"R"$, ${\mathbf{lgroup}}=0$ or ${\mathbf{lgroup}}\ge 3$.
NE_STR_UNKNOWN
On entry, ${\mathbf{gtype}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{gtype}}="QUAD"$, $"Q"$, $"RQUAD"$ or $"R"$.

Not applicable.

## 8Parallelism and Performance

e04rbc is not threaded in any implementation.

Overlapping of cones is not supported, which means each variable may be defined in one cone at most. However by adding auxiliary variables, you can achieve the same effect. For example, if ${x}_{a}\in {\mathcal{K}}^{{m}_{1}}$ and ${x}_{a}\in {\mathcal{K}}^{{m}_{2}}$, you can add one more variable ${x}_{b}={x}_{a}$ and set ${x}_{a}\in {\mathcal{K}}^{{m}_{1}}$, ${x}_{b}\in {\mathcal{K}}^{{m}_{2}}$.

## 10Example

This example solves the following SOCP problem
 $minimize⁡ 10.0x1 + 20.0x2 + x3$
subject to the bounds
 $-2.0 ≤ x1 ≤ 2.0 -2.0 ≤ x2 ≤ 2.0$
the general linear constraints
 $-0.1x1 - 0.1x2 + x3 ≤ 1.5 1.0 ≤ -0.06x1 + x2 + x3$
and the cone constraint
 $x3,x1,x2 ∈ K q 3 .$
The optimal solution (to five significant figures) is
 $x*=-1.2682,-4.0843,1.3323T,$
and the objective function value is $-19.518$.

### 10.1Program Text

Program Text (e04rbce.c)

### 10.2Program Data

Program Data (e04rbce.d)

### 10.3Program Results

Program Results (e04rbce.r)