More Linear Programming Models - gatech.edu
Transcript of More Linear Programming Models - gatech.edu
More Linear Programming Models
(many of these examples come from Introduction to Mathematical Programming by Wayne L. Winston)
Optimization: A Model Archetype
• “Deciding” can be abstracted as a mathematical statement
• The mathematical statement can be analyzed using algorithms and software
• The results of the analysis can help in making actual decisions
Today, more formal modeling
And more Visual Xpress computational models.
Modeling involves five distinct processes, which may be repeated a number of times
in any application:
• cataloging what you know about the problem situation
• recalling relevant domain knowledge and facts pertinent to the situation
• recalling appropriate modeling archetypesthat might be applicable to the situation
• creating a particular model• using and evaluating the model, testing it
against the problem situation and iterating the modeling process if necessary
Assignment
• Modify small.xls to solve Farmer Jones’ decision problem
• Modify small.mod and use Visual Xpress to solve Farmer Jones’ problem
• Solve Farmer Jones’ problem graphically
DO IT TODAY! Did you do it?
See if you can develop the formal models for the
following four problems.
We’ll look at these in more detail during the next lecture, but you’ll get more out of it if you try the problems
before the lecture.
Dorian Auto manufactures luxury cars and trucks. The company believes that its most likely customers are high-income women and men. To reach these groups, Dorian Auto has embarked on an ambitious TV advertising campaign, and has decided to purchase 1-minute ad spots on two types of programs; comedy shows and football games. Each comedy commercial is seen by 7 million high-income women and 2 million high-income men. Each football commercial is seen by 2 million high-income women and 12 million high-income men. A 1-minute comedy spot costs $50,000 and a 1-minute football spot costs $100,000. Dorian wants to reach at least 28 million high-income women and 24 million high-income men. How should Dorian buy commercial time to reach their targets at the lowest possible cost?
Dorian Data
Women Men Cost Comedy Football Need
Formal Model for Dorian
• Objective
• Decision
• Cost impact
Formal model (cont’d)
• Constraints
Formal Model (cont’d)
• Let xc be the number of comedy spots and xf be the number of football slots
• objective = minimize 50xc + 100xf• constraints:
(number of women)(number of men)
note the inconsequential scaling of the values
Formal Model
Xpress Modelmodel dorianvariablesxcxfconstraintscost: 50*xc + 100*xf $women: 7*xc + 2*xf > 28men: 2*xc + 12*xf > 24generate
Xpress ResultsC:\My Documents\2030work\xpress\dorian.modSolution Statistics:
Minimisation performedLP Optimal1 iteration(s) performedObjective function value is 320
VARIABLES (Values)------------------xc: 3.6xf: 1.4
CONSTRAINTS (Shadow Prices)---------------------------cost: 0women: -5men: -7.5
Solve Dorian Graphically
Xc
Xf
Some things to think about
• Can Dorian purchase a fraction of an ad?
• How can we provide an answer to Dorian?
• Look at dorian.xls--there is a worksheet where you can try various values for C and F to determine what gives the least cost.
Some More Thoughts
• The two options do not interact--you can satisfy the requirement using only comedy ads, only football ads, or a combination.
• This is an archetype
Source 2Source 1
Cost of each source
product
quan
tity
productqu
anti
ty
quan
tity Revenue for meeting demand
What happens to excess supply?
product
Requirement
Leary Chemical manufactures three chemicals: A, B, and C. These chemicals are produced via two production processes: 1 and 2. Running process 1 for an hour costs $4 and produces 3 units of A, 1 of B, and 1 of C. Running process 2 for an hour costs $1, and produces 1 unit of A and 1 unit of B. Leary has contracts to provide 10 units of A, 5 units of B, and 3 units of C. How should Leary plan its production to minimize the cost of satisfying its contracts?
Modeling involves five distinct processes, which may be repeated a number of times
in any application:
• cataloging what you know about the problem situation
• recalling relevant domain knowledge and facts pertinent to the situation
• recalling appropriate modeling archetypesthat might be applicable to the situation
• creating a particular model• using and evaluating the model, testing it
against the problem situation and iterating the modeling process if necessary
Leary Data
A B C Cost P1 P2 Contract
Formal Model for Leary
• Objective
• Decision
• Cost impact
Formal model (cont’d)
• Constraints
Formal Model (cont’d)
• Let x1 be the number of hours for P1 and x2 be the number of hours for P2
• objective =• constraints:
(product A)(product B)(product C)
Formal Model
Xpress Model(! Leary Chemical example. Model written by Yudi Pranatoand Leon McGinnis!)
model Leary ! Start a new modeluses "mmxprs" ! Load the optimizer library
declarationsx1: mpvar ! number of trucksx2: mpvar ! number of carsend-declarations
! Objective: maximize total profitcost:= 4*x1 + x2
! constraintsprodA:= 3*x1 + x2 >= 10prodB:= x1 + x2 >= 5prodC:= x1 >= 3minimize(cost) ! Solve the LP-problem
Xpress Results! Print out the solution
writeln("Solution:\n Objective: ", getobjval)
writeln(" x1= ", getsol(x1))
writeln(" x2= ", getsol(x2))
end-model
Solution:Objective: 14x1= 3x2= 2
Solve Leary Graphically
Hint: there are three constraints instead of two
X1
X2
Some Thoughts
• Is Leary fundamentally different from Dorian?
• Do the two processes interact?
My diet requires that all the food I eat come from one of the four basic food groups: chocolate cake, ice cream, soda, and apple pie. The costs for the four items are, respectively, $1.50, $.60, $.90, and $2.40. Each day, I must ingest at least 500 calories, 6 oz of chocolate, 10 oz of sugar, and 8 oz of fat. The nutritional content of the four foods are shown below. What is the minimum cost for me to satisfy my dietary requirements?
Calories Chocolate Sugar Fat CostChoc cake 400 3 2 2 $1.50Choc ice cream 200 2 2 4 $0.60soda 150 0 4 1 $0.90cheesecake 500 0 4 5 $2.40Requirement 500 6 10 8
Formal Model for Diet
• Objectiveto minimize cost
• Decisionhow much of each food type to eat
• Cost impactPrice x quantity for each food type
Formal model (cont’d)
• Constraintsminimum consumption for each nutrient type
Formal Model (cont’d)• Let xc be the amount of choc cake, xi the
amount of ice cream, xs the amount of soda,and xe the amount of cheesecake
• minimize 1.5xc + .6xi + .9xs + 2.4xe• constraints:
400xc + 200xi + 150xs + 500xe > 5003xc + 2xi > 62xc + 2xi + 4xs + 4xe > 102xc + 4xi + xs + 5xe > 8
Formal Model
0,84142104422
623500500150200400..
4.29.06.05.1min
21 ≥≥+++≥+++
≥++≥+++
+++
xxxxxxxxxx
xxxxxxtsxxxx
esic
esic
ic
esic
esic
Xpress Modelmodel diet
uses "mmxprs“declarations
Items=1..4PRICE: array(Items) of real x: array(Items) of mpvar !4 types of foods: cake, ice cream, soda, and cheesecake
end-declarationsPRICE := [1.5, 0.6, 0.9, 2.4] !use an array to store the price of each food Calories := 400*x(1) + 200*x(2) + 150*x(3) + 500*x(4) >= 500Chocolate:= 3*x(1) + 2*x(2) >= 6Sugar := 2*x(1) + 2*x(2) + 4*x(3) + 4*x(4) >= 10Fat := 2*x(1) + 4*x(2) + 1*x(3) + 5*x(4) >= 8cost := sum(i in Items) PRICE(i) * x(i)
minimize(cost)
end-model
Xpress Resultswriteln("Solution for Diet Model")
writeln("Units of Chocolate cake= ",getsol(x(1)))
writeln("Units of Chocolate Ice Cream= ",getsol(x(2)))
writeln("Units of Soda= ",getsol(x(3)))
writeln("Units of Cheesecake= ",getsol(x(4)))
writeln("Cost is $", strfmt(getobjval, 4, 2))
Solution for Diet ModelUnits of Chocolate cake= 0Units of Chocolate Ice Cream= 3Units of Soda= 1Units of Cheesecake= 0Cost is $2.70
Can you solve diet graphically?
Hint: there are four decision variables instead of two
Some Thoughts
• Is the Diet problem fundamentally different from Dorian and Leary
• It is an example of an archetype called “blending”--there are several “feed stocks” and each contributes differently to the “product requirement” which has multiple attributes
0,84142104422
623500500150200400..
4.29.06.05.1min
21 ≥≥+++≥+++
≥++≥+++
+++
xxxxxxxxxx
xxxxxxtsxxxx
esic
esic
ic
esic
esic
0,35103..
4min
21
1
21
21
21
≥≥≥+≥+
+
xxx
xxxxtsxx
0,
24122
2827..
10050min
≥
≥+
≥+
+
fc
fc
fc
fc
xxxxxxtsxx
Chandler Oil Company has 5000 barrels of oil 1 and 10,000 barrels of oil 2. The company sells two products, gasoline and heating oil. The quality level of oil one is 10, and for oil 2 is 5. Gasoline must have an average quality level of at least 8, while heating oil must have an average quality level of 6. Demand is created through advertising, and each dollar spent advertising gasoline yields 5 barrels of sales at a price of $25, while each dollar spent advertising heating oil yields 10 barrels of sales at a price of $20. What should Chandler spend on advertising, and what should Chandler produce in order to maximize revenues?
Chandler Data
Qual level AvailabilityOil 1 10 5000Oil 2 5 10000
Quality Ad Yield PriceGas 8 5 25Htg Oil 6 10 20
Structure of Chandler Oil
Oil1 Gasoline
Heat.Oil
Ad Expense
Oil2 Ad Expense
Decisions: blend of oils in each product, and expenditure for advertising for each product, which determines product demand.
Formal Model for Chandler
• Objective
• Decisions
• Net revenue impact
Formal model (cont’d)
• Constraints
Formal Model (cont’d)• Let X(i,j) be the amount of oil type i used to
blend product type j• The quality constraint for gasoline is:
(10X(1,1)+5X(2,1))/(X(1,1)+X(2,1)) > 8• This definitely is NOT linear• Fortunately, it is easily “linearized”--just
multiply through by X(1,1)+X(2,1) and then group terms to get:
2X(1,1) –3X(2,1) > 0
You should write out the detailed formal model for
Chandler Oil
Xpress Model for Chandlermodel chandleruses "mmxprs"declarations
G1, G2, H1, H2, Gad, Had: mpvar !Gi: amount of Oil type i used to make Gasoline!Hi: amount of Oil type i used to make Heating Oil !Gad,Had: amount of advertizing for Gasoline and Heating Oil
end-declarationsGas_Quality := 2*G1 - 3*G2 >= 0HeatingOil_Quality := 4*H1 - 1*H2 >= 0Oil1_Quantity := G1 + H1 <= 5000Oil2_Quantity := G2 + H2 <= 10000Gas_Demand := G1 + G2 <= 5*GadHeatingOil_Demand := H1 + H2 <= 10*HadRevenue := 25*G1 + 25*G2 + 20*H1 + 20*H2 - Gad - Had
maximize(Revenue)
Chandler Xpress Model (cont’d)writeln("Amount of Gas produced= ",getsol(G1+G2))
writeln("Amount of Heating Oil produced= ",getsol(H1+H2))
writeln("Amount of type 1 oil used= ", getsol(G1 + H1))
writeln("Amount of type 2 oil used= ", getsol(G2+H2))
writeln("Spending on Ads for Gas= ",getsol(Gad))
writeln("Spending on Ads for Heating Oil= ",getsol(Had))
writeln("Revenue after Advertising cost is $", getobjval)
end-model
Xpress ResultsAmount of Gas produced= 5000Amount of Heating Oil produced= 10000Amount of type 1 oil used= 5000Amount of type 2 oil used= 10000Spending on Ads for Gas= 1000Spending on Ads for Heating Oil= 1000Revenue after Advertising cost is $323000
Can you tell me if this is a reasonable answer?
How do you know the formulation wasn’t flawed, or data entered incorrectly?
Chandler Data
Qual level AvailabilityOil 1 10 5000Oil 2 5 10000
Quality Ad Yield PriceGas 8 5 25Htg Oil 6 10 20
Xpress ResultsAmount of Gas produced= 5000Amount of Heating Oil produced= 10000Amount of type 1 oil used= 5000Amount of type 2 oil used= 10000Spending on Ads for Gas= 1000Spending on Ads for Heating Oil= 1000Revenue after Advertising cost is $323000
If Chandler Oil has an opportunity to purchase more crude 1 for $18/bbl or crude 2 for $9/bbl, should they do it?
“Shadow Prices”• Xpress-IVE (and all other LP optimizers)
computes a quantity associated with each constraint
• This is commonly referred to as a “shadow price” or a “dual variable” (for reasons that become clear in 4231)
• The shadow price is, in effect, the partial derivative of the objective function, with respect to the rhs of the corresponding constraint.
Chandler Oil Shadow PricesCode is:
writeln("Shadow price for Crude 1 is $", getdual(Oil1_Quantity))
writeln("Shadow price for Crude 2 is $", getdual(Oil2_Quantity))
Result is:
Shadow price for Crude 1 is $29.7
Shadow price for Crude 2 is $17.45
Does this seem reasonable to you?
Changing Crude 1 RHS to 5001
Amount of Gas produced= 5002Amount of Heating Oil produced= 9999Amount of type 1 oil used= 5001Amount of type 2 oil used= 10000Spending on Ads for Gas= 1000.4Spending on Ads for Heating Oil= 999.9Revenue after Advertising cost is $323030Shadow price for Crude 1 is $29.7Shadow price for Crude 2 is $17.45
Another way to see
• Shadow prices is in the Xpress-IVE user interface
• Simply put your cursor on the constraint name in the panel on the left, and a pop-up will show you the dual variable value
Other Model Archetypes
• Allocation: splits resource(s) among competing uses– special case is “transportation problem”
(see transport.mod)• Operations planning: determines
periodic operations decisions, usually with some form of inventory (what to do and when to do it) (Jos. A Bank example)
What are the common attributes of the linear
programming (LP) models for these decision problems?
LP’s have these attributes• Decision variables are continuous
(divisibility)• Impact of decision variable is proportional
to its value (proportionality)• Impact of one decision variables is
independent of the impact of the others (additivity)
• Parameter values are known and constant (certainty)
If you want to excel as an IE
• You need to be able to start from a complex problem, abstract the problem, and create formal models
• You need to be able to use your formal model in a computational analysis
What’s next?
• Variations of LP models that incorporate more realistic behavior, especially discreteness