Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_mip_ilp_info (h02bz)

## Purpose

nag_mip_ilp_info (h02bz) extracts more information associated with the solution of an integer programming problem computed by nag_mip_ilp_dense (h02bb).

## Syntax

[bl, bu, clamda, istate, ifail] = h02bz(n, m, iwork, rwork)
[bl, bu, clamda, istate, ifail] = nag_mip_ilp_info(n, m, iwork, rwork)
Note: the interface to this routine has changed since earlier releases of the toolbox:
 At Mark 22: liwork and lrwork were removed from the interface

## Description

nag_mip_ilp_info (h02bz) extracts the following information associated with the solution of an integer programming problem computed by nag_mip_ilp_dense (h02bb). The upper and lower bounds used for the solution, the Lagrange-multipliers (costs), and the status of the variables at the solution.
In the branch and bound method employed by nag_mip_ilp_dense (h02bb), the arrays bl and bu are used to impose restrictions on the values of the integer variables in each sub-problem. That is, if the variable ${x}_{j}$ is restricted to take value ${v}_{j}$ in a particular sub-problem, then ${\mathbf{bl}}\left(j\right)={\mathbf{bu}}\left(j\right)={v}_{j}$ is set in the sub-problem. Thus, on exit from this function, some of the elements of bl and bu which correspond to integer variables may contain these imposed values, rather than those originally supplied to nag_mip_ilp_dense (h02bb).

None.

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
This must be the same argument n as supplied to nag_mip_ilp_dense (h02bb).
Constraint: ${\mathbf{n}}>0$.
2:     $\mathrm{m}$int64int32nag_int scalar
This must be the same argument m as supplied to nag_mip_ilp_dense (h02bb).
Constraint: ${\mathbf{m}}\ge 0$.
3:     $\mathrm{iwork}\left(\mathit{liwork}\right)$int64int32nag_int array
This must be the same argument iwork as supplied to nag_mip_ilp_dense (h02bb). It is used to pass information from nag_mip_ilp_dense (h02bb) to nag_mip_ilp_info (h02bz) and therefore the contents of this array must not be changed before calling nag_mip_ilp_info (h02bz).
4:     $\mathrm{rwork}\left(\mathit{lrwork}\right)$ – double array
This must be the same argument rwork as supplied to nag_mip_ilp_dense (h02bb). It is used to pass information from nag_mip_ilp_dense (h02bb) to nag_mip_ilp_info (h02bz) and therefore the contents of this array must not be changed before calling nag_mip_ilp_info (h02bz).

None.

### Output Parameters

1:     $\mathrm{bl}\left({\mathbf{n}}+{\mathbf{m}}\right)$ – double array
If nag_mip_ilp_dense (h02bb) exits with ${\mathbf{ifail}}={\mathbf{0}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$, the values in the array bl contain the lower bounds imposed on the integer solution for all the constraints. The first n elements contain the lower bounds on the variables, and the next m elements contain the lower bounds for the general linear constraints (if any).
2:     $\mathrm{bu}\left({\mathbf{n}}+{\mathbf{m}}\right)$ – double array
If nag_mip_ilp_dense (h02bb) exits with ${\mathbf{ifail}}={\mathbf{0}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$, the values in the array bu contain the upper bounds imposed on the integer solution for all the constraints. The first n elements contain the upper bounds on the variables, and the next m elements contain the upper bounds for the general linear constraints (if any).
3:     $\mathrm{clamda}\left({\mathbf{n}}+{\mathbf{m}}\right)$ – double array
If nag_mip_ilp_dense (h02bb) exits with ${\mathbf{ifail}}={\mathbf{0}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$, the values in the array clamda contain the values of the Lagrange-multipliers for each constraint with respect to the current working set. The first n elements contain the multipliers (reduced costs) for the bound constraints on the variables, and the next m elements contain the multipliers (shadow costs) for the general linear constraints (if any).
4:     $\mathrm{istate}\left({\mathbf{n}}+{\mathbf{m}}\right)$int64int32nag_int array
If nag_mip_ilp_dense (h02bb) exits with ${\mathbf{ifail}}={\mathbf{0}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$, the values in the array istate indicate the status of the constraints in the working set at an integer solution. Otherwise, istate indicates the composition of the working set at the final iterate. The significance of each possible value of ${\mathbf{istate}}\left(j\right)$ is as follows.
 ${\mathbf{istate}}\left(j\right)$ Meaning $-2$ The constraint violates its lower bound by more than tolfes (the feasibility tolerance, see nag_mip_ilp_dense (h02bb)). $-1$ The constraint violates its upper bound by more than tolfes. $\phantom{-}0$ The constraint is satisfied to within tolfes, but is not in the working set. $\phantom{-}1$ This inequality constraint is included in the working set at its lower bound. $\phantom{-}2$ This inequality constraint is included in the working set at its upper bound. $\phantom{-}3$ This constraint is included in the working set as an equality. This value of istate can occur only when ${\mathbf{bl}}\left(j\right)={\mathbf{bu}}\left(j\right)$. $\phantom{-}4$ This corresponds to an integer solution being declared with ${x}_{j}$ being temporarily fixed at its current value. This value of istate can occur only when ${\mathbf{ifail}}={\mathbf{0}}$, ${\mathbf{7}}$ or ${\mathbf{9}}$ on exit from nag_mip_ilp_dense (h02bb).
5:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}\le 0$, or ${\mathbf{m}}<0$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Not applicable.

None.

## Example

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:
minimize
 $cTx$
subject to
 $Ax≥b, 0≤x≤u,$
where
 $c= 3 24 13 9 20 19 T,x=x1,x2,x3,x4,x5,x6T$
is integer,
 $A= 110 205 160 160 420 260 4 32 13 8 4 14 2 12 54 285 22 80 , b= 2000 55 800$
and
 $u= 4 3 2 8 2 2 T$
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 following program solves the above problem to obtain the optimal integer solution and then examines the effect of increasing the energy required to $2200$ units.
```function h02bz_example

fprintf('h02bz example results\n\n');

% Find vector x of length n that Minimizes c.x subject to:
% bl(1:n) <= x <= bu(1:n) and m linear contraints
% bl(n+1:n+m) <= Ax <= bu(n+1:n_m)
n = int64(6);
m = int64(3);
a  = [110,  205,   160,   160,   420,   260;
4,   32,    13,     8,     4,    14;
2,   12,    54,   285,    22,    80];
bl = [  0;    0;     0;     0;     0;     0;   2000;     55;     800];
bu = [  4;    3;     2;     8;     2;     2;  1e+20;  1e+20;   1e+20];

% All of x is integer.
intvar = int64([1;  1;  1;  1;  1;  1]);
c      =         [3; 24; 13;  9; 20; 19];
% Initial guess
x      = zeros(6,1);

itmax  = int64(0);
msglvl = int64(0);
maxnod = int64(0);
intfst = int64(0);
toliv  = 0;
tolfes = 0;
bigbnd = 1e+20;
[itmax, toliv, tolfes, bigbnd, x, objmip, iwork, rwork, ifail] = ...
h02bb( ...
itmax, msglvl, a, bl, bu, intvar, c, maxnod, ...
intfst, toliv, tolfes, bigbnd, x);

% Extract further solution information and display
[bl, bu, clamda, istate, ifail] = ...
h02bz(n, m, iwork, rwork);

fprintf('Final IP objective value = %11.4f\n\n',objmip)

fprintf('%6s%8s%8s%16s%14s%13s\n','Varbl','State','Value',...
'Lower Bound','Upper Bound','Lagr Mult');

chstate = ['VL';'VU';'FR';'LL';'UU';'EQ';'TF'];
vch = ['Oatmeal';'Chicken';'Eggs   ';'Milk   ';'Pie    ';'Bacon  '];
cch = ['Energy ';'Protein';'Calcium'];

for i=1:n
ich = double(istate(i)) + 3;
fprintf('%7s%6s%10.2f%14.2f%14.2f%13.2f\n',vch(i,:),...
chstate(ich,:),x(i),bl(i),bu(i),clamda(i))
end

fprintf('\n%6s%8s%8s%16s%14s%13s\n','L Con','State','Value',...
'Lower Bound','Upper Bound','Lagr Mult');
y = a*x;
for i=n+1:n+m
ich = double(istate(i)) + 3;
fprintf('%7s%6s%10.2f%14.2f%14.2e%13.2f\n',cch(i-n,:),...
chstate(ich,:),y(i-n),bl(i),bu(i),clamda(i))
end

```
```h02bz example results

Final IP objective value =     97.0000

Varbl   State   Value     Lower Bound   Upper Bound    Lagr Mult
Oatmeal    EQ      4.00          4.00          4.00         3.00
Chicken    LL      0.00          0.00          3.00        24.00
Eggs       LL      0.00          0.00          2.00        13.00
Milk       LL      5.00          5.00          8.00         9.00
Pie        EQ      2.00          2.00          2.00        20.00
Bacon      LL      0.00          0.00          2.00        19.00

L Con   State   Value     Lower Bound   Upper Bound    Lagr Mult
Energy     FR   2080.00       2000.00      1.00e+20         0.00
Protein    FR     64.00         55.00      1.00e+20         0.00
Calcium    FR   1477.00        800.00      1.00e+20         0.00
```