examples/diet.mod
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 05 Dec 2010 17:35:23 +0100
changeset 2 4c8956a7bdf4
permissions -rw-r--r--
Set up CMAKE build environment
alpar@1
     1
# STIGLER'S NUTRITION MODEL
alpar@1
     2
#
alpar@1
     3
# This model determines a least cost diet which meets the daily
alpar@1
     4
# allowances of nutrients for a moderately active man weighing 154 lbs.
alpar@1
     5
#
alpar@1
     6
#  References:
alpar@1
     7
#              Dantzig G B, "Linear Programming and Extensions."
alpar@1
     8
#              Princeton University Press, Princeton, New Jersey, 1963,
alpar@1
     9
#              Chapter 27-1.
alpar@1
    10
alpar@1
    11
set N;
alpar@1
    12
/* nutrients */
alpar@1
    13
alpar@1
    14
set F;
alpar@1
    15
/* foods */
alpar@1
    16
alpar@1
    17
param b{N};
alpar@1
    18
/* required daily allowances of nutrients */
alpar@1
    19
alpar@1
    20
param a{F,N};
alpar@1
    21
/* nutritive value of foods (per dollar spent) */
alpar@1
    22
alpar@1
    23
var x{f in F} >= 0;
alpar@1
    24
/* dollars of food f to be purchased daily */
alpar@1
    25
alpar@1
    26
s.t. nb{n in N}: sum{f in F} a[f,n] * x[f] = b[n];
alpar@1
    27
/* nutrient balance (units) */
alpar@1
    28
alpar@1
    29
minimize cost: sum{f in F} x[f];
alpar@1
    30
/* total food bill (dollars) */
alpar@1
    31
alpar@1
    32
data;
alpar@1
    33
alpar@1
    34
param : N : b :=
alpar@1
    35
         Calorie       3 /* thousands */
alpar@1
    36
         Protein      70 /* grams */
alpar@1
    37
         Calcium     0.8 /* grams */
alpar@1
    38
         Iron         12 /* milligrams */
alpar@1
    39
         Vitamin-A     5 /* thousands IUs */
alpar@1
    40
         Vitamin-B1  1.8 /* milligrams */
alpar@1
    41
         Vitamin-B2  2.7 /* milligrams */
alpar@1
    42
         Niacin       18 /* milligrams */
alpar@1
    43
         Vitamin-C    75 /* milligrams */  ;
alpar@1
    44
alpar@1
    45
set F := Wheat Cornmeal Cannedmilk Margarine Cheese Peanut-B Lard
alpar@1
    46
         Liver Porkroast Salmon Greenbeans Cabbage Onions Potatoes
alpar@1
    47
         Spinach Sweet-Pot Peaches Prunes Limabeans Navybeans;
alpar@1
    48
alpar@1
    49
param a default 0
alpar@1
    50
alpar@1
    51
:           Calorie  Protein  Calcium  Iron  Vitamin-A  Vitamin-B1 :=
alpar@1
    52
#            (1000)    (g)      (g)    (mg)   (1000IU)     (mg)
alpar@1
    53
alpar@1
    54
Wheat         44.7     1411      2.0    365        .       55.4
alpar@1
    55
Cornmeal      36        897      1.7     99      30.9      17.4
alpar@1
    56
Cannedmilk     8.4      422     15.1      9      26         3
alpar@1
    57
Margarine     20.6       17       .6      6      55.8        .2
alpar@1
    58
Cheese         7.4      448     16.4     19      28.1        .8
alpar@1
    59
Peanut-B      15.7      661      1       48        .        9.6
alpar@1
    60
Lard          41.7        .       .       .        .2        .
alpar@1
    61
Liver          2.2      333       .2    139     169.2       6.4
alpar@1
    62
Porkroast      4.4      249       .3     37        .       18.2
alpar@1
    63
Salmon         5.8      705      6.8     45       3.5       1
alpar@1
    64
Greenbeans     2.4      138      3.7     80      69         4.3
alpar@1
    65
Cabbage        2.6      125      4       36       7.2       9
alpar@1
    66
Onions         5.8      166      3.8     59      16.6       4.7
alpar@1
    67
Potatoes      14.3      336      1.8    118       6.7      29.4
alpar@1
    68
Spinach        1.1      106       .     138     918.4       5.7
alpar@1
    69
Sweet-Pot      9.6      138      2.7     54     290.7       8.4
alpar@1
    70
Peaches        8.5       87      1.7    173      86.8       1.2
alpar@1
    71
Prunes        12.8       99      2.5    154      85.7       3.9
alpar@1
    72
Limabeans     17.4     1055      3.7    459       5.1      26.9
alpar@1
    73
Navybeans     26.9     1691     11.4    792        .       38.4
alpar@1
    74
alpar@1
    75
:          Vitamin-B2  Niacin  Vitamin-C :=
alpar@1
    76
#             (mg)      (mg)     (mg)
alpar@1
    77
alpar@1
    78
Wheat         33.3       441         .
alpar@1
    79
Cornmeal       7.9       106         .
alpar@1
    80
Cannedmilk    23.5        11        60
alpar@1
    81
Margarine       .          .         .
alpar@1
    82
Cheese        10.3         4         .
alpar@1
    83
Peanut-B       8.1       471         .
alpar@1
    84
Lard            .5         5         .
alpar@1
    85
Liver         50.8       316       525
alpar@1
    86
Porkroast      3.6        79         .
alpar@1
    87
Salmon         4.9       209         .
alpar@1
    88
Greenbeans     5.8        37       862
alpar@1
    89
Cabbage        4.5        26      5369
alpar@1
    90
Onions         5.9        21      1184
alpar@1
    91
Potatoes       7.1       198      2522
alpar@1
    92
Spinach       13.8        33      2755
alpar@1
    93
Sweet-Pot      5.4        83      1912
alpar@1
    94
Peaches        4.3        55        57
alpar@1
    95
Prunes         4.3        65       257
alpar@1
    96
Limabeans     38.2        93         .
alpar@1
    97
Navybeans     24.6       217         .   ;
alpar@1
    98
alpar@1
    99
end;