The routine may be called by the names e04taf or nagf_opt_handle_add_vars.
After the handle has been initialized (e.g., e04raf has been called),
e04taf may be used to define new unconstrained continuous variables to the problem. If denotes the current number of variables in the model, the total number of variables will be and the new variables will be indexed by . 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.
1: – 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: – IntegerInput
On entry: , the number of decision variables to add to the problem.
3: – IntegerOutput
On exit: , the new total number of the variables in the problem.
4: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
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.
The problem cannot be modified right now, the solver is running.
On entry, . Constraint: .
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e04taf is not threaded in any implementation.
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 and . The goal for the factory is to determine the quantities and of each chemical to maximize profit under the following circumstances:
•a unit of weighs kg and a unit of weighs kg;
•the total daily production cannot exceed kg to match the transport capabilities;
•the factory generates $ profit for each unit of and $ profit for each unit of ;
•both products need to use the same machine as part of their respective processes; a unit of requires minutes of machine time while a unit of requires minutes; the machine can only function for minutes daily;
•a unit of uses square metres of packing material while a unit of uses square metres; square metres of packing materials are available each day;
•production of is limited to units per day.
Note that since the chemicals are considered fluid, the quantities and are not limited to integer values.
We can now formulate the problem as a linear program:
If the factory expands its capabilities and is now capable of producing a new chemical with:
•a unit of takes minutes on the common machine;
•a unit of takes square metres of packaging material;
•a unit of weighs kg;
•a unit of generates $ profit;
•production of is limited to units per day.
The problem becomes:
At a later date, regulation changes require that products and 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: