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

ObsName1Label1cValue1nValue1
1solverSolverLP.
2algorithmAlgorithmPrimal Simplex.
3objectiveNameObjective Functiondiet.
4solStatusSolution StatusOptimal.
5objectiveObjective Value12.08133788112.081338
6   .
7primalInfeasibilityPrimal Infeasibility00
8dualInfeasibilityDual Infeasibility1.44329E-161.44329E-16
9boundInfeasibilityBound Infeasibility00
10   .
11iterationsIterations66.000000
12presolveTimePresolve Time0.000.000446
13solutionTimeSolution Time0.000.001765

Primal Solution

ObsObjective
Function ID
RHS IDVariable
Name
Variable
Type
Objective
Coefficient
Lower BoundUpper BoundVariable ValueVariable
Status
Reduced Cost
1diet brN2.00.01.7977E3080.00000L1.19066
2diet miD3.50.010.05360B0.00000
3diet chN8.00.01.7977E3080.44950B0.00000
4diet poN1.50.01.7977E3081.86517B-0.00000
5diet fiO11.00.51.7977E3080.50000L5.15641
6diet yoN1.00.01.7977E3080.00000L1.10849


The cost of the optimal diet is 12.08 units.

Last updated: November 20, 2025