Linear Programming: Basic Concepts

Linear Programming:
Basic Concepts
MS (Spring 2015)
Table of Contents
•
•
•
•
•
•
•
•
•
Three Classic Applications of LP
The Wyndor Glass Company Product Mix Problem
Formulating the Wyndor Problem on a Spreadsheet
The Algebraic Model for Wyndor
The Graphical Method Applied to the Wyndor Problem
Using the Excel Solver with the Wyndor Problem
A Minimization Example—The Profit & Gambit Co.
Introduction to Linear Programming
The Graphical Method and Properties of LP Solutions
2
MS (Spring 2015)
Three Classic Applications of LP
• Product Mix at Ponderosa Industrial
– Considered limited resources, and determined optimal mix of
plywood products.
– Increased overall profitability of company by 20%.
• Personnel Scheduling at United Airlines
– Designed work schedules for all employees at a location to meet
service requirements most efficiently.
– Saved $6 million annually.
• Planning Supply, Distribution, and Marketing at Citgo
Petroleum Corporation
– The SDM system uses LP to coordinate the supply, distribution, and
marketing of each of Citgo’s major products throughout the United
States.
– The resulting reduction in inventory added $14 million annually to
Citgo’s profits.
3
MS (Spring 2015)
Wyndor Glass Co. Product Mix
Problem
• Wyndor has developed the following new products:
– An 8-foot glass door with aluminum framing.
– A 4-foot by 6-foot double-hung, wood-framed window.
• The company has three plants
– Plant 1 produces aluminum frames and hardware.
– Plant 2 produces wood frames.
– Plant 3 produces glass and assembles the windows and doors.
Questions:
1. Should they go ahead with launching these two new products?
2. If so, what should be the product mix?
4
MS (Spring 2015)
Algebraic Model for Wyndor Glass Co.
Let D = the number of doors to produce
W = the number of windows to produce
Maximize P = $300D + $500W
subject to
D≤4
2W ≤ 12
3D + 2W ≤ 18
and
D ≥ 0, W ≥ 0.
5
MS (Spring 2015)
Graphing the Product Mix
W
Production rate (units per week) for windows
8
A product mix of
D = 4 and W = 6
7
(4, 6)
6
5
4
A product mix of
D = 2 and W = 3
3
(2, 3)
2
1
Origin
-2
-1
0
-1
1
2
3
4
5
6
7
8
Production rate (units per week) for doors
D
-2
6
MS (Spring 2015)
Graph Showing Constraints: D ≥ 0 and
W≥0
W
Production rate for windows
8
6
4
2
0
2
4
6
8
D
Production rate for doors
7
MS (Spring 2015)
Nonnegative Solutions Permitted by
D≤4
W
8
Production rate for windows
D=4
6
4
2
0
2
6
4
Production rate for doors
8
D
8
MS (Spring 2015)
Nonnegative Solutions Permitted by
2W ≤ 12
Production rate for windows
W
8
2 W = 12
6
4
2
0
2
4
Production rate for doors
6
8
D
9
MS (Spring 2015)
Boundary Line for Constraint
3D + 2W ≤ 18
Production rate for windows
W
10
(0, 9)
8
1
(1, 7 _)
2
(2, 6)
6
3 D + 2 W = 18
1
(3, 4 _)
2
4
(4, 3)
2
1
(5, 1 _)
2
(6, 0)
0
2
4
Production rate for doors
6
8
D
10
MS (Spring 2015)
Changing Right-Hand Side Creates
Parallel Constraint Boundary Lines
Production rate for windows
W
12
10
3D + 2W = 24
8
6
3D + 2W = 18
4
2
0
3D + 2W = 12
2
4
6
8
Production rate for doors
10
D
11
MS (Spring 2015)
Nonnegative Solutions Permitted by
3D + 2W ≤ 18
Production rate for windows
W
10
8
6
3D + 2W = 18
4
2
0
2
4
Production rate for doors
6
8
D
12
MS (Spring 2015)
Graph of Feasible Region
Production rate for windows
W
10
3 D + 2 W = 18
8
D=4
2 W =12
6
4
Feasible
2
0
region
2
4
Production rate for doors
6
8
D
13
MS (Spring 2015)
Objective Function (P = 1,500)
Production rate
W
for windows
8
6
4
Feasible
region
P = 1500 = 300D + 500W
2
0
2
4
Production rate for doors
6
8
D
14
MS (Spring 2015)
Finding the Optimal Solution
Production rate
W
for windows
8
P = 3600 = 300D + 500W
Optimal solution
(2, 6)
P = 3000 = 300D + 500W 6
Feasible
4
region
P = 1500 = 300D + 500W
2
0
2
4
Production rate for doors
6
8
10
D
15
MS (Spring 2015)
Summary of the Graphical Method
• Draw the constraint boundary line for each constraint. Use the
origin (or any point not on the line) to determine which side of
the line is permitted by the constraint.
• Find the feasible region by determining where all constraints
are satisfied simultaneously.
• Determine the slope of one objective function line. All other
objective function lines will have the same slope.
• Move a straight edge with this slope through the feasible region
in the direction of improving values of the objective function.
Stop at the last instant that the straight edge still passes through
a point in the feasible region. This line given by the straight
edge is the optimal objective function line.
• A feasible point on the optimal objective function line is an
optimal solution.
16
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #1: Data Cells
– Enter all of the data for the problem on the
spreadsheet.
– Make consistent use of rows and columns.
– It is a good idea to color code these “data cells”
(e.g., light blue).
3
4
5
6
7
8
B
C
D
Profit
Tables
$20.00
Chairs
$15.00
Large Bricks
Small Bricks
Bill of Materials
2
1
2
2
E
F
G
Available
6
8
17
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #2: Changing Cells
– Add a cell in the spreadsheet for every decision that
needs to be made.
– If you don’t have any particular initial values, just enter
0 in each.
– It is a good idea to color code these “changing cells”
(e.g., yellow with border).
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
0
E
F
G
Hours
Available
1
12
18
Windows
0
18
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #3: Target Cell
– Develop an equation that defines the objective of the model.
– Typically this equation involves the data cells and the
changing cells in order to determine a quantity of interest
(e.g., total profit or total cost).
– It is a good idea to color code this cell (e.g., orange with
heavy border).
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
E
F
Hours
Available
1
12
18
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
1
G
Windows
1
Total Profit
$800
G
11
Total Profit
12 =SUMPRODUCT(UnitProfit,UnitsProduced)
19
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #4: Constraints
– For any resource that is restricted, calculate the amount of that
resource used in a cell on the spreadsheet (an output cell).
– Define the constraint in three consecutive cells. For example, if
Quantity A ≤ Quantity B, put these three items (Quantity A, ≤,
Quantity B) in consecutive cells.
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
1
E
Hours
Used
1
2
5
Windows
1
F
G
<=
<=
<=
Hours
Available
1
12
18
Total Profit
$800
E
5
6
7
8
9
Hours
Used
=SUMPRODUCT(C7:D7,UnitsProduced)
=SUMPRODUCT(C8:D8,UnitsProduced)
=SUMPRODUCT(C9:D9,UnitsProduced)
20
MS (Spring 2015)
A Trial Solution
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
4
Windows
3
E
Hours
Used
4
6
18
F
G
<=
<=
<=
Hours
Available
1
12
18
Total Profit
$2,700
The spreadsheet for the Wyndor problem with a trial solution (4 doors
and 3 windows) entered into the changing cells.
21
MS (Spring 2015)
Identifying the Target Cell and Changing Cells
• Choose the “Solver”
from the Tools menu.
• Select the cell you wish
to optimize in the “Set
Target Cell” window.
• Choose “Max” or
“Min” depending on
whether you want to
maximize or minimize
the target cell.
• Enter all the changing
cells in the “By
Changing Cells”
window.
3
4
5
6
7
8
9
10
11
12
B
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
1
Windows
1
E
Hours
Used
1
2
5
F
G
<=
<=
<=
Hours
Available
1
12
18
Total Profit
$800
22
MS (Spring 2015)
Adding Constraints
• To begin entering constraints, click the “Add”
button to the right of the constraints window.
• Fill in the entries in the resulting Add Constraint
dialogue box.
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
1
Windows
1
E
Hours
Used
1
2
5
F
G
<=
<=
<=
Hours
Available
1
12
18
Total Profit
$800
23
MS (Spring 2015)
The Complete Solver Dialogue Box
24
MS (Spring 2015)
Some Important Options
• Click on the “Options”
button, and click in both the
“Assume Linear Model” and
the “Assume Non-Negative”
box.
– “Assume Linear Model” tells
the Solver that this is a linear
programming model.
– “Assume Non-Negative” adds
nonnegativity constraints to all
the changing cells.
25
MS (Spring 2015)
The Solver Results Dialogue Box
26
MS (Spring 2015)
The Optimal Solution
B
3
4
5
6
7
8
9
10
11
12
Unit Profit
Plant 1
Plant 2
Plant 3
Units Produced
C
D
Doors
$300
Windows
$500
Hours Used Per Unit Produced
1
0
0
2
3
2
Doors
2
Windows
6
E
Hours
Used
2
12
18
F
G
<=
<=
<=
Hours
Available
1
12
18
Total Profit
$3,600
27
MS (Spring 2015)
The Profit & Gambit Co.
• Management has decided to undertake a major advertising
campaign that will focus on the following three key products:
– A spray prewash stain remover.
– A liquid laundry detergent.
– A powder laundry detergent.
• The campaign will use both television and print media
• The general goal is to increase sales of these products.
• Management has set the following goals for the campaign:
– Sales of the stain remover should increase by at least 3%.
– Sales of the liquid detergent should increase by at least 18%.
– Sales of the powder detergent should increase by at least 4%.
Question: how much should they advertise in each medium to
meet the sales goals at a minimum total cost?
28
MS (Spring 2015)
Algebraic Model for Profit & Gambit
Let TV = the number of units of advertising on television
PM = the number of units of advertising in the print media
Minimize Cost = TV + 2PM (in millions of dollars)
subject to
Stain remover increased sales:
PM ≥ 3
Liquid detergent increased sales: 3TV + 2PM ≥ 18
Powder detergent increased sales: –TV + 4PM ≥ 4
and
TV ≥ 0, PM ≥ 0.
29
MS (Spring 2015)
Applying the Graphical Method
Amount of print media advertising
PM
Feasible
10
region
8
6
4
PM = 3
2
-TV + 4 PM = 4
-4
-2
0
2
3 TV + 2 PM = 18
4
6
8
Amount of TV advertising
10
TV
30
MS (Spring 2015)
The Optimal Solution
PM
10
Feasible
region
Cost = 15 = TV + 2 PM
Cost = 10 = TV + 2 PM
4
(4,3)
optimal
solution
0
5
10
15 TV
Amount of TV advertising
31
MS (Spring 2015)
Summary of the Graphical Method
• Draw the constraint boundary line for each constraint. Use the
origin (or any point not on the line) to determine which side of
the line is permitted by the constraint.
• Find the feasible region by determining where all constraints
are satisfied simultaneously.
• Determine the slope of one objective function line. All other
objective function lines will have the same slope.
• Move a straight edge with this slope through the feasible region
in the direction of improving values of the objective function.
Stop at the last instant that the straight edge still passes through
a point in the feasible region. This line given by the straight
edge is the optimal objective function line.
• A feasible point on the optimal objective function line is an
optimal solution.
32
MS (Spring 2015)
Profit & Gambit Co. Spreadsheet
Model
B
3
4
5
6
7
8
9
10
11
12
13
14
Unit Cost ($millions)
Stain Remover
Liquid Detergent
Powder Detergent
Advertising Units
C
D
Television
1
Print Media
2
Increase in Sales per Unit of Advertising
0%
1%
3%
2%
-1%
4%
Television
4
Print Media
3
E
Increased
Sales
3%
18%
8%
F
G
>=
>=
>=
Minimum
Increase
3%
18%
4%
Total Cost
($millions)
10
33
MS (Spring 2015)
A Production Problem
Weekly supply of raw materials:
8 Small Bricks
6 Large Bricks
Products:
Table
Profit = $20 / Table
Chair
Profit = $15 / Chair
34
MS (Spring 2015)
Linear Programming
• Linear programming uses a mathematical
model to find the best allocation of scarce
resources to various activities so as to
maximize profit or minimize cost.
Let T = Number of tables to produce
C = Number of chairs to produce
Maximize Profit = ($20)T + ($15)C
subject to
2T + C ≤ 6 large bricks
2T + 2C ≤ 8 small bricks
and
T ≥ 0, C ≥ 0.
35
MS (Spring 2015)
Graphical Representation
Tables
5
4
2 Chairs + 2 Tables = 8 Small Bricks
3
2
Chairs + 2 Tables = 6 Large Bricks
1
1
2
3
4
5
6
Chairs
36
MS (Spring 2015)
Components of a Linear Program
•
•
•
•
Data Cells
Changing Cells (“Decision Variables”)
Target Cell (“Objective Function”)
Constraints
37
MS (Spring 2015)
Four Assumptions of Linear
Programming
•
•
•
•
Linearity
Divisibility
Certainty
Nonnegativity
38
MS (Spring 2015)
When is a Spreadsheet Model Linear?
• All equations (output cells) must be of the form
= ax + by + cz + …
where a, b, c are constants (data cells) and x, y, z are changing cells.
• Suppose C1:C6 are changing cells and D1:D6 are data cells.
Which of the following can be part of an LP?
–
–
–
–
–
–
–
–
–
SUMPRODUCT(D1:D6, C1:C6)
SUM(C1:C6)
C1 * SUM(C4:C6)
SUMPRODUCT(C1:C3, C4:C6)
IF(C1 > 3, 2*C3 + C4, 3*C3 + C5)
IF(D1 > 3, C1, C2)
MIN(C1, C2)
MIN(D1, D2) * C1
ROUND(C1)
39
MS (Spring 2015)
Why Use Linear Programming?
• Linear programs are easy (efficient) to solve
• The best (optimal) solution is guaranteed to be
found (if it exists)
• Useful sensitivity analysis information is
generated
• Many problems are essentially linear
40
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #1: Data Cells
– Enter all of the data for the problem on the
spreadsheet.
– Make consistent use of rows and columns.
– It is a good idea to color code these “data cells”
(e.g., light blue).
B
3
4
5
6
7
8
Profit
Large Bricks
Small Bricks
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
F
G
Available
6
8
41
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #2: Changing Cells
– Add a cell in the spreadsheet for every decision that needs to
be made.
– If you don’t have any particular initial values, just enter 0 in
each.
– It is a good idea to color code these “changing cells” (e.g.,
yellow with border).
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
Tables
0
Chairs
0
E
F
G
Available
6
8
42
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #3: Target Cell
– Develop an equation that defines the objective of the model.
– Typically this equation involves the data cells and the
changing cells in order to determine a quantity of interest
(e.g., total profit or total cost).
– It is a good idea to color code this cell (e.g., orange with
heavy border).
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
E
F
Bill of Materials
2
1
2
2
G
Available
6
8
Tables
Chairs
Total Profit
1
0
$20.00
10
G
Total Profit
11 =SUMPRODUCT(C4:D4,C11:D11)
43
MS (Spring 2015)
Developing a Spreadsheet Model
• Step #4: Constraints
– For any resource that is restricted, calculate the amount of that resource
used in a cell on the spreadsheet (an output cell).
– Define the constraint in three consecutive cells. For example, if Quantity
A ≤ Quantity B, put these three items (Quantity A, ≤, Quantity B) in
consecutive cells.
– Note the use of relative and absolute addressing to make it easy to copy
formulas in column E.
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
Total Used
3
4
F
G
<=
<=
Available
6
8
Tables
Chairs
Total Profit
1
1
$35.00
6
7
8
E
Total Used
=SUMPRODUCT(C7:D7,$C$11:$D$11)
=SUMPRODUCT(C8:D8,$C$11:$D$11)
44
MS (Spring 2015)
Defining the Target Cell
• Choose the
“Solver” from the
Tools menu.
• Select the cell you
wish to optimize
in the “Set Target
Cell” window.
• Choose “Max” or
“Min” depending
on whether you
want to maximize
or minimize the
target cell.
3
4
5
6
7
8
9
10
11
B
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
F
G
Total Used
3
4
<=
<=
Available
6
8
Tables
Chairs
Total Profit
1
1
$35.00
45
MS (Spring 2015)
Identifying the Changing Cells
• Enter all the
changing cells in
the “By Changing
Cells” window.
– You may either
drag the cursor
across the cells or
type the
addresses.
– If there are
multiple sets of
changing cells,
separate them by
typing a comma.
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
Total Used
3
4
F
G
<=
<=
Available
6
8
Tables
Chairs
Total Profit
1
1
$35.00
46
MS (Spring 2015)
Adding Constraints
• To begin entering constraints, click the “Add”
button to the right of the constraints window.
• Fill in the entries in the resulting Add
Constraint dialogue box.
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
Total Used
3
4
F
G
<=
<=
Available
6
8
Tables
Chairs
Total Profit
1
1
$35.00
47
MS (Spring 2015)
Some Important Options
• Click on the “Options”
button, and click in both the
“Assume Linear Model” and
the “Assume Non-Negative”
box.
– “Assume Linear Model” tells
the Solver that this is a linear
programming model.
– “Assume Non-Negative” adds
nonnegativity constraints to all
the changing cells.
48
MS (Spring 2015)
The Solution
• After clicking “Solve”, you will receive one of four messages:
– “Solver found a solution. All constraints and optimality
conditions are satisfied.”
– “Set cell values did not converge.”
– “Solver could not find a feasible solution.”
– “Conditions for Assume Linear Model are not satisfied.”
B
3
4
5
6
7
8
9
10
11
Profit
Large Bricks
Small Bricks
Production Quantity:
C
Tables
$20.00
D
Chairs
$15.00
Bill of Materials
2
1
2
2
E
Total Used
6
8
F
G
<=
<=
Available
6
8
Tables
Chairs
Total Profit
2
2
$70.00
49
MS (Spring 2015)
The Graphical Method for Solving
LP’s
•
•
•
•
Formulate the problem as a linear program
Plot the constraints
Identify the feasible region
Draw an imaginary line parallel to the objective
function (Z = a)
• Find the optimal solution
50
MS (Spring 2015)
Example #1
Maximize Z = 3x1 + 5x2
subject to
x1 ≤ 4
2x2 ≤ 12
3x1 + 2x2 ≤ 18
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
51
MS (Spring 2015)
Example #2
Minimize Z = 15x1 + 20x2
subject to
x1 +2x2 ≥ 10
2x1 – 3x2 ≤ 6
x1 + x2 ≥ 6
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
52
MS (Spring 2015)
Example #3
Maximize Z = x1 + x2
subject to
x1 +2x2 = 8
x1 – x 2 ≤ 0
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
53
MS (Spring 2015)
Properties of Linear Programming
Solutions
• An optimal solution must lie on the boundary of the
feasible region.
• There are exactly four possible outcomes of linear
programming:
–
–
–
–
A unique optimal solution is found.
An infinite number of optimal solutions exist.
No feasible solutions exist.
The objective function is unbounded (there is no optimal
solution).
• If an LP model has one optimal solution, it must be at a
corner point.
• If an LP model has many optimal solutions, at least two of
these optimal solutions are at corner points.
54
MS (Spring 2015)
Example #4 (Multiple Optimal
Solutions)
Minimize Z = 6x1 + 4x2
subject to
x1 ≤ 4
2x2 ≤ 12
3x1 + 2x2 ≤ 18
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
55
MS (Spring 2015)
Example #5 (No Feasible Solution)
Maximize Z = 3x1 + 5x2
subject to
x1 ≥ 5
x2 ≥ 4
3x1 + 2x2 ≤ 18
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
56
MS (Spring 2015)
Example #6 (Unbounded Solution)
Maximize Z = 5x1 + 12x2
subject to
x1 ≤ 5
2x1 –x2 ≤ 2
and
x1 ≥ 0, x2 ≥ 0.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
57
MS (Spring 2015)
The Simplex Method Algorithm
1. Start at a feasible corner point (often the origin).
2. Check if adjacent corner points improve the
objective function:
a) If so, move to adjacent corner and repeat step 2.
b)If not, current corner point is optimal. Stop.
x2
10
9
8
7
6
5
4
3
2
1
1
2
3
4
5
6
7
8
9
10
x1
58