C4 - Simplex Method
C4 - Simplex Method
C4 - Simplex Method
1
Outline chapter
Introduction to Simplex method
Setup a standard LP problem
Solve LP with simplex method
Understand sensitivity analysis with simplex
method.
Understand special cases in LP
2
Gauss-Jordan Elimination
Solve: 2 x1 3x2 7
4 x1 5 x2 13
2 3 7
and read off answer from right
column
4 5 13
3
Gauss-Jordan Elimination (cont.)
2 3 7 1 3
2
7 2
row1new= 1/2 * row1
4 5 13 4 5 13
r ow 1
–4*
= row2
1 row2 ne
1 3 7
w
3 7
2 2 2 2
0 1 1 row2new= (-1) * row2
0 1 1
w2
/ 2) * ro
1 2
3
0 –( -
= row1
row1 ne
w
0 1 1 Read off solution: x1 = 2, x2 = 1 4
Introduction to Simplex Method
Developed by George Dantzig in 1947.
The simplex method:
moves from one extreme point to its neighboring extreme
point, stopping when the objective function can no longer be
improved.
The procedure ends when the optimal solution is found or the
problem has no solution.
Based on the Gauss-Jordan elimination procedure.
5
The simplex algorithm
Start
Convert to LP
standard form
Optimal
End
solution Yes
No
7
The simplex algorithm
Constraints: with the type
: add a slack variable to left side
: subtract a surplus variable and add an Artificial variable
to left side
= : add an Artificial variable to left side.
Example:
3x1 + 2x2 25 is converted to 3x1 + 2x2 + s = 25
Objective function:
Min. Z = - Max (- Z)
Example: Min Z = 5x1 + 3x2 has the same solution
with Max (-Z) = - 5x1 - 3x2
8
The simplex algorithm
The standard LP problem
Example
Convert to:
x1 + x2 = 10
x1 + x 2 + A 1 =
2x1 + 2 x2 5
10
4x1 + 3 x2 8
2x1 + 2 x2 + s1 = 5
4x1 + 3 x2 - s2 + A 2 = 8
Where S1: Slack var.,
S2: Surplus var.
A1: Artificial var.
9
The simplex algorithm
The standard LP problem:
Basic solutions
The constraints consist of m equations and n variables (with
n> m). So the basic solution gives
m variables different from zero and
(n-m) variables must be zero.
We call:
m variables are basic solution and
(n-m) variables are non-basic variables.
10
The simplex algorithm
The standard LP problem
11
The simplex algorithm
Initial solution:
m = 2; n = 4
m = 2; n = 4 The final solution:
The initial solution: x1 = 30; x2 = 40
x1 = x2 = 0 :non-basic
s1 = s2 = 0
s1 = 240; s2 = 100: basic
m=2: basic solution
m=2: basic solution 4-2 = 2: non-basic solution
4-2 = 2: non-basic solution
12
The simplex algorithm
Start
Convert to LP
standard form
Optimal
End
solution Yes
No
14
The simplex algorithm (Max problem)
Step 3: Compute the new value for each
remaining row:
Keep other number in the pivot column ( pivot number) to be
zero by matrix elementary transformation
15
The simplex algorithm
Start
Convert to LP
standard form
Optimal
End
solution Yes
No
Basic X1 X2 S1 S2 S3 RHS
variable
Z -3 -5 0 0 0 0
S1 1 0 1 0 0 4
S2 0 2 0 1 0 12
S3 3 2 0 0 1 18
Is the current BFS
The initial solution:
Optimal?
x1 = x2 = 0 : nonbasic variables
s1 = 4; s2 = 12; s3 = 18 : basic variables Z=0 18
The simplex algorithm (Max problem)
Determine entering variable, leaving variable,
pivot number Entering variable (largest negative)
23
Summary
Otherwise:
Determine the entering variable ( the most positive coefficient
value or the most negative coefficient in Z-eq for maximize
problem or minimize problem, respectively).
Determine the leaving variable (minimum ratio test).
The pivot number must be equal to 1 in the next iteration.
The rest of number in the pivot column must be equal to 0 in
the next iteration.
When all coefficient values in the Z-eq. are non-negative for
MAXIMIZE PROBLEM and non-positive for MINIMIZE
PROBLEM, reach optimal.
24
Big M method
LP Standard form :
Maximize (Minimize) Z:
subject to:
functional constraints in form (≤),(≥) bi
nonnegativity constraints on all variables
bi≥0 for all i = 1, 2, . . . , m.
25
Big M method
Artificial variables:
When constraints are equalities, artificial variables are used to
set up an initial solution in the first tableau.
Big M method
Step 1: Obtaining an Initial BF Solution
Maximize Z = 3x1 +5x2 Maximize Z = 3x1 +5x2 +0 s1 +0 s2
subject to subject to
x1 ≤ 4 x1 + s1 = 4
2x2 + s2 =12
2x2 ≤ 12
3x1 +2x2 = 18
3x1 +2x2 = 18
x1 ≥ 0, x2 ≥ 0, s1 ≥ 0, s2 ≥ 0,
x1 ≥ 0, x2 ≥ 0
x1 = 0, x2 = 9
s1 = 4
No initial feasible solution s2 = -6 (violate)
x1 ≥ 0, x2 ≥ 0, s1 ≥ 0, s2 ≥ 0,
Big M method
Maximize Z = 3x1+ 5x2 +0 s1 +0 s2 – MA1
subject to
x1 + s1 = 4
2x2 + s2 =12
Initial feasible solution
Nonbasic variables:
3x1 +2x2 + A1= 18 x1 = 0, x2 = 0
x1 ≥ 0, x2 ≥ 0, s1 ≥ 0, s2 ≥ 0, A1 ≥0 Basic variables:
x3 = 4, x4=12, A1 = 18.
s1 (1) 1 0 1 0 0 4
0
s2 (2) 0 2 0 1 0 12
A1 (3) 3 2 0 0 1 18
Iteration Basic Eq. x1 x2 s1 s2 A1 RHS
varibles
Z (0) 0 -2M-5 3M+3 0 0 -6M+12
X1 (1) 1 0 1 0 0 4
1
s2 (2) 0 2 0 1 0 12
A1 (3) 0 2 -3 0 1 6
Big M method
Step 3: Applicating of the Simplex Method (cont)
Iteration Basic Eq. x1 x2 s1 s2 A1 RHS
varibles
Z (0) 0 0 -9/2 0 M+5/2 27
X1 (1) 1 0 1 0 0 4
2
s2 (2) 0 0 3 1 -1 6
X2 (3) 0 1 -3/2 0 1/2 3
02/06/2023 33
Two phase method
Big M :
Min Z= 0.4x1 +0.5 x2 Min Z= 0.4x1 +0.5x2 +MA1 +MA2
st: st:
0.3x1 + 0.1x2 ≤ 2.7 0.3x1 + 0.1x2 + s1 = 2.7
0.5x1 + 0.5x2 = 6 0.5x1 + 0.5x2 + A1 = 6
0.6x1+ 0.4x2 ≥ 6 0.6x1 + 0.4x2 - s2 +A2 = 6
x1,x2 ≥ 0 x1,x2,s1,s2,A1,A2≥0
Two phase method:
Phase 2:
Continue with the min Z= 0.4x1 + 0.5x2
Phase 1: basic feasible st:
min Z’ = A1+A2 0.3x1 + 0.1x2 + s1 = 2.7
st:
solution of phase 0.5x1 + 0.5x2 = 6
0.3x1 + 0.1x2 + s1=2.7 1. 0.6x1 + 0.4x2 - s2 = 6
0.5x1 + 0.5x2 + A1= 6 x1,x2,s1,s2 ≥0
0.6x1+ 0.4x2 - s2+A2 = 6
x1,x2,s1,s2,A1,A2≥0
34
Phase 1
Iter Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
0 Z -1 -1.1 -0.9 0 0 1 0 -12
S1 0 0.3 0.1 1 0 0 0 2.7
A1 0 0.5 0.5 0 1 0 0 6
A2 0 0.6 0.4 0 0 -1 1 6
Iter Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
1 Z -1 0 -16/30 11/3 0 1 0 -2.1
X1 0 1 1/3 10/3 0 0 0 9
A1 0 0 1/3 -5/3 1 0 0 1.5
A2 0 0 0.2 -2 0 -1 1 0.6
Iter Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
2 Z -1 0 0 -5/3 0 -5/3 8/3 -0.5
X1 0 1 0 20/3 0 5/3 -5/3 8
A1 0 0 0 5/3 1 5/3 -5/3 0.5
X2 0 0 1 -10 0 -5 5 3
Iter Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
2 Z -1 0 0 0 1 0 1 0
X1 0 1 0 0 -4 -5 5 6
S1 0 0 0 1 3/5 1 -1 0.3
X2 0 0 1 0 6 5 -5 6
35
Phase 2 preparation
Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
Z -1 0 0 0 1 0 1 0
Final Phase 1 X1 0 1 0 0 -4 -5 5 6
S1 0 0 0 1 3/5 1 -1 0.3
X2 0 0 1 0 6 5 -5 6
Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS
Z -1 0 0 0 0 0
Drop A1, A2 X1 0 1 0 0 -5 6
S1 0 0 0 1 1 0.3
X2 0 0 1 0 5 6
37
Two phase method
This graph shows the sequence of Coner Point Feasible solutions for
phase 1 (0, 1, 2, 3) and then for phase 2 ([0] ,[1])
02/06/2023 38
Four Special cases in Simplex method
(watch video)
1. Degeneracy
2. Alternative optimal
3. Unbounded solution
4. Infeasible solution
02/06/2023 39
Four Special cases in Simplex method
Degeneracy:
It is situation when the solution of the problem degenerates.
Degenerate Solution:
A Solution of the problem is said to be degenerate solution if
value or values of basic variable(s) become zero
It occurs due to redundant constraints.
02/06/2023 40
Four Special cases in Simplex method
Degeneracy
This is in itself not a problem, but making simplex iterations
form a degenerate solution, give rise to cycling, meaning that
after a certain number of iterations without improvement in
objective value the method may turn back to the point where it
started.
02/06/2023 41
Four Special cases in Simplex method
Degeneracy
Max Z = 3x1 + 9x2
Subject to:
x1 + 4x2 ≤ 8
X1 + 2x2 ≤ 4
X1, x2 ≥ 0
02/06/2023 42
Four Special cases in Simplex method
The solution:
Step 1: Write inequalities in equation form
Let s and s be the slack variables
1 2
x1 + 4x2 + s1= 8
x1 + 2x2 + s2= 4
x1, x2 ,s1,s2≥ 0
Let x1=0, x2=0
Z=0, s1=8, s2=4
02/06/2023 43
Four Special cases in Simplex method
Degeneracy
X2 will enter the basis because of having minimum objective function
Initial Tableau coefficient.
Entering Variable Leaving Variable
Basis X1 X2 S1 S2 RHS Ratio
Z -3 -9 0 0 0
S1 1 4 1 0 8 8/4=2
S2 1 2 0 1 4 4/2=2
S1 and S2 tie for leaving variable( with same minimum ratio 2) so we can
take any one of them arbitrary.
02/06/2023 44
Four Special cases in Simplex method
Tableau 1 Degeneracy
Basis X1 X2 S1 S2 RHS Ratio
Z -3/4 0 9/4 0 18
X2 1/4 1 1/4 0 2 8
S2 ½ 0 -1/2 1 0 0 min
Basis X1 X2 S1 S2 RHS
Z 0 0 3/2 3/2 18
X2 0 1 1/2 -1/2 2
X1 1 0 -1 2 0
Same objective function no change and
improvement ( cycle)
02/06/2023 46
Four Special cases in Simplex method
Degeneracy
This is redundant constraint because its presence
or absence does not affect, neither on optimal
point nor on feasible region.
Feasible
Region
02/06/2023 47
Four Special cases in Simplex method
Alternative optimal:
Z-row value for one or more non basic variables is 0 in the
optimal tableau
When the objective function is parallel to a binding constraint,
objective function will assume same optimal value.
02/06/2023 48
Four Special cases in Simplex method
Alternative optimal
Example:
Max Z= 2x1+ 4 x2
ST
x1 + 2x2 ≤ 5
x1 + x2 ≤ 4
x1, x2 ≥0
02/06/2023 49
Four Special cases in Simplex method
Alternative optimal
The solution
Max Z=2x1+ 4x2
Let S1and S2 be the slack variables
x1 + 2x2 + s1= 5
x1 + x 2 + s2 = 4
x1, x2, s1, s2 ≥0
Initial solution
02/06/2023
Let x1 = 0, x2 = 0, 50
Four Special cases in Simplex method
Alternative optimal
Initial Tableau Entering Variable
Leaving Variable
02/06/2023 51
Four Special cases in Simplex method
Alternative optimal
Optimal solution is 10 when x2=5/2, x1=0.
02/06/2023 52
Four Special cases in Simplex method
Alternative optimal
By looking at Z-row coefficient of the nonbasic variable.
Basis X1 X2 S1 S2 RHS Ratio
Z 0 0 2 0 10
X2 1/2 1 1/2 0 5/2 5
S2 1/2 0 -1/2 1 3/2 3
The coefficient of x1 =0 that x1 can enter the basic solution without changing the
value of Z.
Optimal sol. Z=10 , x1=0, x2=5/2
02/06/2023 53
Four Special cases in Simplex method
Alternative optimal
The second alternative optimal is:
Basis X1 X2 S1 S2 RHS
Z 0 0 2 0 10
X2 0 1 1 -1 1
X1 1 0 -1 2 3
The new optimal solution is 10 when x1=3, x2=1
02/06/2023 54
Four Special cases in Simplex method
Alternative optimal
Objective Function
02/06/2023 55
Four Special cases in Simplex method
Unbounded Solution
When determining the leaving variable of any tableau, if there
is no positive ratio (all the entries in the pivot column are
negative and undefined), then the solution is unbounded.
02/06/2023 56
Four Special cases in Simplex method
Unbounded Solution
Example
Max Z= 2x1+ x2
Subject to
x1 – x2 ≤10
2x1 ≤ 40
x1, x2≥0
02/06/2023 57
Four Special cases in Simplex method
Unbounded Solution
Max 2x1+ x2
Let S1 and S2 be the slack variables
x1 – x2 +s1 =10
2x1+0x2 + s2 =40
x1, x2,s1,s2 ≥0
Initial Solution: x1 = 0, x2=0,
Z=0, s1 =10, s2 =40
02/06/2023 58
Four Special cases in Simplex method
Unbounded Solution
59
02/06/2023 59
Four Special cases in Simplex method
Unbounded Solution
Basis X1 X2 S1 S2 RHS Ratio
Z 0 -3 2 0 20
X1 1 -1 1 0 10 -
S2 0 2 -2 1 20 10
60
02/06/2023 60
Four Special cases in Simplex method
Unbounded
Basis X1 X2 S1 S2 RHS Ratio
Z 0 0 -3 3/2 50
X1 1 0 0 ½ 20 20/0-
X2 0 1 -1 1/2 10 10/-1
61
02/06/2023 61
Four Special cases in Simplex method
Unbounded Solution
Objective function
Unbounded
0
Solution
≤1
Space
2
x
–
2x1 ≤ 40
1
x
Optimal Point
02/06/2023 62
Four Special cases in Simplex method
Infeasible Solution:
No feasible optimal solution is available.
Constraints are conflicting.
An artificial variable still remains in the final tableau
02/06/2023 63
Four Special cases in Simplex method
Infeasible Solution:
MAX Z= 2x1 + 6x2
s. t.
4x1 + 3x2 < 12
2x1 + x2 > 8
x1, x2 >= 0
02/06/2023 64
Four Special cases in Simplex method
Infeasible Solution:
x1 x2 s1 s2 A1 RHS
Z -2-2M 6-M 0 M 0 -8M
S1 4 3 1 0 0 12
A1 2 1 0 -1 1 8
x1 x2 s1 s2 A1 RHS
Z 0 15/2+ 1/2M 1/2+1/2M M 0 6-2M
S1 1 3/4 1/4 0 0 3
A1 0 1/2 -1/2 -1 1 2
x2
2x1 + x2 > 8
2x1 + 6x2 =Z
x1
02/06/2023 66