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.
Here’s one possible solution. Please note that a good solution doesn’t have to try all of the possibilities
in the code; they’re shown to help you learn, but they’re not necessary.
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!)
Algebraically, here’s what the model looks like:
Data
c
j = cost per unit of food j
a
ij = amount of nutrient i per unit of food j
m
i = minimum amount of nutrient i required
M
i = maximum amount of nutrient i required
Variables
x
j = amount of food j eaten
Objective
Minimize ∑
j
c
j x j (minimize total cost)
Constraints
∑j
a
ij x j ≥ mi for each nutrient i (take in at least minimum amount of each nutrient)
∑j
a
ij x j ≤ Mi for each nutrient i (take in no more than max amount of each
nutrient)
x
j ≥0 for each food j (can’t eat negative amounts)
The file solution 15.2-1-separate.py shows one way to solve the problem. This file deals
with each nutrient separately, to show what the problem looks like.
However, an easier way to do it is shown in file solution 15.2-1-simpler.py, where data is
read and constraints are written in a loop, so individual nutrients don’t need to each be written out. This
will come in handy when there are more constraints (like the optional part below).
However you set up the problem, here’s the optimal solution:
## ---------The solution to the diet problem is----------
## 52.64371 units of Celery,_Raw
This study source was downloaded by 100000793680026 from CourseHero.com on 04-04-2021 18:24:29 GMT -05:00
https://www.coursehero.com/file/50070049/solution-152docx/
This stud
[Show More]