0% found this document useful (0 votes)
31 views

DSME 4020B Decision Modeling and Analytics Spring 2022: Sean ZHOU CUHK Business School Chinese University of Hong Kong

This lecture discusses solving linear programming problems in Excel using the Solver tool. It begins by introducing the Lego game problem and inputting the relevant data from the problem into an Excel spreadsheet. This includes inputting the decision variables, constraints as algebraic expressions involving the decision variables, and the objective function. It then explains how to use the SUMPRODUCT function to write the left-hand sides of the constraints and objective function in a way that links to the decision variable cells. Finally, it indicates that the next steps are to set the objective cell as the objective function and choose the decision variable cells.

Uploaded by

XINYANG HE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

DSME 4020B Decision Modeling and Analytics Spring 2022: Sean ZHOU CUHK Business School Chinese University of Hong Kong

This lecture discusses solving linear programming problems in Excel using the Solver tool. It begins by introducing the Lego game problem and inputting the relevant data from the problem into an Excel spreadsheet. This includes inputting the decision variables, constraints as algebraic expressions involving the decision variables, and the objective function. It then explains how to use the SUMPRODUCT function to write the left-hand sides of the constraints and objective function in a way that links to the decision variable cells. Finally, it indicates that the next steps are to set the objective cell as the objective function and choose the decision variable cells.

Uploaded by

XINYANG HE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

DSME 4020B

Decision Modeling and Analytics


Spring 2022
Lecture 5

Sean ZHOU
CUHK Business School
Chinese University of Hong Kong

1
Lecture outline
• The Geometry of Linear Programming

• Solving Linear Programming in Excel (Solver)

2
The Geometry of Linear Programming

3
Geometry of Linear Programming
• How to visualize a linear program geometrically?
– Decision variables?
– Constraints?
– Objective?
• How to find the optimal solution geometrically (for simple
problems)?

• An example:

4
Geometry of LP – Decision Variables
• Each dimension represents a decision variable
n decision variables ⇒ an n-dimensional space
• Each point in the space represents a particular solution
x2

1 (1, 1)

0 1 x1 5
Geometry of LP – Constraints
• Constraint: x1 ≥ 0
• Inequality constraint x1 ≥ 0 defines a half space

X2 X1 ≥ 0

x1 = 0

0 X1
6
Geometry of LP – Constraints
• Constraint: x2 ≥ 0
• Inequality constraint x2 ≥ 0 defines a half space

X2 X2 ≥ 0

0 x2 = 0 X1
7
Geometry of LP – Constraints
• Constraint: 2x1 + x2 ≤ 3
• Inequality constraint 2x1 + x2 ≤ 3 defines a half space

X2
2x1+x2 = 3
(0, 3)

0 (1.5, 0) X1
2x1 + x2 ≤ 3
8
Geometry of LP – Constraints
• Constraint: x1 + 2x2 ≤ 3
• Inequality constraint x1 + 2x2 ≤ 3 defines a half space

X2

x1+2x2 = 3

(0, 1.5)

0 (3, 0) X1
x1 + 2x2 ≤ 3 9
Geometry of LP – Constraints
• The intersection of all the constraints ⇒ Feasible Region

X2

0 X1
10
Geometry of LP – Constraints
• Feasible Region: The set of all the allowed solutions; a region
(polygon) bounded by the constraints
– Each equality constraint defines a line
– Each inequality constraint defines a half-space
• Extreme Points: Corner points on the boundary of the feasible
region. E.g., (0, 0), (1.5, 0), (0, 1.5), and (1, 1)
• Infeasible problem: A problem with an empty feasible region
• Redundant constraint: Adding or removing the constraint does
not affect the feasible region, e.g., X2
𝑥1 + 𝑥2 ≤ 5

11
0 X1
Geometry of LP – Objective
• Objective: maximize x1 + x2
• Isoquant: A line on which all points have the same objective
value; all points are equally good on the objective function.
X2

x1 + x 2 = 0

0 X1
12
Geometry of LP – Objective
• Isoquant: x1 + x2 = 1

X2

x1 + x 2 = 1

(0, 1)

0 (1, 0) X1
Geometry of LP – Objective
• Isoquant: x1 + x2 = 1.5

X2

x1 + x2 = 1.5

0 X1
Geometry of LP – Objective
• Isoquant: x1 + x2 = 3
x1 + x 2 = 3
X2
No feasible
solution can
attain this value

0 X1
15
Geometry of LP – Optimal Solution
• Optimal Solution: The best feasible solution
• Theorem: For any feasible LP with a finite optimal solution
and at lest one extreme point, there exists an optimal
solution that is an extreme point
Max x1 + x2 X2
Optimal Solution:
(1, 1)

0 X1
x1 + x 2 = 2 16
Geometry of LP – Optimal Solution
• Optimal solutions may NOT be unique

X2
Max 2x1 + x2

0 X1
17
Geometry of LP – Optimal Solution
• Optimal solution may NOT be finite

-X1 + 2X2 ≤ 2
X2
Max x1 + x2

X1 - 2X2 ≤ 2

(0, 1)

0 (2, 0) X1
18
Geometry of LP – Optimal Solution
• Binding (or active) constraints: The constraints that are
satisfied as equality at the optimal solution
– All equality constraints are binding by definition

• Non-binding (or inactive) constraints are satisfied as


strict inequality at the optimal solution

• The inequality level (= RHS – LHS (for ``≤ ′′constraint)) is


known as the slack
– Binding constraints have zero slack by definition

19
Geometry of LP – Optimal Solution
• Active constraints are the ones that pass through the optimal solution.
• Inactive constraints are the ones that do not pass through the optimal
solution.
• Why are binding/active constraints important?

Constraints Binding? Slack


Optimal X1 + 2X2 ≤ 3 Yes 0
(1, 1) 2X1 + X2 ≤ 3 Yes 0
X1 ≥ 0 No 1
X2 ≥ 0 No 1

20
Geometry of LP – Summary
• Decision variables
– Each decision variable forms a dimension
– n decision variables define an n-dimensional space
– A solution is a point in the space
• Constraints
– Each equality constraint defines a hyper-plane (line in a 2-D space)
– Each inequality constraint defines a half-space
– All constraints collectively define the feasible region
• Objective
– The objective function defines isoquants and a direction in the space
• To find the optimal solution, push along the direction defined by the
objective until we reach the boundary of the feasible region
• At the optimal solution, some constraints are binding (or active) while
others are not

21
Recap of Lecture 5
• Visualize the three components of a Linear Program
– Decision variables  Dimensions of space
– Constraints  Hyperplanes or half-spaces
– Objective  Isoquant and the direction
• Feasible region and extreme (or corner) points
• Binding and non-binding constraints (at optimal solution)
• Slack of a constraint

22
Geometry of LP – Benefits
• An infinite number of feasible solutions

• A finite number of extreme points


– Number of decision variables n, and number of
constraints (excluding sign constraints) m
– How many? ≤ 𝑛+𝑚 𝑛
• An extreme point is the optimal solution
for a finite LP
• The Simplex algorithm (there are other methods)
developed by Dantzig

23
Geometry of LP – 3-Dimension

24
Solving Linear Programming
in Excel (Solver)

25
• Add Solver in Excel: File  Option  Add-Ins  Manage  Go

26
The Lego Game Revisited
• Products: Chair ($40) and Table ($50)
Chair Table Inventory
(C) (T)
Big
Brick 1 2 10
Small
Brick 4 3 30

MAX 40C + 50T


s.t. 1C + 2T ≤ 10 (Big Bricks)
4C + 3T ≤ 30 (Small Bricks)
C, T ≥ 0
27
First step : input data MAX 40C + 50T
s.t. 1C + 2T ≤ 10 (Big Bricks)
from the problem to the
4C + 3T ≤ 30 (Small Bricks)
spreadsheet. C, T ≥ 0

28
• Initial input about decision variables: B5=0, C5=0

• LHS of the constraint:


– D8=B5*B8+C5*C8;
– D9=B5*B9+C5*C9;

• Objective function:
– D12=B5*B12+C5*C12;

• All the other inputs are numbers

29
SUMPRODUCT
• SUMPRODUCT (array1, array2, array3,…): return the sum of the products
of corresponding range or arrays.
• All arrays must have same dimensions.
• Example: E2=SUMPRODUCT(A2:A5,B2:B5,C2:C5)
=A2*B2*C2 + A3*B3*C3 + A4*B4*C4 + A5*B5*C5

• In The Lego Game, we can rewrite D8, D9, D12 as


– D8= SUMPRODUCT(B5:C5,B8:C8), D9= SUMPRODUCT(B5:C5,B9:C9),
D12= SUMPRODUCT(B5:C5,B12:C12) 30
Set
objective

Choose
decision
variable

Add
constrain

Check if all
variables
are non-
negative

31
32
Example: Blending Model
Investment Problem of Pension Planners
The portfolio manager of Pension Planners has been asked to invest
$1 million of a large pension fund in six mutual funds with varying
potential returns and risks, as summarized in the Table below.

Fund
1 2 3 4 5 6
Price ($/share) 45 76 110 17 23 22
Exp Return (%) 30 20 15 12 10 7
Risk Category High High High Med Med Low

33
LP Model
Max 0.30F1 + 0.20F2 + 0.15F3 + 0.12F4 + 0.10F5 + 0.07F6
st
F1 + F2 + F3 ≥ 0.50
F1 + F2 + F3 ≤ 0.75
F4 + F5 ≥ 0.20
F4 + F5 ≤ 0.30
F6 ≥ 0.05
2F1 − F2 = 0 Optional :
3F1 − F3 = 0 remove one of
3F2 − 2F3 = 0
these constraints
2F4 − F5 = 0
F1 + F2 + F3 + F4 + F5 + F6 = 1

Fi ≥ 0 i = 1, 2, . . . , 6
34
35
Answer Report
Cell Name Original Value Final Value
$H$17 Objective LHS 0 0.168583333

Cell Name Original Value Final Value Integer


$B$5 F1 0 0.125Contin
$C$5 F2 0 0.25Contin
$D$5 F3 0 0.375Contin
$E$5 F4 0 0.066666667Contin
$F$5 F5 0 0.133333333Contin
$G$5 F6 0 0.05Contin

Cell Name Cell Value Formula Status Slack


$H$10 LHS 0.2$H$10<=$J$10 Not Binding 0.1
$H$11 LHS 0.05$H$11>=$J$11 Binding 0
$H$12 LHS 0$H$12=$J$12 Binding 0
$H$13 LHS 0$H$13=$J$13 Binding 0
$H$14 LHS 0$H$14=$J$14 Binding 0
$H$15 LHS 1$H$15=$J$15 Binding 0
$H$7 LHS 0.75$H$7>=$J$7 Not Binding 0.25
$H$8 LHS 0.75$H$8<=$J$8 Binding 0
$H$9 LHS 0.2$H$9>=$J$9 Binding 0

36
Example: Nurse Scheduling
• University hospital requires different number of nurses
at different times
• Each nurse works for 8 consecutive hours per day
Period Time Min Number of Nurses Needed
1 12am – 4am 10
2 4am – 8am 25
3 8am – 12pm 35
4 12pm – 4pm 30
5 4pm – 8pm 40
6 8pm – 12am 20

• Find the minimum number of nurses used per day

37
Example: Nurse Scheduling

8pm – 4am
12am – 8am
4am – 12pm
8am – 4pm
12pm – 8pm
4pm – 12am
8pm – 4am
12am – 4am 4am – 8am 8am – 12pm 12pm – 4pm 4pm – 8pm 8pm – 12am

10 25 35 30 40 20
Monday Tuesday Wednesday

38
Example: Nurse Scheduling
• Decision variables?
– 𝑥𝑖 : number of nurses who start work in period 𝑖 , 𝑖 =
1,2, … , 6
• Objective?
– Minimize total number of nurses
• Constraints?
– Total staff requirement for each period

39
Example: Nurse Scheduling
𝑥6 + 𝑥1 𝑥1 + 𝑥2 𝑥2 + 𝑥3 𝑥3 + 𝑥4 𝑥4 + 𝑥5 𝑥5 + 𝑥6

8pm – 4am
𝑥6
12am – 8am
𝑥1
4am – 12pm
𝑥2
8am – 4pm
𝑥3
12pm – 8pm
𝑥4
4pm – 12am
𝑥5
8pm – 4am
12am – 4am 4am – 8am 8am – 12pm 12pm – 4pm
𝑥6
4pm – 8pm 8pm – 12am

10 25 35 30 40 20
Monday Tuesday Wednesday

40
Example: Nurse Scheduling

min x1  x2  x3  x4  x5  x6
subject to
x1  x6  10
x1  x2  25
x2  x3  35
x3  x4  30
x4  x5  40
x5  x6  20
xi  0, for all i  1,2,...,6
41
42
Nurse Scheduling: Optimal Solution
10 25 35 40 40 20

8pm – 4am
0
12am – 8am
10
4am – 12pm
15 Total no. = 85
8am – 4pm
20
12pm – 8pm
20
4pm – 12am
20
8pm – 4am
12am – 4am
0
4am – 8am 8am – 12pm 12pm – 4pm 4pm – 8pm 8pm – 12am

10 25 35 30 40 20
Monday Tuesday Wednesday

43
44
Nurse Scheduling: Alternative Solution

10 35 35 30 40 20

8pm – 4am
0
12am – 8am
10
4am – 12pm
25 Total no. = 85
8am – 4pm
10
12pm – 8pm
20
4pm – 12am
20
8pm – 4am
12am – 4am
0
4am – 8am 8am – 12pm 12pm – 4pm 4pm – 8pm 8pm – 12am

10 25 35 30 40 20
Monday Tuesday Wednesday

45

You might also like