Download SSAC2007.QP141.YJK1.1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Human nutrition wikipedia , lookup

Nutrition wikipedia , lookup

Transcript
SSAC2007.QP141.YJK1.1
Minimizing Cost while Meeting
Nutritional Requirements – An Example
of Linear Programming
Core Quantitative Concept
Linear Programming
Is it mathematically possible to create a
healthy diet from your favorite foods
while minimizing costs?
Supporting Quantitative concepts and skills
Linear Equations
Linear Inequalities
Multivariable function: inclined plane
Level lines (contours)
Excel Solver
Prepared for SSAC by
*Yu-Ju Kuo – Indiana University of Pennsylvania*
© The Washington Center for Improving the Quality of Undergraduate Education. All rights reserved. *2007*
1
Overview of Module
The “Dietary Problem” is important in our daily lives. The key issue is
whether you get enough nutrition from your choice of foods, while at
the same time paying the minimum cost or consuming the minimum
calories. In this activity, we will set up the Dietary Problem as a linear
programming model, discuss how the solution appears on a graph,
and then use Excel’s Solver feature to solve the problem.
Slides 4-6 Give background information about linear programming – systems of
linear inequalities, the feasible set, and the location of the solution to a linear
programming model.
Slides 7-8 Set up a simplified dietary model using two foods and two nutrition
requirements.
Slides 9-11 Overview Excel Solver and demonstrate its use by solving a
simplified dietary problem.
Slides 11 Poses “what-if questions” to explore the model of the simplified
dietary problem.
Slides 12 Gives the End of Module Assignment, in which you consider a more
realistic dietary problem.
2
Problem
We will assume that your favorite foods are broccoli and carrots We
will further assume that you eat only these two favorite foods.
You will need numbers – the daily requirements for protein and
iron; the amount of protein and iron per serving of broccoli and
carrots; the cost per serving of broccoli and carrots.
Our approach: We let x = servings of broccoli and y = servings of
carrots. A linear programming model includes two parts, a linear
objective function of x and y and a set of linear constraints on x and y.
The set of pairs (x,y) that satisfy all constraints is called the feasible
set. The objective function is the function which you would like to
minimize or maximize over the feasible set.
Definition: A linear function in two variables is defined as f(x,y)=ax+by+c, where a,
b, and c are constants.
3
Background information-Feasible Set
As background, we
consider the values of
x, y, that satisfy all of
the following linear
inequalities:
2x - y  3
- 0.5 x  y  1
x  y  10
How do we find the solution set that satisfies 2x-y≤3
graphically?
Step 1: Graph the equality.
Step 2: Pick a point on one side of the line. Plug it into the
inequality and verify whether the inequality is true.
Step 3: If the point makes the inequality true, then the whole halfside in which the point is located is the solution set to the
inequality. Otherwise, the other side of the line is the solution set.
x  0, y  0
Think carefully about Step 3 and explain why!!
What is an inequality?
If x=1 and y=3, is (x,y) a solution to
2x - y ≤ 3 ?
The half-plane that contains arrows is
the solution set of 2x – y ≤ 3.
How many pairs of (x,y) satisfy
2x – y ≤ 3?
Definition: The solution set to an inequality
ax+by≤ c, where a, b, and c are constants,
is the collection of all ordered pairs (x,y)
such that ax+by≤ c is true.
4
Background Information-Feasible Set
Next, we consider an expression 3x - y. What point
in the yellow area would give the minimum value for
3x - y and what would be that minimum value be?
Now, repeat the same process for
the rest of inequalities and then find
the overlap of all the solution sets.
12
y=.5x+1
y=-x+10
10
y=2x-3
8
We are looking for the minimum of 3x- y over
this yellow area; therefore, 3x- y is the
objective function and the five inequalities
from previous slide are our constraints.
6
The solution
4
2
0
-5
0
5
10
15
20
Now we can write this example into the standard
form of a linear programming model (LP):
-2
-4
This yellow area is the solution set of
all five inequalities from the previous
slide. This set is the feasible set.
Note: The dashed lines on the boundary of the
feasible set are also part of the feasible set.
Minimize
3x- y
subject to (s.t.): 2x- y ≤ 3, x + y ≤ 10,
.5x- y ≤ -1, x≥0 , and y ≥0
Definition: A solution of a minimization LP is a
point in the feasible set that achieves the
minimum of the objective function.
5
Background Information-Solution of Linear Programming
Similar to the graph from the previous slide, the yellow
region here is the feasible set from the five
constraints. The set of parallel lines show contours of
the objective function, z = 3x - y.
Theorem:
If the feasible set of a
LP is not empty, then at
least one corner point
of the feasible set is a
solution of the LP.
The feasible set
Answers
6
Simplified Dietary Model
Now, we can set up a LP to minimize the cost of our two foods subject to two
nutrition requirements? To begin, we will start by introducing the data set.
8 grams of protein in one serving
(10 oz) of frozen broccoli
ID
0.3 milligrams of Iron in one
serving (1/2 cup) of raw carrots
Foods
Price/Serving
Serving Size
Calories
Protein(g)
Vit_C (IU)
IU
Calcium(mg)
Iron(mg)
1
Frozen Broccoli
0.16
10 Oz Pkg
73.8
88
160.2
159
2.3
2
Carrots,Raw
0.07
1/2 Cup Shredded
23.7
0.6
5.1
14.9
0.3
0.3
3
Celery, Raw
0.04
1 Stalk
6.4
0.3
2.8
16
0.2
4
Frozen Corn
0.18
1/2 Cup
72.2
2.5
5.2
3.3
0.3
Assumptions:
1. Eat only broccoli and carrots.
2. All nutrition in food consumed is completely absorbed
3. Protein requirement per day is at least 45 g per day.
Iron requirement per day is no more than 24 mg per day.
IU: international unit, a unit of measurement
for the amount of a substance.
Define:
x: # of servings of broccoli per day
y : # of servings of carrots per day
0.16x+0.07y
7
Simplified Dietary Model
Minimize 0.16x+0.07y
2.3x+0.3y≤ 24
0.16 is the price per serving for broccoli.
0.07 is the price per serving for carrots.
Now, let us consider the protein
requirement : at least 45 grams per day.
Since there are 8 grams of protein per
serving and you consume x servings of
broccoli per day, you absorb 8x grams of
protein from broccoli.
The complete linear programming model
will look as follows:
Minimize 0.16x+0.07y
s.t.
8x+0.6y≥45
2.3x+0.3y≤24, x,y, ≥0
Since you need at least 45 g of protein
per day, that means the total amount of
protein per day should be greater than or
equal to 45 g, i.e.,
8x+0.6y≥45
8
Excel Solver
If you have not used Excel Solver or are not familiar with LOOKUP or SUMPRODUCT command,
please click here for help.
Excel Preview
In this portion, we will introduce the Excel solver through the following steps:
Step 1: Extract data for foods, such as names, price per serving, nutrition contents.
Step 2: Build objective function and constraints.
= cell with a number in it
Step 3: Enter necessary information for the Solver.
Step 4: Run the Solver and interpret the result.
= cell with a formula in it
Step 1:
a) In Column B, enter the ID of your choice of foods.
b) Use Cells D50 and D51 for the variables (# of servings for broccoli and carrot).
c) Use the LOOKUP command to find the names(C50:C51), prices(E50:E51), and nutrition (F50:I51) of the
foods (using the ID entered in Column B).
=LOOKUP(B51,$B$3:$B$42,$F$3:$F$42)
9
Excel Solver
Step 2:
a) Recall: Objective function = (Price per serving for
broccoli )times( # of serving for broccoli)+ (Price per
serving for carrots) times ( # of serving for carrots).
b) Prices per servings are in E50 and E51, # of servings
are in D50 and D51, thus the objective function is
D50*E50+D51*E51.
c) To extend the problem later on, we could also use
SUMPRODUCT.
d) Similarly, look at the left hand side of constraints and
rewrite them using SUMPRODUCT
them
Carefully and
readenter
this part
ofinto
pop-up
D62 and D63.
window before you continue.
Note: D59, D62, and D63 will be 0 after you enter the
formula since the initial values for variables are zeros.
The solutions will be returned to those cells after the
solver is run.
e) Insert appropriate inequality symbols for E62 and E63.
Enter the right hand side of constraints into F62 and F63.
Step 3:
a) Click Tools and find solver, then you will see
the following pop-up.
b) Use “ADD” to add constraints.
c) Click Solve to continue.
=SUMPRODUCT(D50:D51, E50:E51)
Step 3:
d) If the Solver found a solution, Click
OK to continue.
10
Excel Solver-What if questions.
Step 3:
e) Solution is as follows
Solution
Minimum cost
11
End of Module Assignment
1. Expand your Excel sheet so that it will work for any six choices of food and four
nutrition requirements (Protein, Iron, Vitamin C, Calcium).
a) It is recommended to set up nutrition constraints that are suitable for your individual
case.
b) Test your spreadsheet with your six choices of food.
2. A company produces two products, A and B. Both products use one raw material with
the maximum daily availability 240 lb. The usage rates of the raw material are 2 lb per
unit of A and 4 lb per unit of B. Each unit of A and B require 4 hours and 6 hours,
respectively. The unit prices for A and B are $20 and $50, respectively.
a) Write the linear programming model to maximize the revenue of these two products.
b) Use Excel Solver to find the number of units for A and B to achieve the maximum
revenue.
Optional: In Excel Solver’s Step 1, combine IF and LOOKUP to build a formula such that
Excel checks whether the food ID is entered before using LOOKUP to extract data.
12
Get Ready for Excel Solver
Click on Tools and check whether Solver is on the
list. If it is listed, skip the Step 0. If Solver is not
listed, please follow Step 0 to add-in the solver.
Step 0:
a) Click Tools, then Add-in.
b) Check the box next to Solver Add-in, then click
OK.
c) Click in a open worksheet and check again
whether Solver is listed under Tools.
In this portion, we will introduce important commands for
this module: LOOKUP, SUMPRODUCT.
Step1: Open a new Excel worksheet and enter the
information as below.
= cell with a number in it
= cell with a formula in it
13
Get Ready for Excel Solver
Step 2: Now we would like to extract the names and
the prices of foods. For example, Excel should look
for the ID given in B10 from the ID list (B3:B7), then
return the name of the food associated with the ID in
B10 from the Name list (C3:C7). Enter the formulas
for C10, C11, E10, and E11.
Command Format:
LOOKUP(lookup_value,lookup_vector,result_vector)
Step 3: Consider 9 servings of frozen broccoli and 5
servings of frozen corn, how much is the total cost?
Mathematically, Total cost= (# of servings of broccoli)
times(broccoli’s cost per serving)+(# of serving of corn)
times (corn’s cost per serving).
Thus, the total cost is the sum of the product of # of
servings and cost per serving.
Command format: SUMPRODUCT(array1, arrray2)
Array 1
Array 2
=LOOKUP(B11, $B$3:$B$7, $D$3:$D$7)
=SUMPRODCUT(D10:D11, E10:E11)
Return
14
Answers to Questions on Slide 6
Yes, it is possible. If one of the boundary lines of the feasible
set coincides with one of the decreasing contours, there will
be infinite solutions for a minimization LP. On the other hand,
if one of the boundary lines of the feasible set coincides with
one of the increasing contours, there will be infinite solutions
for a maximization LP. Note that in the graph below, there
are infinite solutions for the minimization LP, but there is a
unique solution for the maximization LP.
It would be at a corner point of the
feasible set. Assume that none of
constrains is parallel to the contours of
the objective function. For a minimization
LP, this corner point will be the last point
where the decreasing contour lines
intersect w/ the feasible set. On the other
hand, for a maximization LP, the corner
point will be the last point where the
increasing contour lines intersect with the
feasible set.
Return
Yes, it is possible. When the feasible set is empty, 15
there will be no solution. Study figure in Slide 5.