Settings help

CPP Name Style:

## 1Purpose

handle_set_quadobj is a part of the NAG optimization modelling suite and defines or redefines the objective function of the problem to be linear or quadratic.

## 2Specification

```#include "e04/nagcpp_e04rf.hpp"
#include "e04/nagcpp_class_CommE04RA.hpp"
```
```template <typename COMM, typename IDXC, typename C, typename IROWH, typename ICOLH, typename H>

void function handle_set_quadobj(COMM &comm, const IDXC &idxc, const C &c, const IROWH &irowh, const ICOLH &icolh, const H &h, OptionalE04RF opt)```
```template <typename COMM, typename IDXC, typename C, typename IROWH, typename ICOLH, typename H>

void function handle_set_quadobj(COMM &comm, const IDXC &idxc, const C &c, const IROWH &irowh, const ICOLH &icolh, const H &h)```

## 3Description

After the handle has been initialized (e.g., handle_​init has been called), handle_set_quadobj may be used to define the objective function of the problem as a quadratic function ${c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}Hx$ or a sparse linear function ${c}^{\mathrm{T}}x$. If the objective function has already been defined, it will be overwritten. If handle_set_quadobj is called with no nonzeroes in either $c$ or $H$, any existing objective function is removed, no new one is added and the problem will be solved as a feasible point problem. e04tef (no CPP interface) may be used to set individual elements ${c}_{i}$ of the linear objective.
This objective function will typically be used for
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)
or for Semidefinite Programming problems 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)$ (3)
The matrix $H$ is a sparse symmetric $n×n$ matrix. It does not need to be positive definite. 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{idxc}\left({\mathbf{nnzc}}\right)$types::f77_integer array Input
On entry: the nonzero elements of the sparse vector $c$. ${\mathbf{idxc}}\left(i-1\right)$ must contain the index of ${\mathbf{c}}\left(\mathit{i}-1\right)$ in the vector, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}$. The elements must be stored in ascending order. Note that $n$ is the current number of variables in the model.
Constraints:
• $1\le {\mathbf{idxc}}\left(\mathit{i}-1\right)\le n$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}$;
• ${\mathbf{idxc}}\left(\mathit{i}-1\right)<{\mathbf{idxc}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}-1$.
3: $\mathbf{c}\left({\mathbf{nnzc}}\right)$double array Input
On entry: the nonzero elements of the sparse vector $c$. ${\mathbf{idxc}}\left(i-1\right)$ must contain the index of ${\mathbf{c}}\left(\mathit{i}-1\right)$ in the vector, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}$. The elements must be stored in ascending order. Note that $n$ is the current number of variables in the model.
Constraints:
• $1\le {\mathbf{idxc}}\left(\mathit{i}-1\right)\le n$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}$;
• ${\mathbf{idxc}}\left(\mathit{i}-1\right)<{\mathbf{idxc}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzc}}-1$.
4: $\mathbf{irowh}\left({\mathbf{nnzh}}\right)$types::f77_integer array Input
On entry: arrays irowh, icolh and h store the nonzeros of the upper triangle of the matrix $H$ in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowh specifies one-based row indices, icolh specifies one-based column indices and h specifies the values of the nonzero elements in such a way that ${h}_{ij}={\mathbf{h}}\left(l-1\right)$ where $i={\mathbf{irowh}}\left(l-1\right)$, $j={\mathbf{icolh}}\left(\mathit{l}-1\right)$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$. No particular order is expected, but elements should not repeat.
Constraint: $1\le {\mathbf{irowh}}\left(\mathit{l}-1\right)\le {\mathbf{icolh}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$.
5: $\mathbf{icolh}\left({\mathbf{nnzh}}\right)$types::f77_integer array Input
On entry: arrays irowh, icolh and h store the nonzeros of the upper triangle of the matrix $H$ in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowh specifies one-based row indices, icolh specifies one-based column indices and h specifies the values of the nonzero elements in such a way that ${h}_{ij}={\mathbf{h}}\left(l-1\right)$ where $i={\mathbf{irowh}}\left(l-1\right)$, $j={\mathbf{icolh}}\left(\mathit{l}-1\right)$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$. No particular order is expected, but elements should not repeat.
Constraint: $1\le {\mathbf{irowh}}\left(\mathit{l}-1\right)\le {\mathbf{icolh}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$.
6: $\mathbf{h}\left({\mathbf{nnzh}}\right)$double array Input
On entry: arrays irowh, icolh and h store the nonzeros of the upper triangle of the matrix $H$ in coordinate storage (CS) format (see Section 2.1.1 in the F11 Chapter Introduction). irowh specifies one-based row indices, icolh specifies one-based column indices and h specifies the values of the nonzero elements in such a way that ${h}_{ij}={\mathbf{h}}\left(l-1\right)$ where $i={\mathbf{irowh}}\left(l-1\right)$, $j={\mathbf{icolh}}\left(\mathit{l}-1\right)$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$. No particular order is expected, but elements should not repeat.
Constraint: $1\le {\mathbf{irowh}}\left(\mathit{l}-1\right)\le {\mathbf{icolh}}\left(\mathit{l}-1\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzh}}$.
7: $\mathbf{opt}$OptionalE04RF Input/Output
Optional parameter container, derived from Optional.

1: $\mathbf{nnzc}$
The number of nonzero elements in the sparse vector $c$
2: $\mathbf{nnzh}$
The number of nonzero elements in the upper triangle of the matrix $H$

## 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}=6$
On entry, ${\mathbf{nnzh}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{nnzh}}\ge 0$.
$\mathbf{errorid}=6$
On entry, ${\mathbf{nnzc}}=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{nnzc}}\ge 0$.
$\mathbf{errorid}=7$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{idxc}}\left[i-1\right]=⟨\mathit{value}⟩$ and
${\mathbf{idxc}}\left[i+0\right]=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{idxc}}\left[i-1\right]<{\mathbf{idxc}}\left[i+0\right]$ (ascending order).
$\mathbf{errorid}=7$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{idxc}}\left[i-1\right]=⟨\mathit{value}⟩$ and
$n=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{idxc}}\left[i-1\right]\le n$.
$\mathbf{errorid}=8$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{irowh}}\left[i-1\right]=⟨\mathit{value}⟩$ and
$n=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{irowh}}\left[i-1\right]\le n$.
$\mathbf{errorid}=8$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{icolh}}\left[i-1\right]=⟨\mathit{value}⟩$ and
$n=⟨\mathit{value}⟩$.
Constraint: $1\le {\mathbf{icolh}}\left[i-1\right]\le n$.
$\mathbf{errorid}=8$
On entry, $i=⟨\mathit{value}⟩$, ${\mathbf{irowh}}\left[i-1\right]=⟨\mathit{value}⟩$ and
${\mathbf{icolh}}\left[i-1\right]=⟨\mathit{value}⟩$.
Constraint: ${\mathbf{irowh}}\left[i-1\right]\le {\mathbf{icolh}}\left[i-1\right]$ (elements within the upper triangle).
$\mathbf{errorid}=8$
On entry, more than one element of h has row index $⟨\mathit{\text{value}}⟩$
and column index $⟨\mathit{\text{value}}⟩$.
Constraint: each element of h must have a unique row and column index.
$\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.