Chapter 4 - Solving Linear Programs Part 1
Chapter 4 - Solving Linear Programs Part 1
1
Graphical Method (Two Variables)
𝑥2
2
Graphical Method (Three Variables)
Feasible Solution:
One point in the 𝑥1
feasible region
𝑥3
Optimal Solution
3
Linear Programs: with More Decision Variables
4
Simplex Method
1914.11⎯2005.05
5
Underlying Concepts of Simplex Method
E C
A B 𝑥1 6
Solving Linear Program:
Simplex Method
7
Simplex Method: Basic Solutions
8
Simplex Method: Representation of a Basic Solution
𝑍 = 𝑐1 𝑥1 + ⋯ + 𝑐𝑚 𝑥𝑚 + ⋯ + 𝑐𝑛 𝑥𝑛
Objective
function
𝑍 = 𝐿 + 𝑑𝑚+1 𝑥𝑚+1 + ⋯ + 𝑑𝑛 𝑥𝑛
9
Example of Representation of a Basic Solution
B0={x1,x2,s1}, NB0={s2,s3}
1 1
𝐵 = {𝑥1 , 𝑥2 , … , 𝑥𝑚 }
0 x1 = 2 + s2 – s3
3 3
1 (Refer to next
𝑥1 = 𝑙1 + 𝑘1,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘1𝑛 𝑥𝑛 x2 = 6 – s2
2 slide)
𝑥2 = 𝑙2 + 𝑘2,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘2𝑛 𝑥𝑛 1 1
s1 = 2 – s2 + s3
3 3
⋮
𝑥𝑚 = 𝑙𝑚 + 𝑘𝑚,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘𝑚𝑛 𝑥𝑛
Z = 3𝑥1+ 5𝑥2 + 0𝑠1 + 0𝑠2 + 0𝑠3
𝑍 =𝐿 + 𝑑𝑚+1 𝑥𝑚+1 + ⋯ + 𝑑𝑛 𝑥𝑛 1 1
= 3 2 + s2 – s3 + 5 6 – s2
1
3 3 2
3
= 36 − s –s3
2 2 10
11
Example of Representation of a Basic Solution
B0={s1,a1,a2}
s1 = 11 – x1 + 2x2 – x3
𝐵0 = {𝑥1 , 𝑥2 , … , 𝑥𝑚 }
a1 = 3 – 2x1 – x2 + 4x3 + s2
𝑥1 = 𝑙1 + 𝑘1,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘1𝑛 𝑥𝑛 a2 = 1 – x1 + 2x3
𝑥2 = 𝑙2 + 𝑘2,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘2𝑛 𝑥𝑛
⋮ Z’ = – x1 – x2 + 3x3 + 0s1 + 0s2 – Ma1 – Ma2
𝑥𝑚 = 𝑙𝑚 + 𝑘𝑚,𝑚+1 𝑥𝑚+1 + ⋯ + 𝑘𝑚𝑛 𝑥𝑛 = – x1 – x2 + 3x3 – M(3 – 2x1 – x2+ 4x3 +s2)
– M(1 – x1+ 2x3)
𝑍 =𝐿 + 𝑑𝑚+1 𝑥𝑚+1 + ⋯ + 𝑑𝑛 𝑥𝑛
= –4M + (3M–1)x1 + (M–1)x2 – (6M–3)x3
– Ms2 12
Simplex Method: Algebra Meaning
B1={s1,a1,a2}
E C s1 = 11 – x1 + 2x2 – x3
An Example
a1 = 3 – 2x1 – x2 + 4x3 + s2
a2 = 1 – x1 + 2x3
B2={s1,s2,a2}
A B 𝑥1 s1 = 11 – x1 + 2x2 – x3
s2 = 3 – 2x1 – x2 + 4x3 + a1
a2 = 1 – x1 + 2x3
13
An Example of Simplex Method: Algebra
Meaning
x1 + 2 x2 6 x1 + 2 x2 + s1 = 6
𝑥2 2 x1 + x2 6 2 x1 + x2 + s2 = 6
10
9
B1 = {s1,s2} 1
8
s1 = 6 – x1 – 2x2 𝑥1 , 𝑥2 , 𝑠1 , 𝑠2 = 0,0,6,6
7 s2 = 6 – 2x1 – x2
6
5 B2 = {s1,x1} 2
2 x1 + x2 6 3
s1 = 3 – x2 + 𝑠2
1
𝑥1 , 𝑥2 , 𝑠1 , 𝑠2 = 3,0,3,0
4 2 2
3 ( 0,3) x1 = 3
1
– x2 –
1
𝑠
2 2 2
2 ( 2, 2 )
x1 + 2 x2 6
1
( 3, 0 )
0 1 2 𝑥1
0 1 2 3 4 5 6 7 8 9 10 11 12 13
14
A Quick Example for General Understanding
of the Processes of Simplex Method
15
A Quick Example for General Understanding
the Processes of Simplex Method
Basic and feasible solution Pivot in x1 ; remove s3 from the basis
z = 3 x1 + x2 + 2 x3 1 1 3
z = 27 + x2 + x3 − s3
s1 = 30 − x1 − x2 − 3 x3 4 2 4
1 1 1
s2 = 24 − 2x1 − 2x2 − 5x3 x1 = 9 − x2 − x3 − s3
4 2 4
s3 = 36 − 4x1 − x2 − 2x3
3 5 1
s1 = 21 − x2 − x3 + s3
4 2 4
3 1
s2 = 6 − x2 − 4 x3 + s3
2 2
Stage 1: Stage 2:
Find one basic Find the optimal solution based on the
feasible solution identified basic feasible solution
No Select variable
Optimal?
Feasible? entering the basis
Stage 1
Stage 2
18
Simplex Method: Processes of Simplex Method
Stage 1
Stage 2
19
Stage 1: Feasibility of a Basic Solution (Q1)
20
Stage 1: Progresses of Formulating the
Initial Tabular Form (Step 1)
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
Make it a
maximization
problem
21
Stage 1: Progresses of Formulating the
Initial Tabular Form (Step 2)
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
22
Stage 1: Progresses of Formulating the
Initial Tabular Form (Step 3)
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
All the
constraints For each “Less than or equal to”
have basic (≤)constraint, Add a slack variable to each
variables constraint
For each “equal to” (=) constraint, add an
Three cases: artificial variable.
≤
For each “greater than or equal to” (≥)
=
constraint, subtract a surplus variable and
≥
add an artificial variable.
23
Stage 1: Progresses of Formulating the
Initial Tabular Form (Step 4)
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
24
Stage 1: Progresses of Formulating the
Initial Tabular Form (Step 5)
Coefficients
Objective Right-hand (variables in Initial
Constraints
function side (RHS) objective basis
function)
25
Example 1 (Stage 1)
26
Example 1 (Stage 1)
Initial Tabular Form Formulation
1 2 3 4 5
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
1 4
Max 𝒁=𝟓𝒙𝟏 + 𝟖𝒙𝟐 Max 𝒁=𝟓𝒙𝟏 + 𝟖𝒙𝟐 + 𝟎𝒔𝟏 + 𝟎𝒔𝟐 + 𝟎𝒔𝟑
s.t. s.t.
3 𝒙𝟏 + 𝟐𝒙𝟐 ≤ 𝟏𝟐 2
𝒙𝟏 + 𝟐𝒙𝟐 + 𝒔𝟏 = 𝟏𝟐
𝟒𝒙𝟏 + 𝟓𝒙𝟐 ≤ 𝟒𝟎 𝟒𝒙𝟏 + 𝟓𝒙𝟐 + 𝒔𝟐 = 𝟒𝟎
𝒙𝟏 ≤ 𝟓 𝒙𝟏 + 𝒔𝟑 = 𝟓
𝒙𝟏 , 𝒙𝟐 ≥ 𝟎
𝒙𝟏 , 𝒙𝟐 , 𝒔𝟏 , 𝒔𝟐 , 𝒔𝟑 ≥ 𝟎
27
Example 1 (Stage 1)
Initial Tabular Form Formulation
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 }
𝑥1 + 2𝑥2 + 𝒔𝟏 = 12
4𝑥1 + 5𝑥2 + 𝒔𝟐 = 40
𝑥1 + 𝒔𝟑 = 5
𝑍 = 0 + 5𝑥1 + 8𝑥2
28
Example 1(Stage 1)
Feasibility of a Basic Solution (Q1)
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 }
If 𝑥1 and 𝑥2 are 0, then
This basic solution
𝒔𝟏 = 12 − 𝑥1 − 2𝑥2 = 12 > 0 is feasible
𝒔𝟐 = 40 − 4𝑥1 − 5𝑥2 = 40 > 0
𝒔𝟑 = 5 − 𝑥1 = 5>0
𝑍= 0 + 5𝑥1 + 8𝑥2
( 0,0,12, 40,5 ) ; Z = 0
29
Example 2 (Stage 1)
Min Z = 𝑥1 + 𝑥2 − 3𝑥3
s.t.
− 𝑥1 + 2𝑥2 − 𝑥3 ≥ -11
2𝑥1 + 𝑥2 − 4𝑥3 ≥ 3
𝑥1 − 2𝑥3 = 1
𝑥1 , 𝑥2 , 𝑥3 ≥ 0
30
Example 2 (Stage 1)
Initial Tabular Form Formulation
1 2 3 4 5
Coefficients
Objective Right-hand (variables in
Constraints Basis
function side (RHS) objective
function)
1 4
Min Z = 𝑥1 + 𝑥2 − 3𝑥3 Max Z’ = −𝑥1 − 𝑥2 + 3𝑥3 + 0𝑠1 + 0𝑠2 − 𝑀a1 − 𝑀a2
s.t. s.t.
2
3 − 𝑥1 + 2𝑥2 − 𝑥3 ≥ -11 𝑥1 − 2𝑥2 + 𝑥3 + 𝑠1 = 11
2𝑥1 + 𝑥2 − 4𝑥3 ≥ 3 2𝑥1 + 𝑥2 − 4𝑥3 − s2 + a1 = 3
𝑥1 − 2𝑥3 = 1 𝑥1 − 2𝑥3 + a2 = 1
𝑥1 , 𝑥2 , 𝑥3 ≥ 0 𝑥1 , 𝑥2 , 𝑥3 , s1 , s2 , a1 , a2 ≥ 0
31
Example 2 (Stage 1)
Initial Tabular Form Formulation
B0={s1,a1,a2}
This basic solution
s1 = 11 – x1 + 2x2 – x3 = 11 ≥ 0; is feasible
a1 = 3 – 2x1 – x2 + 4x3 + s2 = 3 ≥ 0;
a2 = 1 – x1 + 2x3 = 1 ≥ 0;
Z’ = 0 – x1 – x2 + 3x3 – Ma1 – Ma2
= –4M + (3M–1)x1 + (M–1)x2 – (6M–3)x3 – Ms2
0,0,0,11,0,3,1 ; 𝑍′ = −4𝑀
33
Question: Why Artificial Variable ?
𝒙𝟏 + 𝟐𝒙𝟐 ≤ 𝟏𝟐 𝒙𝟏 + 𝟐𝒙𝟐 + 𝒔𝟏 = 𝟏𝟐
𝟒𝒙𝟏 + 𝟓𝒙𝟐 ≤ 𝟒𝟎 𝟒𝒙𝟏 + 𝟓𝒙𝟐 + 𝒔𝟐 = 𝟒𝟎
𝒙𝟏 ≤ 𝟓 𝒙𝟏 + 𝒔𝟑 = 𝟓
𝒙𝟏 , 𝒙𝟐 ≥ 𝟎 𝒙𝟏 , 𝒙𝟐 , 𝒔𝟏 , 𝒔𝟐 , 𝒔𝟑 ≥ 𝟎
34
Question: Why Artificial Variable ?
• Consider the case with at least one constraint with “≥” or “=”,
𝑥1 − 2𝑥2 + 𝑥3 ≤ 11 𝑥1 − 2𝑥2 + 𝑥3 + s1 = 11 (1)
2𝑥1 + 𝑥2 − 4𝑥3 ≥ 3 2𝑥1 + 𝑥2 − 4𝑥3 − s2 = 3 (2)
𝑥1 − 2𝑥3 = 1 𝑥1 − 2𝑥3 = 1 (3)
𝑥1 , 𝑥2 , 𝑥3 ≥ 0 𝑥1 , 𝑥2 , 𝑥3 , s1 , s2 ≥ 0
• Like previous example, if we set normal variables 𝒙𝟏 = 𝒙𝟐 = 𝒙𝟑 = 𝟎, we have
constraint (1) ⇒ 𝑠1 = 11 (OK)
constraint (2) ⇒ 𝒔𝟐 = −𝟑 (Not OK)
constraint (3) ⇒ 0 = 1 (not OK)
• If we choose 𝒙𝟐 and 𝒙𝟑 as the non-basic variables and set their values to be zero
(𝒙𝟐 = 𝒙𝟑 = 𝟎), we have
constraint (3) ⇒ 𝒙𝟏 = 1 (OK)
constraint (1) ⇒ 𝑠1 = 10 (OK)
constraint (2) ⇒ 𝒔𝟐 = −𝟏 (not OK)
Without introducing artificial variables, it is not straightforward to identify an initial
feasible basic solution. 35
Question: Why Artificial Variable ?
• In this case, by adding artificial variables to “≥” and ”=” constraints (2)
and (3), we can easily identify an initial feasible basic solution.
• Evidently, If we choose basic variables 𝑠1 , 𝑎1 , 𝑎2 , then
(𝑥1 , 𝑥2 , 𝑥3 , 𝑠1 ,𝑠2 , 𝑎1 ,𝑎2 ) = (0,0,0,11,0,3,1) is a basic feasible solution.
• In order NOT to change the original optimal solution and optimal
objective function value after introducing 𝑎1 and 𝑎2 , we introduce a
large number 𝑀 to penalize 𝑎1 & 𝑎2 in the objective function, to ensure
that 𝑎1 = 𝑎2 = 0 at optimum.
𝐌𝐚𝐱 𝒁′ = 𝟎 − 𝒙𝟏 − 𝒙𝟐 + 𝟑𝒙𝟑 − 𝑴𝒂𝟏 − 𝑴𝒂𝟐
36
Question: Why setting a large coefficient M can enforce
artificial variables a equal to zero at final optimum ?
Consider Consider
max 𝑍 = 2𝑥1 − 𝑥2 max 𝑍 = 2𝑥1 − 𝑥2 − 9999𝑎 𝑀 = 9999
subject to 𝑥1 + 𝑥2 = 10 subject to 𝑥1 + 𝑥2 + 𝑎 = 10
𝑥1 ≥ 0; 𝑥2 ≥ 0 𝑥1 ≥ 0; 𝑥2 ≥ 0, 𝑎 ≥ 0
37
Simplex Method: Processes of Simplex Method
Stage 1
Stage 2
38
Example 1 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
39
Example 1 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
Stage 1
Stage 2
41
Example 1 (Stage 2)
Select an Entering Variable (Q3)
• Maximization problem
– Select the non-basic variable with a positive coefficient in the
objective function
• 𝑥1 is a non-basic variable with a positive coefficient
Basic Variables Non-basic Variables
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 } 𝑁𝐵0 = {𝑥1 , 𝑥2 }
𝑥1 + 2𝑥2 + 𝒔𝟏 = 12
4𝑥1 + 5𝑥2 + 𝒔𝟐 = 40
𝑥1 + 𝒔𝟑 = 5
𝑍 = 0 + 5𝑥1 + 8𝑥2
𝒙𝟏 is the entering variable
42
Example 1 (Stage 2)
Decide the Leaving Variable (Q3)
𝑥1 in
Basic 𝐵 0 = {𝑠1 , 𝑠2 , 𝑠3 } 𝑁𝐵0 = { 𝑥1 , 𝑥2 } Non-basic
Variables Variables
• The leaving variable is the one that first goes to zero as the
value of the entering variable increases from zero
– Set 𝒙𝟏 to the maximum while maintaining all variables non-negative.
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 }
𝒔𝟏 = 12 − 𝑥1 − 2𝑥2 ≥ 0 requires 𝑥1 ≤ 12
𝒔𝟐 = 40 − 4𝑥1 − 5𝑥2 ≥ 0 requires 𝑥1 ≤ 10
𝒔𝟑 = 5 − 𝑥1 ≥ 0 requires 𝑥1 ≤ 5 More limiting, hence 𝑠3 is the leaving
variable, or 𝑥1 will replace 𝑠3 as the new
𝑍 = 0 + 5𝑥1 + 8𝑥2 basic variable at a maximum value of 5
43
Example 1 (Stage 2)
Decide the Leaving Variable (Q3)
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 } 𝑁𝐵0 = {𝑥1 , 𝑥2 }
𝒔𝟏 = 12 − 𝑥1 − 2𝑥2 ≥ 0 requires 𝑥1 ≤ 12
𝒔𝟐 = 40 − 4𝑥1 − 5𝑥2 ≥ 0 requires 𝑥1 ≤ 10 𝑥1 becomes basic variable
but 𝑥2 remains non-basic
𝒔𝟑 = 5 − 𝑥1 ≥ 0 requires 𝑥1 ≤ 5 and hence still zero
𝑍 = 0 + 5𝑥1 + 8𝑥2
𝑥2
10
𝑍=5𝑥1 + 8𝑥2
9 Max 𝑍 = 5𝑥1 +8𝑥2
8 s.t.
7 𝑥1 + 2𝑥2 ≤ 12
4𝑥1 + 5𝑥2 ≤ 40
6 𝑥1 ≤ 5
5 𝑥1 , 𝑥2 ≥ 0
4
3
2
1
0 𝐵0 1 2 3 𝑥1
0 1 2 3 4 5 6 7 8 9 10 11 12 13
46
Question: Why choose x1 instead of x2 as entering variable even
x2 has a larger coefficient in the objective function ?
Answer: First, it is fine to choose either x1 or x2. Larger coefficient of x2 just means
larger increase in objective function for one unit increase in x2. The total increase in
objective function also depends on how much x2 can be increased once it enters the
set of basic variables.
Second, even a larger increase in objective function can be achieved at the current
iteration by choosing x2 as the entering variable; it does not guarantee that the total
number of movements is minimal to reach the optimum. In another word, the path
towards the optimum is not necessarily the shortest.
47
Simplex Method: Processes of Simplex Method
Stage 1
Stage 2
48
Example 1 (Stage 2)
Develop New Simplex Pivot (Q4)
• Using the equation of the leaving variable and the
entering variable to get a new basic feasible solution
– Change the coefficient of all basic variables to be 1.
𝐵0 = {𝑠1 , 𝑠2 , 𝑠3 } 𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 }
𝑥1 + 2𝑥2 + 𝒔𝟏 = 12 5 − 𝑠3 + 2𝑥2 + 𝒔𝟏 = 12
4𝑥1 + 5𝑥2 + 𝒔𝟐 = 40 𝒙𝟏 = 𝟓 − 𝒔𝟑 4 5 − 𝑠3 + 5𝑥2 + 𝒔𝟐 = 40
𝑥1 + 𝒔𝟑 = 5 𝒙𝟏 + 𝑠3 = 5
𝑍 = 0 + 5𝑥1 + 8𝑥2 𝑍 = 0 + 5 5 − 𝑠3 + 8𝑥2
𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 } 𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 }
2𝑥2 + 𝒔𝟏 − 𝑠3 = 7 𝒔𝟏 = 7 − 2𝑥2 + 𝑠3
5𝑥2 + 𝒔𝟐 − 4𝑠3 = 20 𝒔𝟐 = 20 − 5𝑥2 + 4𝑠3
OR
𝒙𝟏 + 𝑠3 = 5 𝒙𝟏 = 5 − 𝑠3
𝑍 = 25 − 5𝑠3 + 8𝑥2 𝑍 = 25 − 5𝑠3 + 8𝑥2 49
Example 1 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 }
2𝑥2 + 𝒔𝟏 − 𝑠3 = 7
5𝑥2 + 𝒔𝟐 − 4𝑠3 = 20
𝒙𝟏 + 𝑠3 = 5
𝑍 = 25 − 5𝑠3 + 8𝑥2
50
Example 1 (Stage 2)
Select the Entering Variable and Leaving Variable (Q3)
𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 }
𝑠1 ≥ 0 requires 𝑥2 ≤ 3.5 more limiting, hence
2𝑥2 + 𝒔𝟏 − 𝑠3 = 7 𝑠1 is the leaving
5𝑥2 + 𝒔𝟐 − 4𝑠3 = 20 𝑠2 ≥ 0 requires 𝑥2 ≤ 4 variable, or 𝑥2 will
replace 𝑠1 as the
𝒙𝟏 + 𝑠3 = 5 𝑥1 ≥ 0 requires 𝑥2 ≤ ∞ new basic variable
at a value of 3.5
𝑍 = 25 − 5𝑠3 + 8𝑥2
𝑥2 is the entering variable
51
Example 1 (Stage 2)
Develop New Simplex Pivot (Q4)
• Using the equation of the leaving variable and the
entering variables to get a new basic feasible solution
– Change the coefficient of all basic variables to be 1.
𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 } 𝐵2 = {𝑥2 , 𝑠2 , 𝑥1 }
2𝑥2 + 𝒔𝟏 − 𝑠3 = 7 𝒙𝟐 + 0.5𝑠1 − 0.5𝑠3 = 3.5
5𝑥2 + 𝒔𝟐 − 4𝑠3 = 20 −2.5𝑠1 + 𝒔𝟐 − 1.5𝑠3 = 2.5
𝟕 𝒔𝟑 𝒔𝟏
𝒙𝟐 = + −
𝒙𝟏 + 𝑠3 = 5 𝟐 𝟐 𝟐 𝒙𝟏 + 𝑠3 = 5
𝑍 = 25 − 5𝑠3 + 8𝑥2 𝑍 = 53 − 4𝑠1 − 𝑠3
𝐵2 = {𝑥2 , 𝑠2 , 𝑥1 }
𝒙𝟐 = 3.5 − 0.5𝑠1 + 0.5𝑠3
𝒔𝟐 = 2.5 + 2.5𝑠1 + 1.5𝑠3
𝒙𝟏 = 5 − 𝑠3
𝑍 = 53 − 4𝑠1 − 𝑠3 52
Example 1 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
• The non-basic variables are 𝑠1 and 𝑠3
• The coefficient of all non-basic variable are non-positive
• This basic solution is optimal
𝐵2 = {𝑥2 , 𝑠2 , 𝑥1 }
𝒙𝟐 + 0.5𝑠1 − 0.5𝑠3 = 3.5
−2.5𝑠1 + 𝒔𝟐 − 1.5𝑠3 = 2.5
𝒙𝟏 + 𝑠3 = 5
𝑍 = 53 − 4𝑠1 − 𝑠3
Optimal solution:
𝑥1∗ = 5, 𝑥2∗ = 3.5
All the coefficients of 𝑍 ∗ = 53
the non-basic
variables are negative
53
Example 1 (Summary of Stage 2)
Simplex method without Tableau form
𝐵1 = {𝑠1 , 𝑠2 , 𝑥1 } 𝐵2 = {𝑥2 , 𝑠2 , 𝑥1 }
2𝑥2 + 𝒔𝟏 − 𝑠3 = 7, 𝑠1 ≥ 0 requires 𝑥2 ≤ 3.5 𝒙𝟐 + 0.5𝑠1 − 0.5𝑠3 = 3.5
5𝑥2 + 𝒔𝟐 − 4𝑠3 = 20, 𝑠2 ≥ 0 requires 𝑥2 ≤ 4 −2.5𝑠1 + 𝒔𝟐 − 1.5𝑠3 = 2.5
𝒙𝟏 + 𝑠3 = 5, 𝑥1 ≥ 0 requires 𝑥2 ≤ ∞ 𝒙𝟏 + 𝑠3 = 5
𝑍 = 25 − 5𝑠3 + 8𝑥2 𝑍 = 53 − 4𝑠1 − 𝑠3
𝑥2 enters and 𝑠1 leaves
Optimal solution:
𝑥1∗ = 5, 𝑥2∗ = 3.5, 𝑍 ∗ = 53 54
Simplex Method: Example 1
Graphical Illustration of Simplex Method
𝑥2
10
9
𝑍=5𝑥1 + 8𝑥2
8
7
6
5
4
3
2
1
0 𝑥1
0 1 2 3 4 5 6 7 8 9 10 11 12 13
55
Min Z = 𝑥1 + 𝑥2 − 3𝑥3
Example 2 s.t.
− 𝑥1 + 2𝑥2 − 𝑥3 ≥ -11
Initial basic feasible solution
2𝑥1 + 𝑥2 − 4𝑥3 ≥ 3
B0={𝑠1 , 𝑎1 , 𝑎2 } 𝑥1 − 2𝑥3 = 1
1 𝑥 , 𝑥 ,
2 3 𝑥 ≥ 0
𝑥1 − 2𝑥2 + 𝑥3 + 𝒔𝟏 = 11
2𝑥1 + 𝑥2 − 4𝑥3 − 𝑠2 + 𝒂𝟏 = 3 ⇒ 𝒂𝟏 = 3 − 2𝑥1 − 𝑥2 + 4𝑥3 + s2
𝑥1 − 2𝑥3 + 𝒂𝟐 = 1 ⇒ 𝒂𝟐 = 1 − 𝑥1 + 2𝑥3
56
Simplex Method: Processes of Simplex Method
Stage 1
Stage 2
57
Example 2 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
B0={𝑠1 , 𝑎1 , 𝑎2 }
𝑥1 − 2𝑥2 + 𝑥3 + 𝒔𝟏 = 11
2𝑥1 + 𝑥2 − 4𝑥3 − 𝑠2 + 𝒂𝟏 = 3
𝑥1 − 2𝑥3 + 𝒂𝟐 = 1
𝑍′ = −4𝑀 + 3𝑀 − 1 𝑥1 + 𝑀 − 1 𝑥2 + −6𝑀 + 3 𝑥3 − 𝑀𝑠2
Stage 1
Stage 2
59
Example 2 (Stage 2)
Select an Entering Variable (Q3)
• Maximization problem
– Select the non-basic variable with a positive coefficient in the
objective function
• 𝑥1 is a non-basic variable with a positive coefficient
B0={𝑠1 , 𝑎1 , 𝑎2 }
𝑥1 − 2𝑥2 + 𝑥3 + 𝒔𝟏 = 11
2𝑥1 + 𝑥2 − 4𝑥3 − 𝑠2 + 𝒂𝟏 = 3
𝑥1 − 2𝑥3 + 𝒂𝟐 = 1
𝑍′ = −4𝑀 + 3𝑀 − 1 𝑥1 + 𝑀 − 1 𝑥2 + −6𝑀 + 3 𝑥3 − 𝑀𝑠2
𝒙𝟏 is the entering variable
60
Example 2 (Stage 2)
Decide the Leaving Variable (Q3)
• The leaving variable is the one that first goes to zero as the
value of the entering variable increases from zero
– Set 𝑥1 to the maximum while maintaining all variables non-negative.
B0={𝑠1 , 𝑎1 , 𝑎2 }
𝑥1 − 2𝑥2 + 𝑥3 + 𝒔𝟏 = 11, 𝑠1 ≥ 0 requires 𝑥1 ≤ 11
2𝑥1 + 𝑥2 − 4𝑥3 − 𝑠2 + 𝒂𝟏 = 3, 𝑎1 ≥ 0 requires 𝑥1 ≤ 3Τ2
𝑥1 − 2𝑥3 + 𝒂𝟐 = 1, 𝑎2 ≥ 0 requires 𝑥1 ≤ 1 𝒂𝟐 leaving
𝑍′ = −4𝑀 + 3𝑀 − 1 𝑥1 + 𝑀 − 1 𝑥2 + −6𝑀 + 3 𝑥3 − 𝑀𝑠2
𝑥1 will replace 𝑎2 as
the new basic variable
61
Simplex Method: Processes of Simplex Method
Stage 1
Stage 2
62
Example 2 (Stage 2)
Develop New Simplex Pivot (Q4)
• Using the equation of the leaving variable and the
entering variable to get a new basic feasible solution
– Change the coefficient of all basic variables to be 1.
B0={𝑠1 , 𝑎1 , 𝑎2 }
𝑥1 − 2𝑥2 + 𝑥3 + 𝒔𝟏 = 11
𝒙𝟏 = 1 + 2𝑥3 − 𝑎2
2𝑥1 + 𝑥2 − 4𝑥3 − 𝑠2 + 𝒂𝟏 = 3
𝑥1 − 2𝑥3 + 𝒂𝟐 =1
𝑍 = −4𝑀 + 3𝑀 − 1 𝑥1 + 𝑀 − 1 𝑥2
+ −6𝑀 + 3 𝑥3 − 𝑀𝑠2
B1={𝑠1 , 𝑎1 , 𝑥1 }
−𝑎2 − 2𝑥2 + 3𝑥3 + 𝒔𝟏 = 10
−2𝑎2 + 𝑥2 − 𝑠2 + 𝒂𝟏 = 1
𝑎2 − 2𝑥3 + 𝒙𝟏 = 1
𝑍′ = − 𝑀 + 1 + −3𝑀 + 1 𝑎2 + 𝑀 − 1 𝑥2 + 𝑥3 − 𝑀𝑠2
63
Example 2 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
B1={𝑠1 , 𝑎1 , 𝑥1 }
−𝑎2 − 2𝑥2 + 3𝑥3 + 𝒔𝟏 = 10
−2𝑎2 + 𝑥2 − 𝑠2 + 𝒂𝟏 = 1
𝑎2 − 2𝑥3 + 𝒙𝟏 = 1
𝑍′ = − 𝑀 + 1 + −3𝑀 + 1 𝑎2 + 𝑀 − 1 𝑥2 + 𝑥3 − 𝑀𝑠2
64
Example 2 (Stage 2)
Select the Entering Variable and Leaving Variable (Q3)
65
Example 2 (Stage 2)
Develop New Simplex Pivot (Q4)
• Using the equation of the leaving variable and the
entering variables to get a new basic feasible solution
– Change the coefficient of all basic variables to be 1.
B1={𝑠1 ,𝑎1 ,𝑥1 }
−𝑎2 − 2𝑥2 + 3𝑥3 + 𝒔𝟏 = 10
𝒙𝟐 = 1 + 2𝑎2 + 𝑠2 − 𝑎1
−2𝑎2 + 𝑥2 − 𝑠2 + 𝒂𝟏 = 1
𝑎2 − 2𝑥3 + 𝒙𝟏 = 1
𝑍′ = − 𝑀 + 1 + −3𝑀 + 1 𝑎2
+ 𝑀 − 1 𝑥2 + 𝑥3 − 𝑀𝑠2
B2={𝑠1 ,𝑥2 ,𝑥1 }
−5𝑎2 − 2𝑠2 + 3𝑥3 + 2𝑎1 + 𝒔𝟏 = 12
−2𝑎2 − 𝑠2 + 𝑎1 + 𝒙𝟐 = 1
𝑎2 − 2𝑥3 + 𝒙𝟏 = 1
𝑍′ = −2 + 𝑥3 − 𝑠2 + −𝑀 − 1 𝑎2 − 𝑀 − 1 𝑎1
66
Example 2 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
67
Example 2 (Stage 2)
Select the Entering Variable and Leaving Variable (Q3)
68
Example 2 (Stage 2)
Develop New Simplex Pivot (Q4)
• Using the equation of the leaving variable and the
entering variable to get a new basic feasible solution
– Change the coefficient of all basic variables to be 1.
B2={𝑠1 ,𝑥2 ,𝑥1 }
−5𝑎2 − 2𝑠2 + 3𝑥3 + 2𝑎1 + 𝒔𝟏 = 12 5 2 2 1
𝒙𝟑 = 4 + 𝑎2 + 𝑠2 − 𝑎1 − 𝑠1
−2𝑎2 − 𝑠2 + 𝑎1 + 𝒙𝟐 = 1 3 3 3 3
𝑎2 − 2𝑥3 + 𝒙𝟏 = 1
𝑍′ = −2 + −𝑀 − 1 𝑎2 + 𝑀 − 1 𝑠2
− 𝑀 − 1 𝑎1 + 𝑥3 B3={𝑥3 ,𝑥2 ,𝑥1 }
5 2 2 1
− 𝑎2 − 𝑠2 + 𝑎1 + 𝑠1 + 𝒙𝟑 = 4
3 3 3 3
−2𝑎2 − 𝑠2 + 𝑎1 + 𝒙𝟐 = 1
7 4 4 2
− 𝑎2 − 𝑠2 + 𝑎1 + 𝑠1 + 𝒙𝟏 = 9
3 3 3 3
1 1 1 2
𝑍′ = 2 − 𝑠1 − 𝑠2 − 𝑀 − 𝑎 − 𝑀− 𝑎
3 3 3 1 3 2
69
Example 2 (Stage 2)
Check whether a Basic Solution is Optimal (Q2)
70