The routine may be called by the names h02bff or nagf_mip_ilp_mpsx.
3Description
h02bff solves Linear Programming (LP) or integer programming (IP) problems specified in MPSX (see IBM (1971)) input format. It calls either e04mff/e04mfa (to solve an LP problem) or h02bbfandh02bzf (to solve an IP problem); these routines are designed to solve problems of the form
$$\underset{x\in {R}^{n}}{\mathrm{minimize}}\phantom{\rule{0.25em}{0ex}}{c}^{\mathrm{T}}x\text{\hspace{1em} subject to \hspace{1em}}l\le \left(\begin{array}{c}x\\ Ax\end{array}\right)\le u$$
where $c$ is an $n$-element vector and $A$ is an $m\times n$ matrix (i.e., there are $n$ variables and $m$ general linear constraints). h02bbf is used if at least one of the variables is restricted to take an integer value at the optimum solution. The document for h02buf should be consulted for a detailed description of the MPSX format.
In the MPSX data file the first free row, that is a row defined with the row type n, is taken as the objective row. Similarly, if there are more than one RHS, RANGES or BOUNDS sets, then the first set is used for the optimization. h02bff also prints the solution to the problem using the row and column names specified in the MPSX data file (by calling h02bvf).
4References
IBM (1971) MPSX – Mathematical programming system Program Number 5734 XM4 IBM Trade Corporation, New York
5Arguments
1: $\mathbf{infile}$ – IntegerInput
On entry: the unit number associated with the MPSX data file.
On entry: an upper limit for the number of variables in the problem.
Constraint:
${\mathbf{maxn}}\ge 1$.
3: $\mathbf{maxm}$ – IntegerInput
On entry: an upper limit for the number of constraints (including the objective) in the problem.
Constraint:
${\mathbf{maxm}}\ge 1$.
4: $\mathbf{optim}$ – Character(3)Input
On entry: specifies the direction of the optimization. optim must be set to 'MIN' for minimization and to 'MAX' for maximization.
Constraint:
${\mathbf{optim}}=\text{'MIN'}$ or $\text{'MAX'}$.
5: $\mathbf{xbldef}$ – Real (Kind=nag_wp)Input
On entry: the default lower bound to be used for the variables in the problem when none is specified in the BOUNDS section of the MPSX data file. For a standard LP or IP problem xbldef would normally be set to zero.
6: $\mathbf{xbudef}$ – Real (Kind=nag_wp)Input
On entry: the default upper bound to be used for the variables in the problem when none is specified in the BOUNDS section of the MPSX data file. For a standard LP or IP problem xbudef would normally be set to ‘infinity’ (i.e., ${\mathbf{xbudef}}\ge {10}^{20}$).
On entry: the amount of printout produced by e04mff/e04mfaorh02bbf, as indicated below. For a description of the printed output see Section 9.2 in e04mff/e04mfa or Section 5.1 in h02bbf (as appropriate). All output is written to the current advisory message unit (as defined by x04abf).
One line of output for each node investigated and the final IP solution.
$10$
The original LP solution (first node) with dummy names for the rows and columns, one line of output for each node investigated and the final IP solution with MPSX names for the rows and columns.
9: $\mathbf{n}$ – IntegerOutput
On exit: $n$, the actual number of variables in the problem.
10: $\mathbf{m}$ – IntegerOutput
On exit: $m$, the actual number of general linear constraints in the problem.
11: $\mathbf{x}\left({\mathbf{maxn}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the solution to the problem, stored in ${\mathbf{x}}\left(1\right),{\mathbf{x}}\left(2\right),\dots ,{\mathbf{x}}\left({\mathbf{n}}\right)$.
${\mathbf{x}}\left(\mathit{i}\right)$ is the value of the variable whose MPSX name is stored in ${\mathbf{crname}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
On exit: the first (${\mathbf{n}}+{\mathbf{m}}$) elements contain ISTATE (the status of the constraints in the working set at the solution). Further details can be found in Section 5 in e04mff/e04mfaorh02bzf (as appropriate).
14: $\mathbf{liwork}$ – IntegerInput
On entry: the dimension of the array iwork as declared in the (sub)program from which h02bff is called.
Constraints:
for an LP problem, ${\mathbf{liwork}}\ge 4\times {\mathbf{maxn}}+{\mathbf{maxm}}+3$;
for an IP problem, ${\mathbf{liwork}}\ge (25+{\mathbf{maxn}}+{\mathbf{maxm}})\times {\mathbf{maxdpt}}+7\times {\mathbf{maxn}}+2\times \phantom{\rule{0ex}{0ex}}{\mathbf{maxm}}+4$.
15: $\mathbf{rwork}\left({\mathbf{lrwork}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the first (${\mathbf{n}}+{\mathbf{m}}$) elements contain BL (the lower bounds), the next (${\mathbf{n}}+{\mathbf{m}}$) elements contain BU (the upper bounds) and the next (${\mathbf{n}}+{\mathbf{m}}$) elements contain CLAMDA (the Lagrange-multipliers). Further details can be found in Section 5 in e04mff/e04mfaorh02bzf (as appropriate). Note that for an IP problem the contents of BL and BU may not be the same as those originally specified in the MPSX data file and/or via the arguments xbldef and xbudef.
16: $\mathbf{lrwork}$ – IntegerInput
On entry: the dimension of the array rwork as declared in the (sub)program from which h02bff is called.
Constraints:
for an LP problem, ${\mathbf{lrwork}}\ge 2\times \mathrm{MIN}{({\mathbf{maxn}},{\mathbf{maxm}}+1)}^{2}+{\mathbf{maxm}}\times {\mathbf{maxn}}+\phantom{\rule{0ex}{0ex}}12\times {\mathbf{maxn}}+9\times {\mathbf{maxm}}$;
for an IP problem, ${\mathbf{lrwork}}\ge {\mathbf{maxdpt}}\times ({\mathbf{maxn}}+1)+2\times \mathrm{MIN}{({\mathbf{maxn}},{\mathbf{maxm}}+1)}^{2}+{\mathbf{maxm}}\times \phantom{\rule{0ex}{0ex}}{\mathbf{maxn}}+19\times {\mathbf{maxn}}+15\times {\mathbf{maxm}}$.
17: $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $\mathrm{-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 $\mathrm{-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 $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ 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 $\mathrm{-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 problem does not have a feasible integer solution.
Weak LP solution.
${\mathbf{ifail}}=2$
The LP solution is unbounded.
${\mathbf{ifail}}=3$
The LP does not have a feasible solution, i.e., it was not possible to satisfy all the constraints to within the feasibility tolerance (defined internally as $\sqrt{\mathit{machineprecision}}$). See Section 9.
${\mathbf{ifail}}=4$
Iteration limit (defined internally as $\mathrm{max}\phantom{\rule{0.125em}{0ex}}(50,5(n+m))$) reached without finding a solution. (See Section 9.)
${\mathbf{ifail}}=5$
On entry, ${\mathbf{infile}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: $0\le {\mathbf{infile}}\le 2147483647$.
On entry, ${\mathbf{maxdpt}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{maxdpt}}\ge 2$.
On entry, ${\mathbf{maxm}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{maxm}}\ge 1$.
On entry, ${\mathbf{maxn}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{maxn}}\ge 1$.
On entry, not enough integer workspace to read data file: ${\mathbf{liwork}}=\u27e8\mathit{\text{value}}\u27e9$.
On entry, not enough integer workspace to solve problem: ${\mathbf{liwork}}=\u27e8\mathit{\text{value}}\u27e9$liwork must be at least $\u27e8\mathit{\text{value}}\u27e9$.
On entry, not enough real workspace to read data file: ${\mathbf{lrwork}}=\u27e8\mathit{\text{value}}\u27e9$.
On entry, not enough real workspace to solve problem: ${\mathbf{lrwork}}=\u27e8\mathit{\text{value}}\u27e9$lrwork must be at least $\u27e8\mathit{\text{value}}\u27e9$.
On entry, ${\mathbf{optim}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{optim}}=\text{'MIN'}$ or $\text{'MAX'}$.
On entry, ${\mathbf{xbldef}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{xbudef}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{xbldef}}\le {\mathbf{xbudef}}$.
${\mathbf{ifail}}=6$
A serious error has occurred. Check all subroutine calls and array dimensions.
${\mathbf{ifail}}=7$
Search of a branch was terminated due to iteration limit.
The solution returned may not be optimal. See Section 9.
maxdpt is too small to solve the problem: ${\mathbf{maxdpt}}=\u27e8\mathit{\text{value}}\u27e9$.
${\mathbf{ifail}}=9$
The IP solution returned is the best solution for the number of nodes investigated in the branch and bound tree.
No feasible integer point was found, i.e., it was not possible to satisfy all the integer variables to within the integer feasibility tolerance (defined internally as ${10}^{-5}$). See Section 9.
${\mathbf{ifail}}=10$
No feasible solution was found for the number of nodes investigated in the branch and bound tree.
${\mathbf{ifail}}=11$
Not enough workspace to solve problem.
${\mathbf{ifail}}=i\text{}<0$
Either maxm and/or maxn are too small or the MPSX data file is nonstandard and/or corrupt.This corresponds to ${\mathbf{ifail}}=-i$ in Section 6 in h02buf.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please
contact NAG.
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.
7Accuracy
h02bff implements a numerically stable active set strategy and returns solutions that are as accurate as the condition of the problem allows on the machine.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
h02bff is not thread safe and should not be called from a multithreaded user program. Please see Section 1 in FL Interface Multithreading for more information on thread safety.
h02bff makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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.
9Further Comments
For an LP problem only:
If ${\mathbf{ifail}}={\mathbf{2}}$ on exit, you can obtain more information by making separate calls to h02buf, e04mff/e04mfa and h02bvf (in that order). Note that this will (by default) cause the final LP solution to be printed twice on the current advisory message unit (see x04abf), once with dummy names for the rows and columns and once with user-supplied names. To suppress the printout of the final LP solution with dummy names for the rows and columns
, include the statement
If ${\mathbf{ifail}}={\mathbf{3}}$ on exit, you are recommended to reset the value of the feasibility tolerance (via Feasibility Tolerance) and rerun h02bff. (Further advice is given under the description of ${\mathbf{ifail}}={\mathbf{3}}$ in Section 6 in e04mff/e04mfa.)
For example, to reset the value of the feasibility tolerance to $0.01$, include the statement
If ${\mathbf{ifail}}={\mathbf{4}}$ on exit, you are recommended to increase the maximum number of iterations allowed before termination (via Iteration Limit) and rerun h02bff.
For example, to increase the maximum number of iterations to $500$, include the statement
Call e04mhf/e04mha(' Iteration Limit = 500 ')
prior to calling h02bff.
Note that h02buf uses an ‘infinite’ bound size of ${10}^{20}$ in the definition of $l$ and $u$. In other words, any element of $u$ greater than or equal to ${10}^{20}$ will be regarded as $+\infty $ (and similarly any element of $l$ less than or equal to $-{10}^{20}$ will be regarded as $-\infty $). If this value is deemed to be inappropriate, you are recommended to reset the value of the ‘infinite’ bound size (via Infinite Bound Size) and make any necessary changes to bl and/or bu prior to calling e04mff/e04mfa.
For example, to reset the value of the ‘infinite’ bound size to $10000$, include the statement
If ${\mathbf{ifail}}={\mathbf{2}}$, ${\mathbf{3}}$, ${\mathbf{4}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$ on exit, you can obtain more information by making separate calls to h02bbf,h02buf,h02bvfandh02bzf (in that order).
Note that h02buf uses an ‘infinite’ bound size of ${10}^{20}$ in the definition of $l$ and $u$. In other words, any element of $u$ greater than or equal to ${10}^{20}$ will be regarded as $+\infty $ (and similarly any element of $l$ less than or equal to $-{10}^{20}$ will be regarded as $-\infty $). If this value is deemed to be inappropriate, you are recommended to reset the value of the argument bigbnd (as described in h02bbf) and make any necessary changes to BL and/or BU prior to calling h02bbf.
10Example
This example solves the same problem as the example for h02buf, except that it treats it as an IP problem.
One of the applications of integer programming is to the so-called diet problem. Given the nutritional content of a selection of foods, the cost of each food, the amount available of each food and the consumer's minimum daily nutritional requirements, the problem is to find the cheapest combination. This gives rise to the following problem:
The rows of $A$ correspond to energy, protein and calcium and the columns of $A$ correspond to oatmeal, chicken, eggs, milk, pie and bacon respectively.
The MPSX data representation of this problem is given in Section 10.2.