# NAG FL Interfacee04rkf (handle_​set_​nlnconstr)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e04rkf is a part of the NAG optimization modelling suite and defines or overwrites nonlinear constraints in the model, their number as well as the sparsity structure of their first derivatives.

## 2Specification

Fortran Interface
 Subroutine e04rkf ( bl, bu,
 Integer, Intent (In) :: ncnln, nnzgd, irowgd(nnzgd), icolgd(nnzgd) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: bl(ncnln), bu(ncnln) Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04rkf_ (void **handle, const Integer *ncnln, const double bl[], const double bu[], const Integer *nnzgd, const Integer irowgd[], const Integer icolgd[], Integer *ifail)
The routine may be called by the names e04rkf or nagf_opt_handle_set_nlnconstr.

## 3Description

After the handle has been initialized (e.g., e04raf has been called), e04rkf may be used to define the nonlinear constraints ${l}_{g}\le g\left(x\right)\le {u}_{g}$ of the problem. If the nonlinear constraints have already been defined, they will be overwritten and their Hessians (or the Hessian of the Lagrangian) will be removed. If e04rkf is called with ${m}_{g}=0$, existing nonlinear constraints are removed and no new ones are added. This 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)
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 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 routine and any later alterations to 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 e04rkf. 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 e04stf).
An individual set of bounds can be also modified by e04tdf. Note that it is also possible to temporarily disable and enable individual constraints in the model by calling e04tcf and e04tbf, respectively.
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{ncnln}$Integer Input
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 any existing nonlinear constraint will be removed from the model. In this case, bl, bu, nnzgd, irowgd and icolgd will not be referenced.
Constraint: ${\mathbf{ncnln}}\ge 0$.
3: $\mathbf{bl}\left({\mathbf{ncnln}}\right)$Real (Kind=nag_wp) array Input
4: $\mathbf{bu}\left({\mathbf{ncnln}}\right)$Real (Kind=nag_wp) array Input
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\right)={\mathbf{bu}}\left(j\right)=\beta$, where $|\beta |<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{bl}}\left(j\right)\le -\mathit{bigbnd}$; to specify a nonexistent upper bound, set ${\mathbf{bu}}\left(j\right)\ge \mathit{bigbnd}$.
Constraints:
• ${\mathbf{bl}}\left(\mathit{j}\right)\le {\mathbf{bu}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$;
• ${\mathbf{bl}}\left(\mathit{j}\right)<\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$;
• ${\mathbf{bu}}\left(\mathit{j}\right)>-\mathit{bigbnd}$, for $\mathit{j}=1,2,\dots ,{\mathbf{ncnln}}$.
5: $\mathbf{nnzgd}$Integer Input
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)$Integer array Input
7: $\mathbf{icolgd}\left({\mathbf{nnzgd}}\right)$Integer array Input
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\right)$ and $j={\mathbf{icolgd}}\left(\mathit{l}\right)$ should be stored in ${\mathbf{gdx}}\left(\mathit{l}\right)$ in congrd in e04stf, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$.
Constraints:
• $1\le {\mathbf{irowgd}}\left(\mathit{l}\right)\le {\mathbf{ncnln}}$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$;
• $1\le {\mathbf{icolgd}}\left(\mathit{l}\right)\le n$, for $\mathit{l}=1,2,\dots ,{\mathbf{nnzgd}}$.
8: $\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{ncnln}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ncnln}}\ge 0$.
On entry, ${\mathbf{nnzgd}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nnzgd}}>0$.
${\mathbf{ifail}}=8$
On entry, $i=⟨\mathit{\text{value}}⟩$, ${\mathbf{icolgd}}\left(\mathit{i}\right)=⟨\mathit{\text{value}}⟩$ and $n=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{icolgd}}\left(\mathit{i}\right)\le n$.
On entry, $i=⟨\mathit{\text{value}}⟩$, ${\mathbf{irowgd}}\left(\mathit{i}\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ncnln}}=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{irowgd}}\left(\mathit{i}\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.
${\mathbf{ifail}}=10$
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bl}}\left(j\right)=⟨\mathit{\text{value}}⟩$, $\mathit{bigbnd}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bl}}\left(j\right)<\mathit{bigbnd}$.
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bl}}\left(j\right)=⟨\mathit{\text{value}}⟩$ and ${\mathbf{bu}}\left(j\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bl}}\left(j\right)\le {\mathbf{bu}}\left(j\right)$.
On entry, $j=⟨\mathit{\text{value}}⟩$, ${\mathbf{bu}}\left(j\right)=⟨\mathit{\text{value}}⟩$, $\mathit{bigbnd}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{bu}}\left(j\right)>-\mathit{bigbnd}$.
${\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.