E04RGF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE04RGF

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

E04RGF is a part of the NAG optimization modelling suite and declares the objective function of the problem as a nonlinear function with a particular gradient sparsity structure.

## 2  Specification

 SUBROUTINE E04RGF ( HANDLE, NNZFD, IDXFD, IFAIL)
 INTEGER NNZFD, IDXFD(NNZFD), IFAIL TYPE (C_PTR) HANDLE

## 3  Description

After the initialization routine E04RAF has been called (and unless the objective function has been defined previously by E04REF, E04RFF or by E04RGF), E04RGF may be used to declare the objective function of the problem as a nonlinear function and define the sparsity pattern (list of nonzero elements) of its gradient. This objective function will typically be used for nonlinear programming problems (NLP) of the kind:
 $minimize x∈ℝn fx (a) subject to lg≤gx≤ug (b) lB≤Bx≤uB (c) lx≤x≤ux (d)$ (1)
The values of the nonlinear objective function $f\left(x\right)$ and the nonzero values of its gradient $\frac{\partial f}{\partial {x}_{i}}$ (matching the sparsity pattern) evaluated at particular points in the decision variable space will be communicated to the NLP solver by user-supplied functions (e.g., OBJFUN and OBJGRD). See E04RAF for more details.

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{NNZFD}$ – INTEGERInput
On entry: the number of nonzero elements in the sparse gradient vector of the objective function.
Constraint: ${\mathbf{NNZFD}}\ge 0$.
3:     $\mathrm{IDXFD}\left({\mathbf{NNZFD}}\right)$ – INTEGER arrayInput
On entry: the one-based indices of the nonzero elements of the sparse gradient vector. The indices must be stored in ascending order. Note that $n$, the number of decision variables in the problem, was set in NVAR during the initialization of the handle by E04RAF.
If ${\mathbf{NNZFD}}=0$, the objective is assumed to be zero and the array IDXFD will not be referenced.
Constraints:
• $1\le {\mathbf{IDXFD}}\left(\mathit{i}\right)\le n$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZFD}}$;
• ${\mathbf{IDXFD}}\left(\mathit{i}\right)<{\mathbf{IDXFD}}\left(\mathit{i}+1\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZFD}}-1$.
4:     $\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$
The Hessians of nonlinear functions have already been defined, a nonlinear objective cannot be added.
The problem cannot be modified in this phase any more, the solver has already been called.
${\mathbf{IFAIL}}=3$
The objective function has already been defined.
${\mathbf{IFAIL}}=6$
On entry, ${\mathbf{NNZFD}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NNZFD}}\ge 0$.
${\mathbf{IFAIL}}=7$
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{IDXFD}}\left(i\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{IDXFD}}\left(i+1\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IDXFD}}\left(\mathit{i}\right)<{\mathbf{IDXFD}}\left(i+1\right)$ (ascending order).
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{IDXFD}}\left(i\right)=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{IDXFD}}\left(i\right)\le n$.
${\mathbf{IFAIL}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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

E04RGF is not threaded in any implementation.

## 9  Further Comments

### 9.1  Additional Licensor

Parts of the code for E04STF are distributed according to terms imposed by another licensor. Please refer to Library Licensors for further details.

## 10  Example

See Section 10 in E04STF.

E04RGF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual