More Linear Programming Models - gatech.edu

64
More Linear Programming Models (many of these examples come from Introduction to Mathematical Programming by Wayne L. Winston)

Transcript of More Linear Programming Models - gatech.edu

Page 1: More Linear Programming Models - gatech.edu

More Linear Programming Models

(many of these examples come from Introduction to Mathematical Programming by Wayne L. Winston)

Page 2: More Linear Programming Models - gatech.edu

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

Page 3: More Linear Programming Models - gatech.edu

Today, more formal modeling

And more Visual Xpress computational models.

Page 4: More Linear Programming Models - gatech.edu

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

Page 5: More Linear Programming Models - gatech.edu

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?

Page 6: More Linear Programming Models - gatech.edu

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.

Page 7: More Linear Programming Models - gatech.edu

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?

Page 8: More Linear Programming Models - gatech.edu

Dorian Data

Women Men Cost Comedy Football Need

Page 9: More Linear Programming Models - gatech.edu

Formal Model for Dorian

• Objective

• Decision

• Cost impact

Page 10: More Linear Programming Models - gatech.edu

Formal model (cont’d)

• Constraints

Page 11: More Linear Programming Models - gatech.edu

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

Page 12: More Linear Programming Models - gatech.edu

Formal Model

Page 13: More Linear Programming Models - gatech.edu

Xpress Modelmodel dorianvariablesxcxfconstraintscost: 50*xc + 100*xf $women: 7*xc + 2*xf > 28men: 2*xc + 12*xf > 24generate

Page 14: More Linear Programming Models - gatech.edu

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

Page 15: More Linear Programming Models - gatech.edu

Solve Dorian Graphically

Page 16: More Linear Programming Models - gatech.edu

Xc

Xf

Page 17: More Linear Programming Models - gatech.edu

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.

Page 18: More Linear Programming Models - gatech.edu

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

Page 19: More Linear Programming Models - gatech.edu

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

Page 20: More Linear Programming Models - gatech.edu

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?

Page 21: More Linear Programming Models - gatech.edu

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

Page 22: More Linear Programming Models - gatech.edu
Page 23: More Linear Programming Models - gatech.edu

Leary Data

A B C Cost P1 P2 Contract

Page 24: More Linear Programming Models - gatech.edu

Formal Model for Leary

• Objective

• Decision

• Cost impact

Page 25: More Linear Programming Models - gatech.edu

Formal model (cont’d)

• Constraints

Page 26: More Linear Programming Models - gatech.edu

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)

Page 27: More Linear Programming Models - gatech.edu

Formal Model

Page 28: More Linear Programming Models - gatech.edu

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

Page 29: More Linear Programming Models - gatech.edu

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

Page 30: More Linear Programming Models - gatech.edu

Solve Leary Graphically

Hint: there are three constraints instead of two

Page 31: More Linear Programming Models - gatech.edu
Page 32: More Linear Programming Models - gatech.edu

X1

X2

Page 33: More Linear Programming Models - gatech.edu

Some Thoughts

• Is Leary fundamentally different from Dorian?

• Do the two processes interact?

Page 34: More Linear Programming Models - gatech.edu

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

Page 35: More Linear Programming Models - gatech.edu

Formal Model for Diet

• Objectiveto minimize cost

• Decisionhow much of each food type to eat

• Cost impactPrice x quantity for each food type

Page 36: More Linear Programming Models - gatech.edu

Formal model (cont’d)

• Constraintsminimum consumption for each nutrient type

Page 37: More Linear Programming Models - gatech.edu

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

Page 38: More Linear Programming Models - gatech.edu

Formal Model

0,84142104422

623500500150200400..

4.29.06.05.1min

21 ≥≥+++≥+++

≥++≥+++

+++

xxxxxxxxxx

xxxxxxtsxxxx

esic

esic

ic

esic

esic

Page 39: More Linear Programming Models - gatech.edu

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

Page 40: More Linear Programming Models - gatech.edu

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

Page 41: More Linear Programming Models - gatech.edu

Can you solve diet graphically?

Hint: there are four decision variables instead of two

Page 42: More Linear Programming Models - gatech.edu

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

Page 43: More Linear Programming Models - gatech.edu

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

Page 44: More Linear Programming Models - gatech.edu

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?

Page 45: More Linear Programming Models - gatech.edu

Chandler Data

Qual level AvailabilityOil 1 10 5000Oil 2 5 10000

Quality Ad Yield PriceGas 8 5 25Htg Oil 6 10 20

Page 46: More Linear Programming Models - gatech.edu

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.

Page 47: More Linear Programming Models - gatech.edu

Formal Model for Chandler

• Objective

• Decisions

• Net revenue impact

Page 48: More Linear Programming Models - gatech.edu

Formal model (cont’d)

• Constraints

Page 49: More Linear Programming Models - gatech.edu

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

Page 50: More Linear Programming Models - gatech.edu

You should write out the detailed formal model for

Chandler Oil

Page 51: More Linear Programming Models - gatech.edu

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)

Page 52: More Linear Programming Models - gatech.edu

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

Page 53: More Linear Programming Models - gatech.edu

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?

Page 54: More Linear Programming Models - gatech.edu

Chandler Data

Qual level AvailabilityOil 1 10 5000Oil 2 5 10000

Quality Ad Yield PriceGas 8 5 25Htg Oil 6 10 20

Page 55: More Linear Programming Models - gatech.edu

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?

Page 56: More Linear Programming Models - gatech.edu

“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.

Page 57: More Linear Programming Models - gatech.edu

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?

Page 58: More Linear Programming Models - gatech.edu

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

Page 59: More Linear Programming Models - gatech.edu

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

Page 60: More Linear Programming Models - gatech.edu

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)

Page 61: More Linear Programming Models - gatech.edu

What are the common attributes of the linear

programming (LP) models for these decision problems?

Page 62: More Linear Programming Models - gatech.edu

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)

Page 63: More Linear Programming Models - gatech.edu

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

Page 64: More Linear Programming Models - gatech.edu

What’s next?

• Variations of LP models that incorporate more realistic behavior, especially discreteness