Title: Linear Programming
1Linear Programming
2Linear Programming
- Linear programming (LP) techniques consist of a
sequence of steps that will lead to an optimal
solution to problems, in cases where a solution
exists, given restrictions or limitations
3Applications of LP
- Linear Programming is a powerful tool to solve a
variety of business problems. Examples include - Resource Allocation
- Given we have a limited supply of X, how do we
divvy it to realize the most profit? - Portfolio Selection
- Scheduling Crews and Equipment
- These are popular problems with Airlines and the
military - Production Planning
- Optimal Blending (Animal Feeds, Petrochemicals,
etc.) - What is the most cost effective way to meet our
production schedule given current resource /
capacity constraints? - Logistics
- How do we deliver our contracted amounts while
keeping our distribution costs as low as
possible?
4Linear Programming ModelTerms to learn over the
next few lectures
- Objective Function the goal of an LP model is
either maximization or minimization - Decision variables choices available to the
decision maker, either inputs or outputs - Feasible solution space the set of all feasible
combinations of decision variables as defined by
the constraints. Realm of Possibilities - Constraints limitations that restrict the
available alternatives - Parameters numerical values that are known and
fixed
5Linear Programming Assumptions
- Linearity the impact of decision variables is
linear in both constraints and objective function - Divisibility non-integer values of decision
variables are acceptable - Certainty values of parameters are known and
constant (within the scope of the problem) - Non-negativity negative values of decision
variables are unacceptable - CAVEAT Negativity is not inherently prohibited
it is possible to formulate a valid LP with
variables that could take negative values (i.e.
shorting a stock in a portfolio optimization
problem). In 412 will never have variables that
make sense as negatives!
6Steps of Linear Programming
- Model Formulation
- Solving the LP
- 2 variables Graphical Methods
- 3 or more variables Computer Algorithms
- Studying the Results Output Reports and
Sensitivity Analysis
7Steps of Model Formulation
- Determine the decision variables
- Identify the objective. Minimize or Maximize?
- Express constraints in terms of the decision
variables - Dont Forget
- Make units consistent
- The simplest formulation that captures the
relevant problem information is usually the best
8Model Formulation Constraints3 Types Possible
- Less than
- 3x 7y
- Do not exceed 40 hours of machine time
- Greater than
- 5x 6y 21
- Use at least 21 kg of recycled materials
- Equality
- x y 60
- Produce exactly the 60 units demanded (of
either/both x and y)
9Model Formulation Constraints
- In practice, equality constraints are usually
converted to inequalities, enabling more freedom
in the solution and easier computation - E.g. produce at least the 60 units demanded. x
y 60 - The inequality will most likely become an
equality at the optimum, unless there really is
an advantage to overproducing to the contracted
demand spec - Variables that have ratio and percentage
relationships with each other can also be
represented - Diet LP Fat calories less than 30 of all
calories consumed - F .7F -.3C - .3P 0
- Ratio of Peanut Butter to Chocolate must not
exceed 32 - PB/C 2PB 2PB - 3C
10To Maximize or Not to MaximizeA Monologue on
Defining Your Objective Function
- We have the choice of either minimizing costs (
expenditures, hours worked, or other variables
that detract from our well-being) or of
maximizing benefits ( profits, items produced,
or other variables contributing to our
well-being) - Note that the following are equivalent -you will
get the same answer with either as your objective
function - Max z 2x 3y
- Min z -2x 3y
- Rule of thumb If your objective coefficients
- are all benefits, keep positive and maximize
- ... are all costs, make positive and minimize
- are mixed costs and benefits (i.e. 2x-3y )
then usually we maximize (and make sure all signs
are right!)
11Graphical Linear Programming
- Set up objective function and constraints in
mathematical format - Plot the constraints
- Identify the feasible solution space
- Plot the objective function
- Determine the optimum solution
- Visually or algebraically
12The Optimal Product Mix A Simple (and Tasty)
Example
- You want to make as much money as possible at
tomorrows bake sale - You know two different cookie recipes chocolate
chip cookies and sugar cookies - You can sell all you make if you price at 1.50
per chocolate chip cookie and 1 per sugar cookie - You have a finite amount of supplies. You have
to follow the given recipes exactly, but can make
partial batches
13Product Mix Example...
14Product Mix Example...
- You have the following ingredients on-hand, and
dont plan to go to the store for more - 1.5 boxes of butter (6 sticks)
- 5 cups of sugar
- 1 dozen eggs
- 2 cups of chocolate chips
- ½ bag (10 cups) of flour
- Question How many batches of each type of
cookie should you make?
15Formulate the Problem
- Identify the decision variables
- xc number of batches of chocolate chip cookies
- xs number of batches of sugar cookies
- Units Use batches rather than individual
cookies, since recipes are expressed in batches
and numbers should be easier to work with -
- Define the objective function
- We are maximizing revenue
- remember 20 cookies per batch
- Max Z 30 xc 20 xs
16Add the Constraints
- A constraint is associated with each ingredient
-
- Butter cannot exceed 6 sticks
- 2xc 2xs
- Sugar cannot exceed 5 cups
- xc 2xs
- Eggs cannot exceed 1 doz.
- 2xc 3xs
- Chocolate Chips cannot exceed 2 cups (sugar
cookies dont use) - xc
- Flour cannot exceed 10 cups.
- 2xc 2xs
- Are there any other constraints?
17Plot the Constraints
18Plot the Constraints, cont.
19Identify the Feasible Region
20Graph the Objective Function
- An Iso-profit line has the same profit at every
point -
- Iso-profit lines are parallel to each other, as
they have the same slope - Our Example -.67 slope of Ch. Chip Cookies to
Sugar Cookies - The further from the origin, the larger the value
of Z (total revenue) - In attempting to maximize revenue, we want to
pick the iso-profit line furthest from the origin
that still intersects the feasible region - The Optimal Solution will always be at a Vertex
(Corner Point) of the feasible region
21More on Slope The Objective Function
- With 2 variable problems, the level of 1 variable
(Xs) corresponds to the x axis, the other
variable (Xc) to the y-axis - The slope of the objective function slope
represents the ratio of prices (or costs) of the
variables Price(Xs)/Price(Xc). - What do all 4 of those lines below have in common?
- In our example a batch of sugar cookies (Xs)
sells for 20, a batch of chocolate chip (Xc) for
30 Slope - (20/30) -.667 - We could make 60 in total by either selling
just 3 Xs or just 2 Xc or some other combo, like
1.5Xs, 1Xc. Which line is this on the graph? - If the price of sugar cookies doubled (and ch.
chip cookies remained at 30), the new slope
would be (40/30) - 1.33. The objective
function would get steeper, and we would try to
make more sugar cookies (at the expense of ch.
chip cookies)
22Graph the Objective Function
23LP, the Movie the Objective Function Grows
until Constrained!
24Visually Finding the Optimum
25Algebraic Solution
- While the solution in this example is easy to see
from the graph, it will sometimes be necessary to
resort to algebra - Determine which constraints form the vertex that
is the optimal solution (will usually be 2) - With this solution, it is the Butter and
Chocolate Chip Constraints - Butter 2xc 2xs
- Chocolate Chips xc
- The constraints are binding along the constraint
line (i.e. We have equalities- use exactly 2 cups
Chocolate Chips and 6 Sticks Butter). - So solve the system with 2 equations, 2 unknowns
- 2xc 2xs 6
- xc 2
- Solving this gives xc 2, xs 1
26Notes on the Solution
- Optimal Levels of the Decision Variables
- xc 2 Batches of Chocolate Chip Cookies
- xs 1 Batches of Sugar Cookies
- Here the optimal product mix is in whole batches,
but only because we were lucky. - Optimized Revenue Z 80
- Looking at the constraints
- Butter and Chocolate Chips are Binding
Constraints. We use all we have, and might have
been able to make more with more - Sugar is Non-Binding. We have leftovers, and
more sugar would not have helped us make more - Remember we previously determined that Eggs and
Flour were Redundant. (Hence automatically
Non-Binding)
27Graphical Linear Programming
- Set up objective function and constraints in
mathematical format - Plot the constraints
- Identify the feasible solution space
- Plot the objective function
- Determine the optimum solution
- Visually or algebraically
28Graphical LPs, Another Example
- A microbrewery produces dark and light beer,
which have 20 and 12 per barrel profits,
respectively -
- They have contracted for delivery of 160 lbs of
hops and 1200 lbs of malt (They more than enough
yeast) - It takes 4 lbs of hops to make 1 barrel of either
light or dark beer, but it takes much more malt
to make dark beer (40 lbs) than light beer (20
lbs) - The microbrewery would like to maximize their
profits with the materials on-hand. What should
they do?
29(No Transcript)
30(No Transcript)
3120 barrels dark beer, 20 barrels light
beer, Profit 640
32Enumeration An Alternate Approach
- If you dont like working with objective
functions, you can do the following - Graph the feasible region
- Look at every corner point and calculate the
objective value - Pick the best
- Downsides
- Can be a lot of points to calculate
- You lose the visual picture of what is going on
with profits/costs
33Solving Larger Problems?
- As we expand the complexity of the model, the
number of variables increases dramatically - Real world problems have thousands of variables
- The graphical method cant handle problems with
more than 2 variables - if you are talented with 3D graphing, you can try
3 variables - Instead, use Computerized Solvers
- Computers make use of algorithms like the Simplex
Method, Interior Point Method, Primal-Dual, etc. - Excel Solver - useful for small scale problems
(under 200 decision variables)
34Product Mix Extension
- Assume nothing has changed from the previous
Product Mix example, except you now have a recipe
for Fudge Squares - 2 sticks butter
- 1 cup sugar
- 2 cups chocolate chips
- Assume you can sell these at 1.50 apiece, and
also that you can cut a batch up into smaller
pieces (30 squares per batch) - Question How many batches of each type of
cookie should you make now?
35Adjust Formulation
- Include a new decision variable
- xf - the number of batches of fudge squares
- Objective Function is now
- Max Z 30xc 20xs 45xf
- Adjust the constraints to include the new
variable - Butter 2xc 2xs 2xf
- Sugar xc 2xs xf
- Eggs 2xc 3xs
- C. Chips xc 2xf
- Flour 2xc 2xs
36Formulation in Excel
- Decision variables are in blue, currently set at
previous optimal solution - Objective value, Summation of resources used are
in orange
37Formulation in Excel
- Enter the Objective Value, Decision Variables
and Constraints - Under Options check both
- Assume Linear Model
- Assume Non-Negative
38Excel Returns the Solution
- Make 1 batch of Fudge Squares and 2 batches of
Sugar Cookies to improve profit by 5 by
switching to this product mix. - The optimal solution is still on a corner point
(vertex), but it not as easy to visualize with 3
or more variables
39Analyzing the Results
- There is more information in the solution than
just the level of the decision variables and
objective function - Practically we want to know how stable or
sensitive the optimal solution is - We may not have accurate data on all parameters
- We might be able to relax some of the
constraints, and need to know if it would be
worthwhile to consider - Therefore we look at Reports and do Sensitivity
Analysis - Excel provides an Answer Report and Sensitivity
Report
40Example Answer Report
41Interpreting theExcel Output Report
- Shows you cell references for debugging
formulation - Displays Level of the Objective Function (Target
Cell) and level of Decision Variables (Adjustable
Cells) - Look at Final Value and Original Value if you
want to compare results to the previous solution - In our example Went from z80 (2 Xc, 1 Xs) to z
85 (2 Xs, 1 Xf), improved total revenues by 5 - For constraints
- Aside from location (Cell) Constraint Name, and
Formula we get - Cell Value amount of constraint usage
- Status is the constraint Binding or Non-Binding
- How much Slack (will only be non-zero if Binding)
- Slack?! What is Slack? See next few slides
42Review on Constraints
- Binding Constraint A constraint that forms the
optimal corner point (vertex) of the feasible
solution space - we have no wiggle room
- Non-Binding Constraint A constraint that is not
part of the optimal corner point - We have some wiggle room
- Redundant Constraint a constraint that does not
form a unique boundary of the feasible solution
space - We are never up against this constraint for any
feasible solution. We dont have to worry about
it ever! (unless the other constraints get
relaxed)
43Slack and Surplus
- Non-Binding Constraints have either Slack or
Surplus - Slack When the optimal values of the decision
variables are substituted into a less than or
equals constraint and the resulting value is
less than the right side value. - We have 6 extra eggs in our product mix example
for 3 recipes - 2(xc 0) 3 (xs 2)
- . Surplus When the optimal values of the
decision variables are substituted into a
greater than or equals constraint and the
resulting value exceeds the right side value. - Note
- Equality constraints are always binding
- Slack often used as the generic term, as in Excel
Solver
44Sensitivity Analysis
- For decision variables (Adjustable Cells) Excel
shows the following - Final Value (same as in Answer Report)
- Reduced Cost (dont worry about for this class)
- Objective Coefficient Allowable Increase and
Decrease (Range of Optimality) the range of
values the prices could vary and yet levels for
the decision variables remains the same. - What the prices/costs could change by and not
change optimal values for the decision variables
- The objective value, Z, would change, but not the
levels of Xs, Xc, etc
45Sensitivity Analysis, pt 2
- For Constraints
- Look at the Final Value and compare to the
Constraint R.H. Side. - Same info as Slack (Constraints
Binding/Nonbinding) on the Answer Report - Shadow Price The amount an additional unit on
the RHS of the constrained resource might affect
the objective value - Only binding constraints have non-zero Shadow
prices - This price is not a guarantee- we might run into
an additional constraint that would prevent us
from utilizing all of the additional unit. - The Allowable (RHS) Increase and Decrease- Show
how much the RHS could change and not change the
shadow price. - The interval determined by these is called the
range of feasibility
46Example Sensitivity Report
47Sensitivity Analysis the Range of Optimality
- Definition What the price of one of the decision
variables could change by, yet still have the
current solution (2 Xs,1Xf) remain the best
choice - Objective Coefficient - Allowable Coefficient
Decrease, - Objective Coefficient Allowable
Coefficient Increase - Example
- Chocolate Chip Cookies- between 0 and 32.5 per
batch - Sugar Cookies between 15 and 45 per batch
- Fudge Squares between 40 and infinity per batch
- If the price stays within the Range of
Optimality, The objective value, Z, would change,
but not the levels of Xs, Xc, Xf - If price of sugar cookies rose to 30 from 20,
wed make 20 more revenue in total, but still
make the same mix (2 Xs,1Xf) - However, if the price of Chocolate Chip cookies
rose to 35, we are outside the range of
optimality for the current solution. - Resolving shows wed make (2 Xc, 1Xs ) for z
23520 90 total revenue
48Interpreting the Sensitivity Report, part 2
- Some conclusion for the section on constraints
- Chocolate Chips are the most prized critical
resource- use all 2 cups - Wed pay up to 12.50 for another cup of
chocolate chips. (Can see by re-solving the
model with an extra cup gives 1.5 Xf, 1.5 Xs, for
97.5, a 12.5 improvement.) - This shadow price would remain the same if we had
up to 6 cups of chips but would change if we had
any less than 2 cups - Eggs- We use only 6 of the 12 eggs available to
us, giving a shadow price of 0. If we decreased
the amount of eggs by 6, then wed get a new
shadow price (Eggs would become a binding
constraint.) - Please remember the shadow price is not a
guarantee- we might run into an additional
constraint that would prevent us from utilizing
all of the additional unit. - Resolving with an extra stick of butter does not
yield a 10 improvement in the objective function
as the shadow price of butter would suggest - Instead we run into other limits and make (2 Xc,
1.5 Xs) for z 90, a mere 5 improvement)
49Solution States
- We may not always formulate a problem that has a
unique, feasible optimum. Here are the other
possibilities - Infeasible Problem The feasible space is
empty. No solution is possible - Example MaxiZ 3X 2Y
- s.t. X Y
- X Y 4
- Excel solver will tell you if you are infeasible
- Unbounded Problem The feasible space is
unconstrained and the objective function can
increase to infinity - Example Max Z 3X 2Y
- s.t. X Y 4
- X 0, Y 0
- Note that if our objective was to minimize
instead of maximize, we would get a finite
optimal solution X 0, Y 4, Z 8. - Excel solver will tell you if you are unbounded
(cannot converge)
50Solution States, continued
- Multiple/Alternate Optima The objective
function is parallel to one of the binding
constraints, resulting in a range of optimal
solutions - All of these optimal solutions are vertices
- Multiple Optima are easy to see in Graphical
Solutions and have to be checked for when solved
by computer (for instance, Excel Solver does not
automatically tell you that you have multiple
optima.) - In 412 we will not work with homework or exam
problems that have multiple optima. In the
highly unlikely event that one such problem turns
up, I will accept any of these optima as valid.
51Multiple Optima, Example
- From the cookie example, if the price of sugar
cookies increases to 1.50 Max Z 30 xc 30
xs
52Multiple Optima in Excel
- Assume with the product mix example that the
fudge price per batch is only 40. - For our solution with 2 batches Sugar Cookies and
1 batch Fudge Squares, Z drops to 80 - But remember that 80 was the revenue for 2
batches Chocolate Chip, 1 batch Sugar - Solving in Excel shows that the optimal Z is 80.
But how would we know that there are multiple
optima? - Look at the Sensitivity Report
- Check if the number of non zeros totaling Slack
and Reduced Costs is less than the number of
decision variables - Another Hint If the allowable increase/decrease
in the objective function coefficients is 0, that
means that any change, however slight will result
in a different set of decision variables. - Correspondingly, one can get rid of multiple
optima by changing the objective coefficients
slightly to force a unique optimum
53Multiple Optima in Excel
- Can see this example has multiple optima by one
of 2 ways - Any change to the objective coefficients will
resort in a new solution - Is a 3 variable problem, yet only 2 non-zero
entries combined within the Reduced Cost and
Shadow Price columns
54Additional Examples for Practice, Homework and
Past Exam Problems Solved
55Examples HW Problems
- P291 Pr 3 An appliance manufacturer produces 2
models of microwave ovens H and W, which require
fab and assembly work. - Each H requires 4 hours of fab, 2 of assembly and
has a 40 profit - Each W requires 2 hours of fab, 6 of assembly
and has a 30 profit - The manufacturer has hours of 600 fab time and
480 hours of assembly available each week - What feasible product mix will maximize weekly
Profit?
56Examples HW problems
- Pr12 The manager of a deli section of a grocery
store has just learned that they have 112 lbs of
mayonnaise, of which 70 lbs is about to expire
and needs to be used up. To use it up, the deli
can either prepare Ham trays or Deli trays. (The
problem assumes that they can sell whatever is
prepared) - Each tray of Ham spread uses 1.4lbs mayo and each
tray of Deli spread uses 1.0 lbs - Both cost 3/tray to make, Ham sells for 5/tray,
Deli 7/tray - The manager has existing orders for 10 trays of
Ham, 8 of Deli and wants to have at least 10
additional trays of both spreads available for
sale - Determine the solution that will minimize Cost
- Then
- Determine the solution that will maximize Profit
57Extending the Product Mix Problem Purchasing
Supplies
- Assume original prices on each of the 3 cookies
we can make. Also assume that we have the same
number of original supplies, BUT we could go to
the nearby Rip-Off Mart. - Prices are 5 per stick butter, 3 per cup sugar,
20 per cup of chocolate chips! Furthermore,
they dont stock eggs or flour. - For the purpose of maintaining linearity we allow
fractional purchases (e.g. .5 sticks butter) - Is it worth it to pay these outrageous prices?
- How do we formulate the problem to allow for
purchasing supplies?
58Product Mix w/Purchasing Adjust Formulation
- Include 3 new decision variables
- yb - the amount of butter we buy
- ys - the amount of sugar we buy
- ycc - the amount of chocolate chips we buy
- Objective Function is now
- Max Z 30xc 20xs 45xf 5yb 3ys -20ycc
- Adjust the constraints to include the new
variables - Butter 2xc 2xs 2xf yb
- Sugar xc 2xs xf ys
- Eggs 2xc 3xs
- C. Chips xc 2xf ycc
- Flour 2xc 2xs
59Product Mix w/Purchasing Excel Answer Report
60Production and Distribution Example
- A firm needs to schedule production and
distribution of its primary product to satisfy
this months warehouse demand at 3 locations in a
cost-effective manner. - W1 700 units W2 800 units W3 600 units
- The firm has 2 plants, PA and PB, with monthly
production capacities of 1000 units and 1200
units, and unit production costs of 5.50/unit
and 5.00/unit, respectively - Because of the diverse locations of the plants
and warehouse, unit transportation costs differ
(but can be assumed linear).
Assume a single time period of 1 month, no prior
warehouse inventory. How would we formulate an LP
to solve this problem?
61Model Formulation Production and Distribution
Example
- Create the Decision Variables, 6 in total
- X_a1 Units manufactured at Plant A for Warehouse
1 - X_a2 Units manufactured at Plant A for Warehouse
2 - etc
- Set up the Objective Function
- Overall Goal Minimize costs given demand quotas
- Objective Function Coefficients sum costs for
manufacture and transport - X_a1(5.50 .2.50) X_a2(5.50.50)
X_b3(5.003.00) - Add the Constraints
- 2 types of constraints Production Capacity
Limits and Warehouse Demand Quotas - No bounds on transit routes were provided, but
could be added later, if needed
62Excel Formulation
- The way the decision variables were set up
allowed for the constraint matrix to have a
regular form - X_a1 Units manufactured at Plant A for
Warehouse 1
63Excel Formulation, Part 2
- Notice that the Demand Constraints are not set
as equalities, but as S - Minimization will prevent needless
overproduction - This formulation will allow greater freedom. In
a more complex, multi period model we may
overproduce one month to make up a shortfall later
64Excel Answer Report
65Excel Sensitivity Report
- From these 2 reports we see that the solver
satisfies demands exactly, and that there is
slack in production at Plant B. Also, the
solution avoids using more expensive transport
routes.
66Examples HW problems
- HW-former exam problem A fertilizer manufacturer
has to fulfill supply contracts to its two main
customers (650 tons to Cust_A and 800 tons to
Cust_B). It can meet this demand by shipping
from existing inventory from any of its 3
warehouses. W1 has 400 tons of inventory
onhand, W2 has 500 tons and W3 has 600 tons.
They would like to arrange the shipping for the
lowest cost possible, where the per ton transit
costs are as follows - Explain what each of the six decision variables
(V1 thru V6) is - Write out the Objective function
- Are we maximizing or minimizing?
- What are the 5 constraints (label and write out
formulae)
67HW/Exam problem cont.
- Now given Excels sensitivity report for the
problem - How many of the constraints are binding? ___
- How much slack/surplus is there with the
non-binding constraint(s)? ____ - What is the range of optimality on Variable V3?
_____ to _____