Diet lp COPT AMPL short = 0; param f_min {FOOD} >= 0, default 0; param f_max {j in FOOD} >= f_min[j], default Infinity; param n_min {NUTR} >= 0, default 0; param n_max {i in NUTR} >= n_min[i], default Infinity; param amt {NUTR,FOOD} >= 0; # -------------------------------------------------------- var Buy {j in FOOD} >= f_min[j], <= f_max[j]; # -------------------------------------------------------- minimize Total_Cost: sum {j in FOOD} cost[j] * Buy[j]; minimize Nutr_Amt {i in NUTR}: sum {j in FOOD} amt[i,j] * Buy[j]; # -------------------------------------------------------- subject to Diet {i in NUTR}: n_min[i] <= sum {j in FOOD} amt[i,j] * Buy[j] <= n_max[i]; ]]> param: FOOD: cost f_min f_max := "Quarter Pounder w/ Cheese" 1.84 . . "McLean Deluxe w/ Cheese" 2.19 . . "Big Mac" 1.84 . . "Filet-O-Fish" 1.44 . . "McGrilled Chicken" 2.29 . . "Fries, small" .77 . . "Sausage McMuffin" 1.29 . . "1% Lowfat Milk" .60 . . "Orange Juice" .72 . . ; param: NUTR: n_min n_max := Cal 2000 . Carbo 350 375 Protein 55 . VitA 100 . VitC 100 . Calc 100 . Iron 100 . ; param amt (tr): Cal Carbo Protein VitA VitC Calc Iron := "Quarter Pounder w/ Cheese" 510 34 28 15 6 30 20 "McLean Deluxe w/ Cheese" 370 35 24 15 10 20 20 "Big Mac" 500 42 25 6 2 25 20 "Filet-O-Fish" 370 38 14 2 0 15 10 "McGrilled Chicken" 400 42 31 8 15 15 8 "Fries, small" 220 26 3 0 15 0 2 "Sausage McMuffin" 345 27 15 4 0 20 15 "1% Lowfat Milk" 110 12 9 10 4 30 0 "Orange Juice" 80 20 1 2 120 2 2 ; solve; display Buy; Diet" example from chapter 2 of AMPL book. More examples are available at: http://www.ampl.com/cm/cs/what/ampl/BOOK/EXAMPLES/index_files.html