Question 15.2
In the videos, we saw the “diet problem”. (The diet problem is one of the first large-scale optimization
problems to be studied in practice. Back in the 1930’s and 40’s, the Army wanted to meet the nutrit
...
Question 15.2
In the videos, we saw the “diet problem”. (The diet problem is one of the first large-scale optimization
problems to be studied in practice. Back in the 1930’s and 40’s, the Army wanted to meet the nutritional
requirements of its soldiers while minimizing the cost.) In this homework you get to solve a diet problem
with real data. The data is given in the file diet.xls.
1. Formulate an optimization model (a linear program) to find the cheapest diet that satisfies the
maximum and minimum daily nutrition constraints, and solve it using PuLP. Turn in your code
and the solution. (The optimal solution should be a diet of air-popped popcorn, poached eggs,
oranges, raw iceberg lettuce, raw celery, and frozen broccoli. UGH!)
Optimization Solution:
52.64371 units of foods_Celery,_Raw
0.25960653 units of foods_Frozen_Broccoli
63.988506 units of foods_Lettuce,Iceberg,Raw
2.2929389 units of foods_Oranges
0.14184397 units of foods_Poached_Eggs
13.869322 units of foods_Popcorn,Air_Popped
Total cost = $4.34
2. Please add to your model the following constraints (which might require adding more variables)
and solve the new model:
a. If a food is selected, then a minimum of 1/10 serving must be chosen. (Hint: now you will
need two variables for each food i: whether it is chosen, and how much is part of the diet.
You’ll also need to write a constraint to link them.)
b. Many people dislike celery and frozen broccoli. So at most one, but not both, can be
selected.
c. To get day-to-day variety in protein, at least 3 kinds of meat/poultry/fish/eggs must be
selected. [If something is ambiguous (e.g., should bean-and-bacon soup be considered
meat?), just call it whatever you think is appropriate – I want you to learn how to write this
type of constraint, but I don’t really care whether we agree on how to classify foods!]
Optimization Solution:
42.399358 units of foods_Celery,_Raw
0.1 units of foods_Kielbasa,Prk
82.802586 units of foods_Lettuce,Iceberg,Raw
3.0771841 units of foods_Oranges
1.9429716 units of foods_Peanut_Butter
0.1 units of foods_Poached_Eggs
13.223294 units of foods_Popcorn,Air_Popped
0.1 units of foods_Scrambled_Eggs
Total cost of food = $4.51
If you want to see what a more full-sized problem would look like, try solving your models for the file
diet_large.xls, which is a low-cholesterol diet model (rather than minimizing cost, the goal is to
ISYE 6501 Week 11 HW
minimize cholesterol intake). I don’t know anyone who’d want to eat this diet – the optimal solution
includes dried chrysanthemum garland, raw beluga whale flipper, freeze-dried parsley, etc. – which
shows why it’s necessary to add additional constraints beyond the basic ones we saw in the video!
[Note: there are many optimal solutions, all with zero cholesterol, so you might get a different one.
It probably won’t be much more appetizing than mine.]
Optimization Solution:
0.059863415 units of Beans,_adzuki,_mature_seeds,_raw
0.069514608 units of Broccoli_raab,_raw
0.42866218 units of Cocoa_mix,_no_sugar_added,_powder
0.14694398 units of Egg,_white,_dried,_flakes,_glucose_reduced
0.73805891 units of
Infant_formula,_MEAD_JOHNSON,_ENFAMIL,_NUTRAMIGEN,_with_iron,_p
0.4258564 units of
Infant_formula,_NESTLE,_GOOD_START_ESSENTIALS__SOY,__with_iron,
0.050114149 units of
Infant_formula,_ROSS,_ISOMIL,_with_iron,_powder,_not_reconstitu
0.15033656 units of
Margarine_like_spread,_approximately_60%_fat,_tub,_soybean_(hyd
0.25918767 units of Mung_beans,_mature_seeds,_raw
0.18052856 units of Nuts,_mixed_nuts,_dry_roasted,_with_peanuts,_with_salt_added
1.184482 units of Oil,_vegetable,_sunflower,_linoleic,_(hydrogenated)
0.10375187 units of Seeds,_sunflower_seed_kernels,_dry_roasted,_with_salt_added
0.031866196 units of Snacks,_potato_chips,_fat_free,_made_with_olestra
0.070710308 units of Spices,_paprika
0.55106575 units of Tomatoes,_sun_dried
9999.6864 units of Water,_bottled,_non_carbonated,_CALISTOGA
Total cholesterol = 0.000000
Ans. –
2.1
The optimal solution -
Optimization Solution:
52.64371 units of foods_Celery,_Raw
0.25960653 units of foods_Frozen_Broccoli
63.988506 units of foods_Lettuce,Iceberg,Raw
2.2929389 units of foods_Oranges
0.14184397 units of foods_Poached_Eggs
13.869322 units of foods_Popcorn,Air_Popped
Total cost = $4.34
Py Code –
ISYE 6501 Week 11 HW
from pulp import *
import pandas as pd
# load diet data
data = pd.read_excel(open('/Users/AmolJ/Down
[Show More]