E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE04RLF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

E04RLF is a part of the NAG optimization modelling suite and defines the structure of the Hessians of the nonlinear objective and constraints, on assumption that they are present in the problem. Alternatively, it may be used to define the Hessian of the Lagrangian.

## 2  Specification

 SUBROUTINE E04RLF ( HANDLE, IDF, NNZH, IROWH, ICOLH, IFAIL)
 INTEGER IDF, NNZH, IROWH(NNZH), ICOLH(NNZH), IFAIL TYPE (C_PTR) HANDLE

## 3  Description

After the initialization routine E04RAF has been called and an objective function $f$ or nonlinear constraint function ${g}_{i}$ has been registered with E04RGF and E04RKF, E04RLF can be used to define the sparsity structure of the Hessians, $H$, of those functions (i.e., the second partial derivatives with respect to the decision variables) or a linear combination of them, called the Lagrangian.
• Defining ${\nabla }^{2}f\equiv \left(\begin{array}{cccc}\frac{{\partial }^{2}f}{{\partial }^{2}{x}_{1}}& \frac{{\partial }^{2}f}{\partial {x}_{2}\partial {x}_{1}}& \dots & \frac{{\partial }^{2}f}{\partial {x}_{n}\partial {x}_{1}}\\ \frac{{\partial }^{2}f}{\partial {x}_{1}\partial {x}_{2}}& \frac{{\partial }^{2}f}{{\partial }^{2}{x}_{2}}& \dots & \frac{{\partial }^{2}f}{\partial {x}_{n}\partial {x}_{2}}\\ ⋮& ⋮& \ddots & ⋮\\ \frac{{\partial }^{2}f}{\partial {x}_{1}\partial {x}_{n}}& \frac{{\partial }^{2}f}{\partial {x}_{2}\partial {x}_{n}}& \dots & \frac{{\partial }^{2}f}{{\partial }^{2}{x}_{n}}\end{array}\right)$;
• the Hessian of the Lagrangian function $\equiv \sigma {\nabla }^{2}f+\sum _{i=1}^{m}{\lambda }_{i}{\nabla }^{2}{g}_{i}$;
• the Hessian of the objective function $\equiv {\nabla }^{2}f$;
• the Hessian of the constraint functions $\equiv {\nabla }^{2}{g}_{i}$.
Each of the symmetric $n×n$ Hessian matrices will have its own sparsity structure, in general. These structures can be given in separate E04RLF calls, or merged together in the Lagrangian and given in one call.
The nonzero values of the Hessians at particular points in the decision variable space will be communicated to the NLP solver by user-supplied functions (e.g., HESS for E04STF).
Some NLP solvers (e.g., E04STF) expect either all of the Hessians (for objective and nonlinear constraints) to be supplied by the user or none and they will terminate with an error indicator if only some but not all of the Hessians have been introduced by E04RLF.
Some NLP solvers (e.g., E04STF, again) will automatically switch to using internal approximations for the Hessians if none have been introduced by E04RLF. This usually results in a slower convergence (more iterations to the solution) and might even result in no solution being attainable within the ordinary tolerances.

None.

## 5  Arguments

1:     $\mathrm{HANDLE}$ – TYPE (C_PTR)Input
On entry: the handle to the problem. It needs to be initialized by E04RAF and must not be changed.
2:     $\mathrm{IDF}$ – INTEGERInput
On entry: specifies the quantities for which a sparsity structure is provided in NNZH, IROWH and ICOLH.
${\mathbf{IDF}}=-1$
The sparsity structure of the Hessian of the Lagrangian is provided.
${\mathbf{IDF}}=0$
The sparsity structure of the Hessian of the objective function is provided.
${\mathbf{IDF}}>0$
The sparsity structure of the Hessian of the IDFth constraint function is provided.
The value of IDF will also determine how an NLP solver will call the user-supplied subroutines that evaluate these nonzeros at particular points of the decision variable space, i.e., whether the solver will expect the nonzero values of the objective and constraint Hessians in separate calls or merged in the Lagrangian Hessian, in one call. See, for example, HESS of E04STF.
Constraint: $-1\le {\mathbf{IDF}}\le \mathit{ncnln}$.
Note: $\mathit{ncnln}$, the number of nonlinear constraints registered with the handle.
3:     $\mathrm{NNZH}$ – INTEGERInput
On entry: the number of nonzero elements in the upper triangle of the matrix $H$.
Constraint: ${\mathbf{NNZH}}>0$.
4:     $\mathrm{IROWH}\left({\mathbf{NNZH}}\right)$ – INTEGER arrayInput
5:     $\mathrm{ICOLH}\left({\mathbf{NNZH}}\right)$ – INTEGER arrayInput
On entry: arrays IROWH and ICOLH 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 specifies the values of the nonzero elements in such a way that ${h}_{ij}=\mathit{H}\left(l\right)$ where $i={\mathbf{IROWH}}\left(l\right)$ and $j={\mathbf{ICOLH}}\left(\mathit{l}\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}\right)\le {\mathbf{ICOLH}}\left(\mathit{l}\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{NNZH}}$.
6:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}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).

## 6  Error 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 initialized by E04RAF or it has been corrupted.
${\mathbf{IFAIL}}=2$
Neither nonlinear objective nor nonlinear constraints are present. The structure of the Hessian cannot be defined.
No nonlinear objective has been defined, its Hessian cannot be set.
The problem cannot be modified in this phase any more, the solver has already been called.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{IDF}}=〈\mathit{\text{value}}〉$.
The structure of the Hessian of nonlinear function linked to the given IDF has already been defined.
The structure of the Hessian of the Lagrangian has already been defined.
The structure of the individual Hessians has already been defined, the Hessian of the Lagrangian cannot be defined.
${\mathbf{IFAIL}}=6$
On entry, ${\mathbf{NNZH}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NNZH}}>0$.
${\mathbf{IFAIL}}=7$
On entry, ${\mathbf{IDF}}=〈\mathit{\text{value}}〉$.
Constraint: $〈\mathit{\text{value}}〉\le {\mathbf{IDF}}\le 〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=8$
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{ICOLH}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{ICOLH}}\left(\mathit{i}\right)\le n$.
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{IROWH}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{ICOLH}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IROWH}}\left(\mathit{i}\right)\le {\mathbf{ICOLH}}\left(\mathit{i}\right)$ (elements within the upper triangle).
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{IROWH}}\left(\mathit{i}\right)=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{IROWH}}\left(\mathit{i}\right)\le n$.
On entry, more than one element of structural matrix $H$ has row index $〈\mathit{\text{value}}〉$ and column index $〈\mathit{\text{value}}〉$.
Constraint: each element of structural matrix $H$ must have a unique row and column index.
${\mathbf{IFAIL}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8  Parallelism and Performance

E04RLF is not threaded in any implementation.