The McDonald's Diet Problem A Case Study in Optimization Using AMPL

## 2. VARIETY IS THE SPICE OF LIFE

Here's the original diet solution again. Optimal solutions to linear programs tend to look like this: do a lot of a few things. This could easily get boring.

```   stretto% ampl

ampl: model diet1.mod;
ampl: data diet1.dat;

ampl data: solve;
MINOS 5.4: ignoring integrality of 9 variables
MINOS 5.4: optimal solution found.
8 iterations, objective 14.8557377

'Quarter Pounder w/ Cheese'  4.38525
'McLean Deluxe w/ Cheese'  0
'Big Mac'  0
Filet-O-Fish  0
'McGrilled Chicken'  0
'Fries, small'  6.14754
'Sausage McMuffin'  0
'1% Lowfat Milk'  3.42213
'Orange Juice'  0
;

ampl: display n_min,Diet.body,n_max;

:        n_min  Diet.body    n_max      :=
Cal       2000   3965.37    Infinity
Carbo      350    350            375
Protein     55    172.029   Infinity
VitA       100    100       Infinity
VitC       100    132.213   Infinity
Calc       100    234.221   Infinity
Iron       100    100       Infinity
;
```

In the interest of variety, we can say that the diet should not involve buying more than two of any one item. Then we get indeed a much more varied solution, and as a bonus it has somewhat fewer calories. On the other hand, the cost goes up from \$14.85 to \$16.76.

```   ampl: let {j in FOOD} f_max[j] := 2;

ampl: solve;
MINOS 5.4: ignoring integrality of 9 variables
MINOS 5.4: optimal solution found.
6 iterations, objective 16.76576923

'Quarter Pounder w/ Cheese'  2
'McLean Deluxe w/ Cheese'  2
'Big Mac'  2
Filet-O-Fish  0
'McGrilled Chicken'  0
'Fries, small'  1.42308
'Sausage McMuffin'  1
'1% Lowfat Milk'  2
'Orange Juice'  2
;

ampl: display n_min,Diet.body,n_max;

:        n_min  Diet.body    n_max      :=
Cal       2000   3798.08    Infinity
Carbo      350    350            375
Protein     55    193.269   Infinity
VitA       100    100       Infinity
VitC       100    305.346   Infinity
Calc       100    234       Infinity
Iron       100    141.846   Infinity
;
```

How low can we reduce the calories, now that we've added the variety constraint? Only to 3488 -- compared to under 2500 before. Also the cost of this diet, about \$17.25, is about 50 cents higher than the minimum-calorie diet without the variety restriction. Still, the diet is significantly different; no Big Macs, for one thing.

```   ampl: objective Nutr_Amt["Cal"];

ampl: solve;
MINOS 5.4: ignoring integrality of 9 variables
MINOS 5.4: optimal solution found.
6 iterations, objective 3488.286853

ampl: display Total_Cost;
Total_Cost = 17.2484

'Quarter Pounder w/ Cheese'  1.95219
'McLean Deluxe w/ Cheese'  2
'Big Mac'  0
Filet-O-Fish  0.358566
'McGrilled Chicken'  2
'Fries, small'  2
'Sausage McMuffin'  0
'1% Lowfat Milk'  2
'Orange Juice'  2
;

ampl: display n_min,Diet.body,n_max;
:        n_min  Diet.body    n_max      :=
Cal       2000   3488.29    Infinity
Carbo      350    350            375
Protein     55    195.681   Infinity
VitA       100    100       Infinity
VitC       100    339.713   Infinity
Calc       100    197.944   Infinity
Iron       100    106.629   Infinity
;

ampl:
```