# NAG FL Interfacee04tcf (handle_​disable)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e04tcf is a part of the NAG optimization modelling suite and allows you to disable various components of an existing model.

## 2Specification

Fortran Interface
 Subroutine e04tcf ( comp, lidx, idx,
 Integer, Intent (In) :: lidx, idx(lidx) Integer, Intent (Inout) :: ifail Character (*), Intent (In) :: comp Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04tcf_ (void **handle, const char *comp, const Integer *lidx, const Integer idx[], Integer *ifail, const Charlen length_comp)
The routine may be called by the names e04tcf or nagf_opt_handle_disable.

## 3Description

e04tcf and e04tbf form a pair of routines which allow you to quickly remove parts of the model and add them back. This is particularly useful when a sequence of similar problems needs to be solved, to identify how a particular constraint or variable affects the solution, or to switch between previously defined constraints which are somewhat related to each other.
After the model has been fully or partially built by calling routines of the NAG optimization modelling suite, e04tcf may be used to disable some components (variables or constraints) from the model. To identify the part of the model to be disabled, the component type needs to be specified in comp together with the appropriate component indices, such as variable or linear constraint numbers, in an index set idx. e04tbf may be used to bring them back (to enable them). Note that a disabled component may still be edited but would not be automatically re-enabled; a disabled component can only be enabled by calling e04tbf. By default, all newly created components of the model are enabled. Calling this routine on disabled components is not an error but has no effect.
In general, disabled components are still present in the model with respect to the numbering of the variables and constraints (e.g., disabling a variable will not renumber the remaining variables) but the solver will ignore them and work internally with a smaller model formulation. The solver will communicate with you (e.g., return results) in arrays matching the full size of the model and the elements corresponding to the disabled components will be set to NaN, which can be tested for via a call to x07abf. The effect of disabling components is described in detail as follows:
Decision variables
As a rule, a disabled variable behaves as if the existing parts of the model were defined without the variable in the first place. Matching elements in all other model components are ignored. In particular, the following applies:
• elements in the linear or quadratic objective function corresponding to the disabled variables are ignored, as if they were set to 0;
• the same applies to the linear and quadratic constraints as well as to the matrix inequalities, however, note that this can generate infeasible constraints (for instance, $-2\le x+y\le -1$ with disabled $x$ and $y$ is interpreted as $-2\le 0\le -1$ and thus would be infeasible);
• the box bounds of the disabled variables are ignored;
• if a disabled variable is present in a cone constraint and the cone constraint becomes invalid (e.g., the length of the cone is just one or the first cone variable is disabled), the whole constraint is disabled as well;
• any callbacks for nonlinear function evaluation will have on input the full $x$ vector, however, all disabled variables are set to NaN and the matching elements in the returned derivatives are not referenced.
An alternative approach is to fix the variable to a predefined value by changing its simple bounds using e04tdf instead of disabling it.
Linear constraints, Quadratic constraints, Second-order cones, Matrix inequalities
Disabled constraints do not restrict the feasible set, they are eliminated before the model is presented to the solver. As the constraints are not renumbered, the position for Lagrangian multipliers (u, uc, ua) is unchanged and NaNs are returned in place of disabled constraints.
Nonlinear constraints
The disabled nonlinear constraints do not affect the feasible set and their Lagrangian multipliers are returned as NaNs in their expected location. The values of the nonlinear constraints and their partial derivatives are passed to the solver via callbacks, such as, objfun and objgrd. The size of all array arguments in the callbacks remain the same, irrespective of the number of disabled constraints. On exit from the callback any elements in these arrays corresponding to the disabled constraints are not referenced.
Nonlinear residuals
The disabled residuals in the nonlinear least squares objective function $\sum {r}_{j}^{2}\left(x\right)$ are skipped in the sum and their values are not referenced.
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{comp}$Character(*) Input
On entry: the type of the component of the model to be disabled. comp is case insensitive.
${\mathbf{comp}}=\text{'X'}$, $\text{'VAR'}$ or $\text{'VARIABLE'}$
Decision variables $x$.
${\mathbf{comp}}=\text{'LC'}$ or $\text{'LINEAR CONSTRAINT'}$
Linear constraints (see e04rjf).
${\mathbf{comp}}=\text{'QC'}$ or $\text{'QUADRATIC CONSTRAINT'}$
Quadratic constraints (see e04rsf and e04rtf).
${\mathbf{comp}}=\text{'NLC'}$ or $\text{'NONLINEAR CONSTRAINT'}$
Nonlinear constraints (see e04rkf).
${\mathbf{comp}}=\text{'CN'}$ or $\text{'CONE'}$
${\mathbf{comp}}=\text{'MI'}$ or $\text{'MATRIX INEQUALITY'}$
Matrix inequality constraints (see e04rnf).
${\mathbf{comp}}=\text{'NLS'}$ or $\text{'RESIDUAL'}$
Nonlinear residuals ${r}_{i}\left(x\right)$ in the nonlinear least squares objective function (see e04rmf).
Constraint: ${\mathbf{comp}}=\text{'X'}$, $\text{'VAR'}$, $\text{'VARIABLE'}$, $\text{'LC'}$, $\text{'LINEAR CONSTRAINT'}$, $\text{'QC'}$, $\text{'QUADRATIC CONSTRAINT'}$, $\text{'NLC'}$, $\text{'NONLINEAR CONSTRAINT'}$, $\text{'CN'}$, $\text{'CONE'}$, $\text{'MI'}$, $\text{'MATRIX INEQUALITY'}$, $\text{'NLS'}$ or $\text{'RESIDUAL'}$.
3: $\mathbf{lidx}$Integer Input
On entry: the number of elements in the index set.
Constraint: ${\mathbf{lidx}}\ge 1$.
4: $\mathbf{idx}\left({\mathbf{lidx}}\right)$Integer array Input
On entry: the index set of components comp to be disabled. The elements may be supplied in any order.
Constraint: $1\le {\mathbf{idx}}\left(\mathit{i}\right)\le M$, for $\mathit{i}=1,2,\dots ,{\mathbf{lidx}}$, where $M$ is the total number of the given components (e.g., decision variables) in the problem.
5: $\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}}=5$
On entry, ${\mathbf{lidx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lidx}}\ge 1$.
${\mathbf{ifail}}=6$
On entry, ${\mathbf{comp}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{comp}}=\text{'X'}$, $\text{'LC'}$, $\text{'QC'}$, $\text{'NLC'}$, $\text{'CN'}$, $\text{'MI'}$ or $\text{'NLS'}$.
${\mathbf{ifail}}=8$
On entry, ${\mathbf{comp}}=⟨\mathit{\text{value}}⟩$, $i=⟨\mathit{\text{value}}⟩$, ${\mathbf{idx}}\left(i\right)=⟨\mathit{\text{value}}⟩$ and $M=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{idx}}\left(i\right)\le M$.
${\mathbf{ifail}}=9$
On entry, ${\mathbf{comp}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{idx}}\left(i\right)=⟨\mathit{\text{value}}⟩$.
This component has been deleted.
This error can only occur when trying to enable a cone constraint that has been deleted by setting its size to $0$ with e04rbf.
${\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

e04tcf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10Example

This example shows how to use the NAG optimization modelling suite to edit a nonlinear least squares problem. In particular, outlier data is disabled in the NAG handle without having to redefine the full problem.
We use e04ggf to fit a nonlinear least squares problem of the form
 $minimize x∈ℝp ∑ i=1 30 (f(ti,x)-yi)2$
where $p=5$, $x=\left(a,b,c,d,\omega \right)$ and $f\left(t\right)=a{t}^{2}+bt+c+d\mathrm{sin}\left(\omega t\right)$ to some simulated data $\left\{\left({t}_{i},{y}_{i}\right)\right\}$.
Thirty data points were simulated using $\left(a=0.3,b=1.0,c=0.01,d=0.2,\omega =5.0\right)$ with ${t}_{i}$ uniformly spread in $\left[\mathrm{-1.0},\mathrm{1.0}\right]$ and ${y}_{i}=f\left({t}_{i},x\right)+{\epsilon }_{i}$ where ${\epsilon }_{i}$ is random noise. In addition two data points, ${y}_{10}$ and ${y}_{20}$, were modified to simulate the presence of outlier data.
We show how to solve three variants of the same problem:
• with the full data set;
• with the outlier residuals disabled;
• with the outlier corrected and enabled, and with the first parameter fixed to its known value 0.3.

### 10.1Program Text

Program Text (e04tcfe.f90)

### 10.2Program Data

Program Data (e04tcfe.d)

### 10.3Program Results

Program Results (e04tcfe.r)