The OPTLP Procedure
Example 5.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 3.
Table 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 table:
data mylib.ex3;
input _id_ field1 $ field2 $ field3 $ field4 field5 $ field6;
datalines;
1 NAME . EX3 . . .
2 ROWS . . . . .
3 N diet . . . .
4 G calories . . . .
5 L protein . . . .
6 G fat . . . .
7 G carbs . . . .
8 COLUMNS . . . . .
9 . br diet 2 calories 90
10 . br protein 4 fat 1
11 . br carbs 15 . .
12 . mi diet 3.5 calories 120
13 . mi protein 8 fat 5
14 . mi carbs 11.7 . .
15 . ch diet 8 calories 106
16 . ch protein 7 fat 9
17 . ch carbs .4 . .
18 . po diet 1.5 calories 97
19 . po protein 1.3 fat .1
20 . po carbs 22.6 . .
21 . fi diet 11 calories 130
22 . fi protein 8 fat 7
23 . fi carbs 0 . .
24 . yo diet 1 calories 180
25 . yo protein 9.2 fat 1
26 . yo carbs 17 . .
27 RHS . . . . .
28 . . calories 300 protein 10
29 . . fat 8 carbs 10
30 BOUNDS . . . . .
31 UP . mi 1 . .
32 LO . fi .5 . .
33 ENDATA . . . . .
;
You can solve the diet problem by using PROC OPTLP as follows:
proc optlp data=mylib.ex3
presolver = none
algorithm = ps
primalout = mylib.ex3pout
dualout = mylib.ex3dout
logfreq = 1;
run;
The solution summary and the optimal primal solution are displayed in Output 5.3.1.
Output 5.3.1: Diet Problem: Solution Summary and Optimal Primal Solution
| Solution Summary |
| Obs | Name1 | Label1 | cValue1 | nValue1 |
|---|---|---|---|---|
| 1 | solver | Solver | LP | . |
| 2 | algorithm | Algorithm | Primal Simplex | . |
| 3 | objectiveName | Objective Function | diet | . |
| 4 | solStatus | Solution Status | Optimal | . |
| 5 | objective | Objective Value | 12.081337881 | 12.081338 |
| 6 | . | |||
| 7 | primalInfeasibility | Primal Infeasibility | 0 | 0 |
| 8 | dualInfeasibility | Dual Infeasibility | 1.44329E-16 | 1.44329E-16 |
| 9 | boundInfeasibility | Bound Infeasibility | 0 | 0 |
| 10 | . | |||
| 11 | iterations | Iterations | 6 | 6.000000 |
| 12 | presolveTime | Presolve Time | 0.00 | 0.000446 |
| 13 | solutionTime | Solution Time | 0.00 | 0.001765 |
| 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.