# NAG FL Interfacee04rgf (handle_​set_​nlnobj)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine e04rgf (
 Integer, Intent (In) :: nnzfd, idxfd(nnzfd) Integer, Intent (Inout) :: ifail Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04rgf_ (void **handle, const Integer *nnzfd, const Integer idxfd[], Integer *ifail)
The routine may be called by the names e04rgf or nagf_opt_handle_set_nlnobj.

## 3Description

After the handle has been initialized (e.g., e04raf has been called), 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. If the objective function has already been defined, it will be overwritten and its Hessian (or the Hessian of the Lagrangian) will be removed. If e04rgf is called with no nonzeroes in the sparsity pattern, any existing objective function is removed, no new one is added and the problem will be solved as a feasible point problem.
This objective function will typically be used for nonlinear programming problems (NLP) of the kind:
 $minimize x∈ℝn f(x) (a) subject to lg≤g(x)≤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 for e04stf). See Section 3.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

## 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{nnzfd}$Integer Input
On entry: the number of nonzero elements in the sparse gradient vector of the objective function.
Constraint: ${\mathbf{nnzfd}}\ge 0$.
3: $\mathbf{idxfd}\left({\mathbf{nnzfd}}\right)$Integer array Input
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$ is the current number of decision variables in the model.
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: $\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}}=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$
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

e04rgf is not threaded in any implementation.