Previous Page | Next Page

The OPTLP Procedure

Example 17.3 The Diet Problem

Consider the problem of diet optimization. There are six different foods: bread, milk, cheese, potato, fish, and yogurt. The cost and nutrition values per unit are displayed in Table 17.3.

Table 17.3 Cost and Nutrition Values
 

Bread

Milk

Cheese

Potato

Fish

Yogurt

Cost

2.0

3.5

8.0

1.5

11.0

1.0

Protein, g

4.0

8.0

7.0

1.3

8.0

9.2

Fat, g

1.0

5.0

9.0

0.1

7.0

1.0

Carbohydrates, g

15.0

11.7

0.4

22.6

0.0

17.0

Calories

90

120

106

97

130

180

The objective is to find a minimum-cost diet that contains at least 300 calories, not more than 10 grams of protein, not less than 10 grams of carbohydrates, and not less than 8 grams of fat. In addition, the diet should contain at least 0.5 unit of fish and no more than 1 unit of milk.

You can use the following SAS code to create the MPS-format input data set:

data ex3;
input field1 $ field2 $ field3$ field4 field5 $ field6 ;
datalines;
NAME        .          EX3      .     .         .
ROWS        .          .        .     .         .
 N          diet       .        .     .         .
 G          calories   .        .     .         .
 L          protein    .        .     .         . 
 G          fat        .        .     .         .
 G          carbs      .        .     .         .
COLUMNS     .          .        .     .         .
.           br         diet     2     calories  90
.           br         protein  4     fat       1
.           br         carbs    15    .         .
.           mi         diet     3.5   calories  120
.           mi         protein  8     fat       5
.           mi         carbs    11.7  .         .
.           ch         diet     8     calories  106
.           ch         protein  7     fat       9
.           ch         carbs    .4    .         .
.           po         diet     1.5   calories  97
.           po         protein  1.3   fat       .1
.           po         carbs    22.6  .         .
.           fi         diet     11    calories  130
.           fi         protein  8     fat       7
.           fi         carbs    0     .         .
.           yo         diet     1     calories  180
.           yo         protein  9.2   fat       1
.           yo         carbs    17    .         .
RHS         .          .        .     .         .
.           .          calories 300   protein   10
.           .          fat      8     carbs     10
BOUNDS      .          .        .     .         .
UP          .          mi       1     .         .
LO          .          fi       .5    .         .
ENDATA      .          .        .     .         .
;

You can solve the diet problem by using PROC OPTLP as follows:

proc optlp data=ex3
  presolver = none 
  solver    = ps 
  primalout = ex3pout 
  dualout   = ex3dout
  printfreq = 1; 
run;

The solution summary and the optimal primal solution are displayed in Output 17.3.1.

Output 17.3.1 Diet Problem: Solution Summary and Optimal Primal Solution
The OPTLP Procedure
Solution Summary

Obs Label1 cValue1 nValue1
1 Solver Primal simplex .
2 Objective Function diet .
3 Solution Status Optimal .
4 Objective Value 12.081337881 12.081338
5     .
6 Primal Infeasibility 8.881784E-16 8.881784E-16
7 Dual Infeasibility 0 0
8 Bound Infeasibility 0 0
9     .
10 Iterations 5 5.000000
11 Presolve Time 0.00 0
12 Solution Time 0.00 0



Primal Solution

Obs Objective
Function ID
RHS ID Variable
Name
Variable
Type
Objective
Coefficient
Lower Bound Upper Bound Variable Value Variable
Status
Reduced Cost
1 diet   br N 2.0 0.0 1.7977E308 0.00000 L 1.19066
2 diet   mi D 3.5 0.0 1 0.05360 B 0.00000
3 diet   ch N 8.0 0.0 1.7977E308 0.44950 B 0.00000
4 diet   po N 1.5 0.0 1.7977E308 1.86517 B 0.00000
5 diet   fi O 11.0 0.5 1.7977E308 0.50000 L 5.15641
6 diet   yo N 1.0 0.0 1.7977E308 0.00000 L 1.10849

The cost of the optimal diet is 12.08 units.

Previous Page | Next Page | Top of Page