| The McDonald's Diet Problem | A Case Study in Optimization Using AMPL |
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
ampl: display Buy;
Buy [*] :=
'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
;
ampl: let n_max["Cal"] := 2500;
ampl: solve;
MINOS 5.4: ignoring integrality of 9 variables
MINOS 5.4: optimal solution found.
9 iterations, objective 16.67097416
ampl: display Buy;
Buy [*] :=
'Quarter Pounder w/ Cheese' 0.231942
'McLean Deluxe w/ Cheese' 3.85465
'Big Mac' 0
Filet-O-Fish 0
'McGrilled Chicken' 0
'Fries, small' 0
'Sausage McMuffin' 0
'1% Lowfat Milk' 2.0433
'Orange Juice' 9.13408
;
ampl: display n_min,Diet.body,n_max;
: n_min Diet.body n_max :=
Cal 2000 2500 2500
Carbo 350 350 375
Protein 55 126.53 Infinity
VitA 100 100 Infinity
VitC 100 1144.2 Infinity
Calc 100 163.618 Infinity
Iron 100 100 Infinity
;
ampl: let n_max["Cal"] := 2000; ampl: solve; MINOS 5.4: ignoring integrality of 9 variables MINOS 5.4: infeasible problem. 2 iterations
ampl: let n_max["Cal"] := Infinity;
ampl: objective Nutr_Amt["Cal"];
ampl: solve;
MINOS 5.4: ignoring integrality of 9 variables
MINOS 5.4: optimal solution found.
3 iterations, objective 2466.981132
ampl: display Total_Cost;
Total_Cost = 16.7453
ampl: display Buy;
Buy [*] :=
'Quarter Pounder w/ Cheese' 0
'McLean Deluxe w/ Cheese' 4.08805
'Big Mac' 0
Filet-O-Fish 0
'McGrilled Chicken' 0
'Fries, small' 0
'Sausage McMuffin' 0
'1% Lowfat Milk' 2.04403
'Orange Juice' 9.1195
;
ampl:
Return to the AMPL examples page.