# NAG FL Interfacee04rhf (handle_​set_​simplebounds)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e04rhf is a part of the NAG optimization modelling suite and sets bounds on the variables of the problem.

## 2Specification

Fortran Interface
 Subroutine e04rhf ( nvar, bl, bu,
 Integer, Intent (In) :: nvar Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: bl(nvar), bu(nvar) Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04rhf_ (void **handle, const Integer *nvar, const double bl[], const double bu[], Integer *ifail)
The routine may be called by the names e04rhf or nagf_opt_handle_set_simplebounds.

## 3Description

After the handle has been initialized (e.g., e04raf has been called), e04rhf may be used to define the variable bounds ${l}_{x}\le x\le {u}_{x}$ of the problem. If the bounds have already been defined, they will be overwritten. Individual bounds may also be set by e04tdf.
This will typically be used for problems, such as:
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)
Nonlinear Programming (NLP)
 $minimize x∈ℝn f(x) (a) subject to lg≤g(x)≤ug, (b) lB≤Bx≤uB, (c) lx≤x≤ux, (d)$ (3)
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)$ (4)
where ${l}_{x}$ and ${u}_{x}$ are $n$-dimensional vectors. Note that upper and lower bounds are specified for all the variables. This form allows full generality in specifying various types of constraint. In particular, the $j$th variable may be fixed by setting ${l}_{j}={u}_{j}$. If certain bounds are not present, the associated elements of ${l}_{x}$ or ${u}_{x}$ 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 routine and any later alterations to Infinite Bound Size will not affect these constraints.
See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

## 4References

Candes E and Recht B (2009) Exact matrix completion via convex optimization Foundations of Computation Mathematics (Volume 9) 717–772

## 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{nvar}$Integer Input
On entry: $n$, the current number of decision variables $x$ in the model.
3: $\mathbf{bl}\left({\mathbf{nvar}}\right)$Real (Kind=nag_wp) array Input
4: $\mathbf{bu}\left({\mathbf{nvar}}\right)$Real (Kind=nag_wp) array Input
On entry: ${l}_{x}$, bl and ${u}_{x}$, bu define lower and upper bounds on the variables, respectively. To fix the $j$th variable, set ${\mathbf{bl}}\left(j\right)={\mathbf{bu}}\left(j\right)=\beta$, where $|\beta |<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left(j\right)\le -\mathit{bigbnd}$; to specify a nonexistent upper bound (i.e., ${u}_{j}=\infty$), set ${\mathbf{bu}}\left(j\right)\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{bl}}\left(\mathit{j}\right)\le {\mathbf{bu}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{nvar}}$;
• ${\mathbf{bl}}\left(\mathit{j}\right)<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nvar}}$;
• ${\mathbf{bu}}\left(\mathit{j}\right)>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nvar}}$.
5: $\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{nvar}}=⟨\mathit{\text{value}}⟩$, expected $\mathrm{value}=⟨\mathit{\text{value}}⟩$.
Constraint: nvar must match the current number of variables of the model in the handle.
${\mathbf{ifail}}=10$
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bl}}\left(j\right)=⟨\mathit{\text{value}}⟩$, $\mathit{bigbnd}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bl}}\left(j\right)<\mathit{bigbnd}$.
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bl}}\left(j\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{bu}}\left(j\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bl}}\left(j\right)\le {\mathbf{bu}}\left(j\right)$.
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bu}}\left(j\right)=⟨\mathit{\text{value}}⟩$, $\mathit{bigbnd}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bu}}\left(j\right)>-\mathit{bigbnd}$.
${\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.

## 8Parallelism and Performance

e04rhf is not threaded in any implementation.

### 9.1Internal Changes

Internal changes have been made to this routine as follows:
• At Mark 26.1: The limitation to specifying model fixed variables (${\mathbf{bl}}\left(j\right)={\mathbf{bu}}\left(j\right)$ for some $j$) where such input returns ${\mathbf{ifail}}={\mathbf{10}}$ has been lifted.
• At Mark 27.1: Previously, it was not possible to modify the bounds once they were set or to edit the model once a solver had been called. These limitations have been removed and the associated error codes were removed.
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.

## 10Example

There is a vast number of problems which can be reformulated as SDP. This example follows Candes and Recht (2009) to show how a rank minimization problem can be approximated by SDP. In addition, it demonstrates how to work with the monitor mode of e04svf.
The problem can be stated as follows: Let's have $m$ respondents answering $k$ questions where they express their preferences as a number between $0$ and $1$ or the question can be left unanswered. The task is to fill in the missing entries, i.e., to guess the unexpressed preferences. This problem falls into the category of matrix completion. The idea is to choose the missing entries to minimize the rank of the matrix as it is commonly believed that only a few factors contribute to an individual's tastes or preferences.
Rank minimization is in general NP-hard but it can be approximated by a heuristic, minimizing the nuclear norm of the matrix. The nuclear norm of a matrix is the sum of its singular values. A rank deficient matrix must have (several) zero singular values. Given the fact that the singular values are always non-negative, a minimization of the nuclear norm has the same effect as ${\ell }_{1}$ norm in compress sensing, i.e., it encourages many singular values to be zero and thus it can be considered as a heuristic for the original rank minimization problem.
Let $\stackrel{^}{Y}$ denote the partially filled in $m×k$ matrix with the valid responses on $\left(i,j\right)\in \Omega$ positions. We are looking for $Y$ of the same size so that the valid responses are unchanged and the nuclear norm (denoted here as ${‖·‖}_{*}$) is minimal.
 $minimizeY ‖Y‖* subject to Yij = Y^ij for all (i,j)∈Ω.$
This is equivalent to
 $minimize W1, W2, Y trace (W1)+ trace (W2) subject to Yij = Y^ij for all (i,j)∈Ω , ( W1 Y YT W2 ) ⪰ 0$
which is the linear semidefinite problem solved in this example, see Candes and Recht (2009) and the references therein for details.
This example has $m=15$ respondents and $k=6$ answers. The obtained answers are
 $Y^ = ( * * * * * 0.4 0.6 0.4 0.8 * * * * * 0.8 * 0.2 * 0.8 0.2 * * * * * 0.4 * 0.0 * 0.2 0.4 * * 0.2 * 0.2 * 0.8 0.2 0.6 * * * * 0.2 * * * * 0.4 * 0.6 0.0 * * * 0.4 * * * * * 0.2 0.2 0.4 0.4 * * * * 1.0 0.8 1.0 * 0.2 * * 0.6 * * * * * 0.2 0.6 * 0.2 0.4 * * )$
where $*$ denotes missing entries ($-1.0$ is used instead in the data file). The obtained matrix has rank $4$ and it is shown below printed to $1$-digit accuracy:
 $Y = ( 0.5 0.3 0.2 0.2 0.4 0.4 0.6 0.4 0.8 0.2 0.3 0.4 0.4 0.3 0.8 0.0 0.2 0.2 0.8 0.2 0.3 0.4 0.3 0.4 0.0 0.4 0.2 0.0 0.2 0.2 0.4 0.1 0.2 0.2 0.1 0.2 0.6 0.8 0.2 0.6 0.2 0.4 0.1 0.1 0.2 0.0 0.0 0.1 0.6 0.4 0.1 0.6 0.0 0.3 0.2 0.1 0.4 0.0 0.1 0.1 0.5 0.3 0.2 0.2 0.4 0.4 0.7 0.4 0.3 0.0 1.0 0.8 1.0 0.3 0.2 0.5 0.5 0.6 0.2 0.1 0.1 0.1 0.2 0.2 0.6 0.3 0.2 0.4 0.2 0.3 ) .$
The example also turns on monitor mode of e04svf, there is a time limit introduced for the solver which is being checked at the end of every outer iteration. If the time limit is reached, the routine is stopped by setting ${\mathbf{inform}}=0$ within the monitor step.