# NAG CL Interfacee04rgc (handle_​set_​nlnobj)

## 1Purpose

e04rgc 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

 #include
 void e04rgc (void *handle, Integer nnzfd, const Integer idxfd[], NagError *fail)
The function may be called by the names: e04rgc or nag_opt_handle_set_nlnobj.

## 3Description

After the initialization function e04rac has been called (and unless the objective function has already been defined), e04rgc 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 for e04stc). See Section 4.1 in the E04 Chapter Introduction for more details about the NAG optimization modelling suite.

None.

## 5Arguments

1: $\mathbf{handle}$void * Input
On entry: the handle to the problem. It needs to be initialized by e04rac and must not be changed before the call to e04rgc.
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]$const Integer 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$, the number of decision variables in the problem, was set in nvar during the initialization of the handle by e04rac.
If ${\mathbf{nnzfd}}=0$, the objective is assumed to be zero and the array idxfd will not be referenced and may be NULL.
Constraints:
• $1\le {\mathbf{idxfd}}\left[\mathit{i}-1\right]\le n$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzfd}}$;
• ${\mathbf{idxfd}}\left[\mathit{i}-1\right]<{\mathbf{idxfd}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{nnzfd}}-1$.
4: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
The objective function has already been defined.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_HANDLE
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 e04rac or it has been corrupted.
NE_INT
On entry, ${\mathbf{nnzfd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nnzfd}}\ge 0$.
NE_INTARR
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{idxfd}}\left[i-1\right]=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{idxfd}}\left[i-1\right]\le n$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_INCREASING
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{idxfd}}\left[i-1\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{idxfd}}\left[i\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{idxfd}}\left[\mathit{i}-1\right]<{\mathbf{idxfd}}\left[i\right]$ (ascending order).
NE_PHASE
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.

Not applicable.

## 8Parallelism and Performance

e04rgc is not threaded in any implementation.

None.

## 10Example

See Section 10 in e04stc.