nag_mip_ilp_info (h02bz) extracts more information associated with the solution of an integer programming problem computed by
nag_mip_ilp_dense (h02bb).
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 |
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
is restricted to take value
in a particular sub-problem, then
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.
None.
Not applicable.
None.
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 following program solves the above problem to obtain the optimal integer solution and then examines the effect of increasing the energy required to units.
function h02bz_example
fprintf('h02bz example results\n\n');
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];
intvar = int64([1; 1; 1; 1; 1; 1]);
c = [3; 24; 13; 9; 20; 19];
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);
[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