## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e04taf is a part of the NAG optimization modelling suite and adds new variables to the problem.

## 2Specification

Fortran Interface
 Integer, Intent (In) :: nadd Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: nvar Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void e04taf_ (void **handle, const Integer *nadd, Integer *nvar, Integer *ifail)
The routine may be called by the names e04taf or nagf_opt_handle_add_vars.

## 3Description

After the handle has been initialized (e.g., e04raf has been called), e04taf may be used to define ${n}_{\mathrm{add}}$ new unconstrained continuous variables to the problem. If ${n}_{\mathrm{now}}$ denotes the current number of variables in the model, the total number of variables will be $n={n}_{\mathrm{now}}+{n}_{\mathrm{add}}$ and the new variables will be indexed by ${n}_{\mathrm{now}}+1,\dots ,{n}_{\mathrm{now}}+{n}_{\mathrm{add}}$. The objective function or constraints, if already defined in the model, won't be affected as they will be naturally extended as if the new variables were not referred during their definition (e.g., for a linear objective function the coefficients for the new variables would be set to zero). If the new variables should enter any already defined parts of the problem, you should modify them with the appropriate routines from the suite.
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{nadd}$Integer Input
On entry: ${n}_{\mathrm{add}}$, the number of decision variables to add to the problem.
Constraint: ${\mathbf{nadd}}>0$.
3: $\mathbf{nvar}$Integer Output
On exit: $n$, the new total number of the variables in the problem.
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{nadd}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nadd}}>0$.
${\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

e04taf is not threaded in any implementation.

None.

## 10Example

This example demonstrates, using a simple production-planning problem, how to use the routines of the NAG optimization modelling suite to edit and solve different variants of the problem.
We consider a situation where a factory can manufacture two different chemicals ${A}_{1}$ and ${A}_{2}$. The goal for the factory is to determine the quantities ${x}_{1}$ and ${x}_{2}$ of each chemical to maximize profit under the following circumstances:
• a unit of ${A}_{1}$ weighs $40$kg and a unit of ${A}_{2}$ weighs $80$kg;
• the total daily production cannot exceed $16000$kg to match the transport capabilities;
• the factory generates \$$2$ profit for each unit of ${A}_{1}$ and \$$4.5$ profit for each unit of ${A}_{2}$;
• both products need to use the same machine as part of their respective processes; a unit of ${A}_{1}$ requires $1.2$ minutes of machine time while a unit of ${A}_{2}$ requires $3$ minutes; the machine can only function for $1500$ minutes daily;
• a unit of ${A}_{1}$ uses $6$ square metres of packing material while a unit of ${A}_{2}$ uses $10$ square metres; $6000$ square metres of packing materials are available each day;
• production of ${A}_{2}$ is limited to $100$ units per day.
Note that since the chemicals are considered fluid, the quantities ${x}_{1}$ and ${x}_{2}$ are not limited to integer values.
We can now formulate the problem as a linear program:
 $maximize x∈ℝn 2x1+4.5x2 subject to 1.2x1+3x2≤1500 (machine time constraint) 6x1+10x2≤6000 (packaging material constraint) 40x1+80x2≤16000 (transport constraint) 0≤x1 (capacity constraint) 0≤x2≤100 (capacity constraint)$
If the factory expands its capabilities and is now capable of producing a new chemical ${A}_{3}$ with:
• a unit of ${A}_{3}$ takes $5$ minutes on the common machine;
• a unit of ${A}_{3}$ takes $12$ square metres of packaging material;
• a unit of ${A}_{3}$ weighs $120$kg;
• a unit of ${A}_{3}$ generates \$$7$ profit;
• production of ${A}_{3}$ is limited to $50$ units per day.
The problem becomes:
 $maximize x∈ℝn 2x1+4.5x2+7x3 subject to 1.2x1+3x2+5x3≤1500 (machine time constraint) 6x1+10x2+12x3≤6000 (packaging material constraint) 40x1+80x2+120x3≤16000 (transport constraint) 0≤x1 (capacity constraint) 0≤x2≤100 (capacity constraint) 0≤x3≤50 (capacity constraint)$
At a later date, regulation changes require that products ${A}_{2}$ and ${A}_{3}$ follow a rigorous quality assurance test before being sent to market. Now the factory is only able to process a total of 100 units per day which amounts to adding the following constraint to our linear program:
 $x2+x3≤100 (regulation constraint)$

### 10.1Program Text

Program Text (e04tafe.f90)

None.

### 10.3Program Results

Program Results (e04tafe.r)