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

1. COUNTING PENNIES AND COUNTING CALORIES

Running our original data file, we see that the cheapest diet meeting the nutritional constraints is about 4000 calories. It relies on a lot of quarter pounders with cheese and fries, washed down with milk.


   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
   ;


Next we look for the most nutritional diet not exceeding 2500 calories. In this diet the fries are out, and there is a switch from milk to orange juice and from the quarter pounder to (surprise) the McLean deluxe. The cost has gone up from $14.85 to to $16.67 -- as should be expected when a constraint is added. (It costs more to eat carefully.)


   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
   ;


Can we fashion a diet of only 2000 calories? Not if we want to meet the other nutrient requirements -- the message "infeasible problem" indicates that no solution satisfying all the constraints is possible.


   ampl: let n_max["Cal"] := 2000;

   ampl: solve;
   MINOS 5.4: ignoring integrality of 9 variables
   MINOS 5.4: infeasible problem.
   2 iterations


What's the lowest-calorie diet that meets the other requirements? By introducing a new objective that minimizes calories (while ignoring cost), we see that the minimum is about 2467 calories, at a cost of about $16.75. In this solution you eat only the McLean Deluxe.


   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: 



Comments or questions?
Write to info@ampl.com or use our comment form.

Return to the AMPL examples page.

Return to the AMPL home page.


LAST MODIFIED 27 MARCH 1996 BY 4er.