examples/diet.mod
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/diet.mod	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,99 @@
     1.4 +# STIGLER'S NUTRITION MODEL
     1.5 +#
     1.6 +# This model determines a least cost diet which meets the daily
     1.7 +# allowances of nutrients for a moderately active man weighing 154 lbs.
     1.8 +#
     1.9 +#  References:
    1.10 +#              Dantzig G B, "Linear Programming and Extensions."
    1.11 +#              Princeton University Press, Princeton, New Jersey, 1963,
    1.12 +#              Chapter 27-1.
    1.13 +
    1.14 +set N;
    1.15 +/* nutrients */
    1.16 +
    1.17 +set F;
    1.18 +/* foods */
    1.19 +
    1.20 +param b{N};
    1.21 +/* required daily allowances of nutrients */
    1.22 +
    1.23 +param a{F,N};
    1.24 +/* nutritive value of foods (per dollar spent) */
    1.25 +
    1.26 +var x{f in F} >= 0;
    1.27 +/* dollars of food f to be purchased daily */
    1.28 +
    1.29 +s.t. nb{n in N}: sum{f in F} a[f,n] * x[f] = b[n];
    1.30 +/* nutrient balance (units) */
    1.31 +
    1.32 +minimize cost: sum{f in F} x[f];
    1.33 +/* total food bill (dollars) */
    1.34 +
    1.35 +data;
    1.36 +
    1.37 +param : N : b :=
    1.38 +         Calorie       3 /* thousands */
    1.39 +         Protein      70 /* grams */
    1.40 +         Calcium     0.8 /* grams */
    1.41 +         Iron         12 /* milligrams */
    1.42 +         Vitamin-A     5 /* thousands IUs */
    1.43 +         Vitamin-B1  1.8 /* milligrams */
    1.44 +         Vitamin-B2  2.7 /* milligrams */
    1.45 +         Niacin       18 /* milligrams */
    1.46 +         Vitamin-C    75 /* milligrams */  ;
    1.47 +
    1.48 +set F := Wheat Cornmeal Cannedmilk Margarine Cheese Peanut-B Lard
    1.49 +         Liver Porkroast Salmon Greenbeans Cabbage Onions Potatoes
    1.50 +         Spinach Sweet-Pot Peaches Prunes Limabeans Navybeans;
    1.51 +
    1.52 +param a default 0
    1.53 +
    1.54 +:           Calorie  Protein  Calcium  Iron  Vitamin-A  Vitamin-B1 :=
    1.55 +#            (1000)    (g)      (g)    (mg)   (1000IU)     (mg)
    1.56 +
    1.57 +Wheat         44.7     1411      2.0    365        .       55.4
    1.58 +Cornmeal      36        897      1.7     99      30.9      17.4
    1.59 +Cannedmilk     8.4      422     15.1      9      26         3
    1.60 +Margarine     20.6       17       .6      6      55.8        .2
    1.61 +Cheese         7.4      448     16.4     19      28.1        .8
    1.62 +Peanut-B      15.7      661      1       48        .        9.6
    1.63 +Lard          41.7        .       .       .        .2        .
    1.64 +Liver          2.2      333       .2    139     169.2       6.4
    1.65 +Porkroast      4.4      249       .3     37        .       18.2
    1.66 +Salmon         5.8      705      6.8     45       3.5       1
    1.67 +Greenbeans     2.4      138      3.7     80      69         4.3
    1.68 +Cabbage        2.6      125      4       36       7.2       9
    1.69 +Onions         5.8      166      3.8     59      16.6       4.7
    1.70 +Potatoes      14.3      336      1.8    118       6.7      29.4
    1.71 +Spinach        1.1      106       .     138     918.4       5.7
    1.72 +Sweet-Pot      9.6      138      2.7     54     290.7       8.4
    1.73 +Peaches        8.5       87      1.7    173      86.8       1.2
    1.74 +Prunes        12.8       99      2.5    154      85.7       3.9
    1.75 +Limabeans     17.4     1055      3.7    459       5.1      26.9
    1.76 +Navybeans     26.9     1691     11.4    792        .       38.4
    1.77 +
    1.78 +:          Vitamin-B2  Niacin  Vitamin-C :=
    1.79 +#             (mg)      (mg)     (mg)
    1.80 +
    1.81 +Wheat         33.3       441         .
    1.82 +Cornmeal       7.9       106         .
    1.83 +Cannedmilk    23.5        11        60
    1.84 +Margarine       .          .         .
    1.85 +Cheese        10.3         4         .
    1.86 +Peanut-B       8.1       471         .
    1.87 +Lard            .5         5         .
    1.88 +Liver         50.8       316       525
    1.89 +Porkroast      3.6        79         .
    1.90 +Salmon         4.9       209         .
    1.91 +Greenbeans     5.8        37       862
    1.92 +Cabbage        4.5        26      5369
    1.93 +Onions         5.9        21      1184
    1.94 +Potatoes       7.1       198      2522
    1.95 +Spinach       13.8        33      2755
    1.96 +Sweet-Pot      5.4        83      1912
    1.97 +Peaches        4.3        55        57
    1.98 +Prunes         4.3        65       257
    1.99 +Limabeans     38.2        93         .
   1.100 +Navybeans     24.6       217         .   ;
   1.101 +
   1.102 +end;