# NAG C Library Function Document

## 1Purpose

nag_opt_handle_set_nlnconstr (e04rkc) is a part of the NAG optimization modelling suite and defines the number of nonlinear constraints of the problem as well as the sparsity structure of their first derivatives.

## 2Specification

 #include #include
 void nag_opt_handle_set_nlnconstr (void *handle, Integer ncnln, const double bl[], const double bu[], Integer nnzgd, const Integer irowgd[], const Integer icolgd[], NagError *fail)

## 3Description

After the initialization function nag_opt_handle_init (e04rac) has been called, nag_opt_handle_set_nlnconstr (e04rkc) may be used to define the nonlinear constraints ${l}_{g}\le g\left(x\right)\le {u}_{g}$ of the problem unless the nonlinear constraints have already been defined. This 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)
where $n$ is the number of the decision variables $x$, ${m}_{g}$ is the number of the nonlinear constraints (in (1)(b)) and $g\left(x\right)$, ${l}_{g}$ and ${u}_{g}$ are ${m}_{g}$-dimensional vectors.
Note that upper and lower bounds are specified for all the constraints. This form allows full generality in specifying various types of constraint. In particular, the $j$th constraint may be defined as an equality by setting ${l}_{j}={u}_{j}$. If certain bounds are not present, the associated elements ${l}_{j}$ or ${u}_{j}$ may be set to special values that are treated as $-\infty$ or $+\infty$. See the description of the optional parameter ${\mathbf{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 function and any later alterations to ${\mathbf{Infinite Bound Size}}$ will not affect these constraints.
Since each nonlinear constraint is most likely to involve a small subset of the decision variables, the partial derivatives of the constraint functions with respect to those variables are best expressed as a sparse Jacobian matrix of ${m}_{g}$ rows and $n$ columns. The row and column positions of all the nonzero derivatives must be registered with the handle through nag_opt_handle_set_nlnconstr (e04rkc).
The values of the nonlinear constraint functions and their nonzero gradients at particular points in the decision variable space will be communicated to the NLP solver by user-supplied functions (e.g., confun and congrd for nag_opt_handle_solve_ipopt (e04stc)).
See nag_opt_handle_init (e04rac) for more details.

None.

## 5Arguments

1:    $\mathbf{handle}$void *Input
On entry: the handle to the problem. It needs to be initialized by nag_opt_handle_init (e04rac) and must not be changed.
2:    $\mathbf{ncnln}$IntegerInput
On entry: ${m}_{g}$, the number of nonlinear constraints (number of rows of the Jacobian matrix).
If ${\mathbf{ncnln}}=0$, no nonlinear constraints will be defined and bl, bu, nnzgd, irowgd and icolgd will not be referenced and may be NULL.
Constraint: ${\mathbf{ncnln}}\ge 0$.
3:    $\mathbf{bl}\left[{\mathbf{ncnln}}\right]$const doubleInput
4:    $\mathbf{bu}\left[{\mathbf{ncnln}}\right]$const doubleInput
On entry: bl and bu define lower and upper bounds of the nonlinear constraints, ${l}_{g}$ and ${u}_{g}$, respectively. To define the $j$th constraint as equality, set ${\mathbf{bl}}\left[j-1\right]={\mathbf{bu}}\left[j-1\right]=\beta$, where $\left|\beta \right|<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left[j-1\right]\le -\mathit{bigbnd}$; to specify a nonexistent upper bound, set ${\mathbf{bu}}\left[j-1\right]\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{bl}}\left[\mathit{j}-1\right]\le {\mathbf{bu}}\left[\mathit{j}-1\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$;
• ${\mathbf{bl}}\left[\mathit{j}-1\right]<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$;
• ${\mathbf{bu}}\left[\mathit{j}-1\right]>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$.
5:    $\mathbf{nnzgd}$IntegerInput
On entry: nnzgd gives the number of nonzeros in the Jacobian matrix.
Constraint: if ${\mathbf{ncnln}}>0$, ${\mathbf{nnzgd}}>0$.
6:    $\mathbf{irowgd}\left[{\mathbf{nnzgd}}\right]$const IntegerInput
7:    $\mathbf{icolgd}\left[{\mathbf{nnzgd}}\right]$const IntegerInput
On entry: arrays irowgd and icolgd store the sparsity structure (pattern) of the Jacobian matrix as nnzgd nonzeros in coordinate storage (CS) format (see Section 2.1.1 in the f11 Chapter Introduction). The matrix has dimensions ${\mathbf{ncnln}}×n$. irowgd specifies one-based row indices and icolgd specifies one-based column indices. No particular order of elements is expected, but elements should not repeat and the same order should be used when the Jacobian is evaluated for the solver, e.g., the value of $\frac{\partial {g}_{i}}{\partial {x}_{j}}$ where $i={\mathbf{irowgd}}\left[l-1\right]$ and $j={\mathbf{icolgd}}\left[\mathit{l}-1\right]$ should be stored in ${\mathbf{gdx}}\left[\mathit{l}-1\right]$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$.
Constraints:
• $1\le {\mathbf{irowgd}}\left[\mathit{l}-1\right]\le {\mathbf{ncnln}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$;
• $1\le {\mathbf{icolgd}}\left[\mathit{l}-1\right]\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$.
8:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
A set of nonlinear constraints has already been defined.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_BOUND
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{bl}}\left[j-1\right]=〈\mathit{\text{value}}〉$, $\mathit{bigbnd}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{bl}}\left[j-1\right]<\mathit{bigbnd}$.
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{bl}}\left[j-1\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{bu}}\left[j-1\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{bl}}\left[j-1\right]\le {\mathbf{bu}}\left[j-1\right]$.
On entry, $j=〈\mathit{\text{value}}〉$, ${\mathbf{bu}}\left[j-1\right]=〈\mathit{\text{value}}〉$, $\mathit{bigbnd}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{bu}}\left[j-1\right]>-\mathit{bigbnd}$.
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 nag_opt_handle_init (e04rac) or it has been corrupted.
NE_INT
On entry, ${\mathbf{ncnln}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ncnln}}\ge 0$.
On entry, ${\mathbf{nnzgd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nnzgd}}>0$.
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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_INVALID_CS
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{icolgd}}\left[\mathit{i}-1\right]=〈\mathit{\text{value}}〉$ and $n=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{icolgd}}\left[\mathit{i}-1\right]\le n$.
On entry, $i=〈\mathit{\text{value}}〉$, ${\mathbf{irowgd}}\left[\mathit{i}-1\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{ncnln}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{irowgd}}\left[\mathit{i}-1\right]\le {\mathbf{ncnln}}$.
On entry, more than one element of structural Jacobian matrix has row index $〈\mathit{\text{value}}〉$ and column index $〈\mathit{\text{value}}〉$.
Constraint: each element of structural Jacobian matrix must have a unique row and column index.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_PHASE
The Hessian of the nonlinear objective has already been defined, nonlinear constraints cannot be added.
The problem cannot be modified in this phase any more, the solver has already been called.

Not applicable.

## 8Parallelism and Performance

nag_opt_handle_set_nlnconstr (e04rkc) is not threaded in any implementation.