Week 5 - Linear Programming
Week 5 - Linear Programming
2DA3
Decision Making with
Analytics
WEEK 5: LINEAR PROGRAMMING 1
INSTRUCTOR: ZAHRA MASHAYEKHI
1
Introduction to Prescriptive Analytics
2
ILOs
•At the end of this course, you will be able to
• define mathematical programming and linear programming concepts.
• solve simple 2 variable questions with ‘graphical method’.
• model LP questions on excel and solve by using an add-in called solver.
3
Chapter 12
Linear Optimization Models
4
Introduction
Optimization Problems:
◦ Can be used to support and improve managerial decision making.
◦ Optimization is the process of finding the optimal (min/max)
objective function by changing decision variables with respect to
restrictions known as constraints.
◦ Can be linear or nonlinear.
5
Introduction
Typical Applications:
o Production scheduling and inventory planning that satisfies demand in
future periods, while minimizing the total production, transportation and
inventory costs.
o Investment portfolio identification from a variety of stock and bond
investment alternatives that maximizes the return on investment.
o In marketing, the optimal advertising budget allocation among alternative
advertising media such as web, radio, television, newspaper, and magazine
to maximize advertising effectiveness.
6
Introduction
Real world examples:
** Terms “Linear optimization models” and “linear programs” can be used interchangeably.
7
First Example of LP
PROBLEM FORMULATION
FLAIR COMPANY
8
Flair Company Example
oFlair Furniture Company produces tables and chairs
oThey would like to decide how many chairs and tables to produce to maximize their profits
under some constraints.
9
1. Modeling Flair Company Problem
Problem formulation or modeling: Process of translating the verbal statement of a problem
into a mathematical statement.
Mathematical model: A set of mathematical relationships
Foundational step:
• Describe the objective, decision variables, and constraints
10
Flair Company Example
Flair Furniture Company produces tables and chairs:
Per Table Per Chair
Availability
Profit ($) 7 5
Carpentry Department
(labor hours) 3 4 2,400
Painting Department
(labor hours) 2 1 1,000
Manager/Market restrictions:
◦ Make no more than 450 chairs (the on-hand inventory of chairs is high)
◦ Make at least 100 tables (the inventory of table is low)
11
Flair Company LP Model
oDecision Variables:
◦ # of tables produced : T
◦ # of chairs produced : C
oObjective function:
◦ Maximize the profit
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶
13
Flair Company LP Model
oConstraints:
◦ Carpentry hour (the number of labor hours available at the department)
3𝑇 + 4𝐶 ≤ 2,400
◦ Maximum chair
𝐶 ≤ 450
◦ Minimum table
𝑇 ≥ 100
◦ Non-negativity
𝑇≥0
𝐶≥0
14
Why LP?
This is a linear programming model (or linear program) because the objective
function and all constraint functions are linear functions of the decision
variables.
Linear function: Mathematical function in which each variable appears in a
separate term and is raised to the first power.
15
Flair Company LP Model
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶 Objective Function
Subject to
3𝑇 + 4𝐶 ≤ 2,400
2𝑇 + 1𝐶 ≤ 1,000 RHS
(Right-hand side)
𝐶 ≤ 450
𝑇 ≥ 100
Non-negativity
𝑇≥0 Constraints
Decision Variables 𝐶≥0
16
Flair Company LP Model
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶 Maximize Profit
Subject to
3𝑇 + 4𝐶 ≤ 2,400 Carpentry
2𝑇 + 1𝐶 ≤ 1,000 Painting
Max C
𝐶 ≤ 450 production
Min T
𝑇 ≥ 100 Production
𝑇≥0 Non-negativity
Constraints
𝐶≥0
17
2. Solving Flair Company Problem
◦ Feasible solution: a setting of the decision variables that satisfies all of the
constraints of the problem.
◦ Optimal solution: is a feasible solution that has the highest objective function
value in Maximization problem and lowest objective function value in
Minimization problem.
18
2. Solving Flair Company Problem
• Graphical Solving
•Algorithm
• Simplex
• Interior-point
•…
•Computer Packages
• CPLEX
• GAMS
• Excel Solver
19
A. Graphical Solving
The Geometry of the Flair Company Problem:
When there are only two decision variables and the functions of these
variables are linear, they form lines in two-dimensional space.
20
A. Graphical Solving
1. Draw all constraints to identify Feasible Region.
The region which consists of all points, that
2. Identify extreme points simultaneously satisfy all constraints in the problem.
21
Step 1: Draw the Feasible Region
If constraints are inequalities, the constraint cuts the space in two:
◦ The line and the area on one side of the line is the space that satisfies that constraint.
◦ These subregions are called half spaces.
◦ The intersection of the half spaces make up the feasible region.
22
𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶
Subject to
3𝑇 + 4𝐶 ≤ 2,400
2𝑇 + 1𝐶 ≤ 1,000
𝐶 ≤ 450
𝑇 ≥ 100
C, 𝑇 ≥ 0
23
24
Step 1: Draw the Feasible Region
1. Convert inequality to a linear equation:
3𝑇 + 4𝐶 = 2,400
2. Find two points:
✓Normally, the two easiest points are the intersections between the linear equation and two
axes:
• If T = 0, then C = 600 ⇒ (0, 600)
• If C = 0, then T = 800 ⇒ (800, 0)
3. Draw a line through two points.
25
Step 1: Feasible Region – Flair Comp Ex.
1,000 –
– 3T + 4C ≤ 2,400
Number of Chairs (C)
26
Step 1: Feasible Region – Flair Comp Ex.
1,000 –
Use (0,0) as a specifying point:
–
Region Satisfying
Number of Chairs (C)
800 – 3𝑇 + 4𝐶 = 0 ≤ 2,400
3𝑇 + 4𝐶 ≤ 2,400
–
600 – (𝑇 = 300, 𝐶 = 200)
Therefore, (0,0) belongs to the
–
400 – feasible region.
–
200 –
–
0–
| | | | | | | | | | | |
0 200 400 600 800 1,000
27
Step 1: Feasible Region – Flair Comp Ex.
1,000 –
–
Number of Chairs (C)
800 –
– Painting Constraint
600 – 2𝑇 + 1𝐶 ≤ 1,000
–
Carpentry Constraint
400 – 3𝑇 + 4𝐶 ≤ 2,400
–
200 –
–
0–
| | | | | | | | | | | |
0 200 400 600 800 1,000
28
Step 1: Feasible Region – Flair Comp Ex. Painting Constraint 2𝑇 + 1𝐶 ≤ 1,000
1,000 –
–
Number of Chairs (C)
800 –
Minimum Tables Required Constraint 𝑇 ≥ 100
–
600 – Maximum Chairs Allowed Constraint 𝐶 ≤ 450
–
400 –
– Carpentry Constraint 3𝑇 + 4𝐶 ≤ 2,400
200 –
Feasible Infeasible Solution
–
Region
0–
| | | | | | | | | | | |
0 200 400 600 800 1,000
29
Step 2: Identify extreme points
•Extreme points are found where constraints intersect on the boundary of the feasible region.
•To solve a linear optimization problem, we only have to search the extreme points of the
feasible region to find the optimal solution.
30
Step 2: Identify extreme points
800 –
Number of Chairs (C)
– Maximum Chairs Allowed Constraint 𝐶 ≤ 450
400 –
4 Minimum Tables Required Constraint 𝑇 ≥ 100
–
200 –
Painting Constraint
–
3𝑇 + 4𝐶 ≤ 2,400
0– | | | | | | | | | |
0 1 200 400 5 600 800 1,000
Number of Tables (T)
31
Step 3: Objective function contour lines
800 –
–
Number of Chairs (C)
– 2 3
400 –
4 𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶 → 7𝑇 + 5𝐶 = 𝑍
–
200 –
Painting Constraint
–
0– | | | | | | | | | |
0 1 200 400 5 600 800 1,000
Number of Tables (T)
32
Step 4: Identify the direction for improving objective value
800 –
Optimal Level Profit Line
–
Number of Chairs (C)
– 2 3
Optimal Corner Point Solution
400 –
4 𝑀𝑎𝑥𝑖𝑚𝑖𝑧𝑒 7𝑇 + 5𝐶 → 7𝑇 + 5𝐶 = 𝑍
–
200 –
Painting Constraint
–
0– | | | | | | | | | |
0 1 200 400 5 600 800 1,000
Number of Tables (T)
33
Step 5: Find the optimal values
Optimal solution:
◦ Intersection of carpentry constraint and painting constraint:
3𝑇 + 4𝐶 = 2,400
൝ ⇒ 𝑇 = 320, 𝐶 = 360
2𝑇 + 1𝐶 = 1,000
34
Flair Graphical LP Solution
Point 1 (T = 100, C = 0)
Profit = $7 x 100 + $5 x 0 = $700
Point 2 (T = 100, C = 450)
Profit = $7 x 100 + $5 x 450 = $2,950
Point 3 (T = 200, C = 450)
Profit = $7 x 200 + $5 x 450 = $3,650
Point 4 (T = 320, C = 360)
Profit = $7 x 320 + $5 x 360 = $4,040
Point 5 (T = 500, C = 0)
Profit = $7 x 500 + $5 x 0 = $3,500
35
Input data values,
coefficients used in the
2. Proportionality
◦ If the level of any activity is multiplied by a constant factor, then the contribution of that activity in the objective function or
constraints will be multiplied by the same factor.
e.g.
3. Additivity Production of 1 unit of an item uses 3 hours
◦ Total of all activities equals the sum of individual activities. of a particular resource,
→ making 10 units of that item uses 30 hours
4. Divisibility e.g. of the resource.
◦ Non-integer variables are acceptable. One product worth $8 per
unit is produced, and
and of course “ Linearity “ !
the other product worth $3
per unit is also produced,
→ the total profit will be 8
plus 3.
36
B. Solving Flair Company Problem in Excel
37
A Simple Maximization Problem
PROBLEM FORMULATION
MATHEMATICAL MODEL FOR THE PAR, INC. PROBLEM
38
Simple Maximization Problem
Illustration: Par, Inc.:
◦ Par, Inc. is a small manufacturer of golf equipment and supplies.
◦ Management has decided to move into the market for medium- and
high-priced golf bags.
◦ Par’s distributor has agreed to buy all of the golf bags produced over
the next three months.
39
Simple Maximization Problem
Production Requirements Per Golf Bag
40
Simple Maximization Problem
Estimated total time available for the next three months to perform different operations:
Profit contribution:
◦ Standard bag: $10/unit.
◦ Deluxe bag: $9/unit.
Simple Maximization Problem
Objective:
Develop a mathematical model of the Par, Inc. problem to determine
the number of standard bags and the number of deluxe bags to
produce to maximize total profit contribution.
Foundational step:
42
Simple Maximization Problem
Decision Variables:
• S = Number of standard bags to be manufactured
• D = Number of Deluxe bags to be manufactured
Objective Function:
• MAX (Total Profit Contribution) = MAX (10S + 9D)
44
Simple Maximization Problem
Constraints:
Hours of sewing Hours of sewing 1 5
Constraint 1: -> S + D 600
time used time available 2 6
◦ Nonnegativity constraints: Based on the fact that the number of standard or deluxe bags produced cannot be negative.
S 0 and D 0 or S , D 0
45
Simple Maximization Problem
Constraints:
Hours of sewing Hours of sewing 1 5
Constraint 1: -> S + D 600
time used time available 2 6
◦ Nonnegativity constraints: Based on the fact that the number of standard or deluxe bags produced cannot be negative.
S 0 and D 0 or S , D 0
46
Simple Maximization Problem
Final Mathematical Model for the Par, Inc. Problem:
◦ Mathematical model: Max 10 S + 9D.
7
S + 1D 630 Cutting and dyeing
10
1 5
S + D 600 Sewing
2 6
2
1S + D 708 Finishing
3
1 1
S + D 135 Inspection and packaging
10 4
S, D 0
Simple Maximization Problem
Mathematical Model for the Par, Inc. Problem (cont.):
This is a linear programming model (or linear program)
48
Solving the Par, Inc. Problem
THE GEOMETRY OF THE PAR, INC. PROBLEM
SOLVING LINEAR PROGRAMS WITH EXCEL SOLVER
49
Solving the Par, Inc. Problem
Figure 1: Feasible Region for the Par, Inc.
Problem
50
Solving the Par, Inc. Problem
Figure 2: The Optimal Solution to the Par, Inc.
Problem
• Extreme points
• Recall: Extreme points are found where constraints
intersect on the boundary of the feasible region.
51
Solving the Par, Inc. Problem
The Geometry of the Par, Inc. Problem (cont.):
7,668
Solving the Par, Inc. Problem
53
Par, Inc. Excel Screenshots
54
Par, Inc. Excel Screenshots
55
Analyzing the Answer report
A binding constraint is one that holds as an
equality at the optimal solution.
The slack value for each less-than-or-equal-to
constraint indicates the difference between
the left-hand and right-hand values for a
constraint.
56
A Simple Minimization Problem
57
A Simple Minimization Problem
M&D Chemicals produces two products that are sold as raw materials to companies
manufacturing bath soaps and laundry detergents.
Based on the analysis of the current inventory levels and potential demand for the coming
month, M&D’s management specified certain production requirements.
58
A Simple Minimization Problem
Illustration: M&D Chemicals:
Production requirements for M&D Chemicals:
◦ The combined production for products A and B must total at least 350 gallons.
◦ Separately, a major customer’s order for 125 gallons of product A must also be satisfied.
Processing time:
◦ Product A: 2 hours/gallon.
◦ Product B: 1 hour/gallon.
◦ For the coming month, 600 hours of processing time are available.
59
A Simple Minimization Problem
Decision Variables:
• A = Number of Gallons of product A to produce
• B = Number of Gallons of product B to produce
Objective Function:
• MIN (Total costs) = MIN (2A + 3B)
Constraints:
• 1A >= 125 Demand for Product A
• 1A +1B >= 350 Total Production requirement
• 2A + 1B <= 600 Processing Time
• A,B >= 0
60
A Simple Minimization Problem
61
Special Cases of Linear Program
Outcomes
1. ALTERNATIVE OPTIMAL SOLUTIONS
2. I NFEASIBILITY
3. UNBOUNDED
62
Special Cases of Linear Program Outcomes
Alternative Optimal Solutions:
63
Special Cases of Linear Program Outcomes
Illustration: Par, Inc.:
Original objective function:
10 S + 9D.
Assume the profit for the standard golf bag decreased to $6.30.
Revised objective function: 6.3S + 9D.
The optimal solution occurs at two extreme points:
◦ Extreme point 4 (S = 300, D = 420).
◦ Extreme point 3 (S = 540, D = 252).
Special Cases of Linear Program Outcomes
Figure: Par, Inc. Problem with an
Objective Function of
6.3S + 9D (Alternative
Optimal Solutions)
Special Cases of Linear Program Outcomes
Infeasibility:
66
Special Cases of Linear Program Outcomes
Figure: No Feasible Region for the Par, Inc.
Problem with Minimum Production Requirements
of 500 Standard and 360 Deluxe Bags
67
Special Cases of Linear Program Outcomes
Infeasibility (cont.):
68
Special Cases of Linear Program Outcomes
Table: Resources Needed to Manufacture 500 Standard Bags and 360 Deluxe Bags
69
Special Cases of Linear Program Outcomes
Infeasibility (cont.):
70
Special Cases of Linear Program Outcomes
Unbounded:
71
Special Cases of Linear Program Outcomes
Illustration:
Consider the following linear program with two decision variables, X and Y:
Max 20 X + 10Y
s.t.
1X 2
1Y 5
X, Y 0
Special Cases of Linear Program Outcomes
Figure: Example of an Unbounded Problem
73
Special Cases of Linear Program Outcomes
Unbounded (cont.):
Solving an unbounded problem using Excel Solver returns a message
“Objective Cell values do not converge.”
In linear programming models of real problems, the occurrence of an
unbounded solution means that the problem has been improperly
formulated.
If a profit maximization problem results in an unbounded solution, the
mathematical model does not represent the real-world problem sufficiently.
In many cases, this error is the result of inadvertently omitting a constraint
during problem formulation. (Missing Constraints)
74
End of Lecture