You are on page 1of 66

Simplex method

Ha Thi Xuan Chi, PhD


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
Gauss-Jordan Elimination
Solve: 2 x1  3 x2  7
4 x1  5 x2  13

We can perform the problem as matrix form:

2 3 7
and read off answer from right
  column
4 5 13

Goal: reduce this to trivial form


1x1  0 x2  a 1 0 a
 
0 x1  1x2  b 0 1 b
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 2
row2 ne
1 3 7 
w
3 7
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
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.
The simplex algorithm
Start

Convert to LP
standard form

Find the initial


solution

Optimal
End
solution Yes
No

Pivot row, column, Selecting entering variable


number

Selecting leaving variable


The simplex algorithm
The standard LP problem conditions: (watch
video)
 All constraints are equations.
 All variables are nonnegative
 The objective function may be maximization or minimization.
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
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.
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.
The simplex algorithm
The standard LP problem

Original After converting:


Max. Z = $7x1 + $5x2+ $0s1+ $0s2
Max. Z = $7x1 + $5x2
Subject to:
Subject to:
2x1 + 1x2 + 1s1 = 100
2x1 + 1x2  100
4x1 + 3x2 + 1s2 = 240
4x1 + 3x2  240
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
The simplex algorithm
Start

Convert to LP
standard form

Find the initial


solution

Optimal
End
solution Yes
No

Pivot row, column, Selecting entering variable


number

Selecting leaving variable


The simplex algorithm (Max problem)
Step 1: Determine Entering variable:
 The largest positive number in the Zj row.
 The column identified is called pivot column.

 Step 2: Determine Leaving variable:


 Dividing amount in RHS by the corresponding number in the
selected column, select smallest ratio, take only positive
number.
 This row is called pivot row, the intersection called pivot
number.
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

Step 4: Compute Zj rows:


 If all numbers in the Zj row are non-positive, reach optimal.
 If not, return to step 1
The simplex algorithm
Start

Convert to LP
standard form

Find the initial


solution

Optimal
End
solution Yes
No

Pivot row, column, Selecting entering variable


number

Selecting leaving variable


The simplex algorithm (Max problem)
Convert LP problem to standard form ( watch
video)
Original form After converting
Maximize Z = 3x1 + 5x2 Maximize Z = 3x1 + 5x2
Subject to Subject to
x1 ≤4 x1 + s1 =4
2x2 ≤ 12 2x2 + s2 = 12
3x1 + 2x2 ≤ 18 3x1 + 2x2 + s3 = 18
x1 ≥ 0 x1≥ 0
x2 ≥ 0. x ≥ 0.
2
Number of nonbasic = 2, basic = 3.
The simplex algorithm (Max problem)
 Find the initial solution

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
The simplex algorithm (Max problem)
Determine entering variable, leaving variable,
pivot number Entering variable (largest negative)

Iteration Basic X1 X2 S1 S2 S3 RHS Ratio


variable
Z -3 -5 0 0 0 0
S1 1 0 1 0 0 4 4/0 undefined
0
S2 0 2 0 1 0 12 The
12/2
smallest
S3 3 2 0 0 1 18 18/2 ratio

Leaving Pivot Pivot Pivot


variable column number row
Is the current BFS Optimal?

The simplex algorithm (Max problem)


 Test the new BFS
Iteration Eq. Basic X1 X2 S1 S2 S3 RHS Ratio
variable
(0) Z -3 -5 0 0 0 0
(1) S1 1 0 1 0 0 4
0
(2)
(2) S22 0
0/2 2
2/2 0
0/2 1
1/2 0
0/2 12
12/2
(3) S3 3 2 0 0 1 18
(0) Z 0*(5)-3 1*(5)-5 0*5-0 ½*5-0 0*5-0 6*5-0
1 (1) S1 1 0 1 0 0 4
(2) X2 0 1 0 1/2 0 6
(3) S3 0*(2)-3 1*2-2 0*2-0 ½*2-0 1*2-0 6*2-0

The rest of number in the pivot The pivot number must


X2 becomes in the basic column must be equal to 0 in the next be equal to 1 in the next
variables list instead of S2 iteration iteration
Step 5: Repeat step 3, 4
Is the current BFS Optimal?
Iteratio Eq. Basic X X2 S1 S2 S3 RH Rati
n variab 1 S o
le
(0) Z -3 -5 0 0 0 0
(1) S1 1 0 1 0 0 4
0
(2) S2 0 2 0 1 0 12 12/2
(3) S3 3 2 0 0 1 18 18/2
(0) Z -3 0 0 5/2 0 30
1 (1) S1 1 0 1 0 0 4 4/1
(2) X2 0 1 0 1/2 0 6
(3)
Z=36
S3 3 0 0 -1 1 6 6/3
(0) Z 0 0 0 3/2 1 36
2
non-negative
(1) S1 0 0 1 1/3 -1/3 2
(2) X2 0 1 0 1/2 0 6
Optimal solution
Summary
Convert LP problem to standard form
Test optimality:
 Find initial basis feasible solution(BFS)
 Check the initial BFS, if initial BFS is an optimal solution, stop.
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.
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.

How can we solve “=”forms of the linear


programming model?
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.

M: a huge positive number

The coefficient of slack or surplus variable is zero


The coefficient of artificial variable is M
Big M method
 Step 2 : Converting Equation (0) to standard form

Maximize Z -3x1- 5x2 + MA1 =0 A basic variable A1


subject to has a nonzero
x1 + s 1 = 4
2x2 + s2 =12
coefficient in Eq. (0),
3x1 + 2x2+ A1= 18 thus A1 must be
x1 ≥ 0, x2 ≥ 0, s1 ≥ 0, s2 ≥ 0, A1 ≥0 eliminated
Z -3x1 -5x2 MA1 0
+
-M x (3x1 +2x2 + A1 18)

Z -(3M-3) x1 -(2M-5) x2 -18M


Big M method
 Step 3: Applicating of the Simplex Method
Iteration Basic Eq. x1 x2 s1 s2 A1 RHS
varibles
Z (0) -3M - 3 -2M -5 0 0 0 -18M

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

Iteration Basic Eq. x1 x2 s1 s2 A1 RHS


varibles
Z (0) 0 0 0 3/2 M+1 36
x1 (1) 1 0 0 -1/3 1/3 2
3
s2 (2) 0 0 1 1/3 -1/3 2
x2 (3) 0 1 0 1/2 0 6

The optimal solution is x1=2, s2=2, x2=6, Z=36


Summary (watch video)
Artificial variables are added to “=” constraint
forms.
The coefficient of artificial variable is M.
The coefficient of slack (surplus )variable is 0.
LP problem: convert to standard form before
using the simplex method.
Two phase method
«Greater than or equal to » constraints,
the slack variable in the equality form has a
negative coefficient or equality constraints do
not have slack variables.
If either type of constraints is part of the model,
there is no convenient initial basic solution.
In this case we use a two phase method for the
simplex procedure.
 Phase 1 has the goal of finding a basic feasible solution,
 Phase 2 has goal of finding the optimum solution.
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
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
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

Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS


Z -1 0.4 0.5 0 0 0
Phase 2 X1 0 1 0 0 -5 6
Obj. fct. S1 0 0 0 1 1 0.3
X2 0 0 1 0 5 6

Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS


Iter. 1 Z -1 0 0 0 -0.5 -5.4
Gaussian X1 0 1 0 0 -5 6
Elimination S1 0 0 0 1 1 0.3
X2 0 0 1 0 5 6
Phase 2 Final

Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS


Iter. 0 Z -1 0 0 0 -0.5 -5.4
X1 0 1 0 0 -5 6
S1 0 0 0 1 1 0.3
X2 0 0 1 0 5 6

Basic Vars. Z X1 X2 S1 A1 S2 A2 RHS


Iter. 1 Z -1 0 0 0.5 0 -5.25
X1 0 1 0 5 0 7.5
S2 0 0 0 1 1 0.3
X2 0 0 1 -5 0 4.5

The optimal solution has been reached:


X1 = 7.5; X2 = 4.5; Z = 5.25
S1 = 0; S2 = 0.3
Two phase method

The sequence of Coner


Point Feasible solutions
for phase 1 and phase 2

This graph shows the sequence of Coner Point Feasible solutions for
phase 1 (0, 1, 2, 3) and then for phase 2 ([0] ,[1])
Four Special cases in Simplex method
(watch video)
1. Degeneracy
2. Alternative optimal
3. Unbounded solution
4. Infeasible solution
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.
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.
Four Special cases in Simplex method
Degeneracy
 Max Z = 3x1 + 9x2
 Subject to:
x1 + 4x2 ≤ 8
X1 + 2x2 ≤ 4
X1, x2 ≥ 0
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
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.
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

Here basic variable S2 is 0 resulting in a


degenerate basic solution.
Four Special cases in Simplex method
Degeneracy:
Tableau 2 Same objective

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)
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
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.
Four Special cases in Simplex method

Alternative optimal
Example:
Max Z= 2x1+ 4 x2
ST
x1 + 2x2 ≤ 5
x1 + x2 ≤ 4
x1, x2 ≥0
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
Let x1 = 0, x2 = 0,
Four Special cases in Simplex method
Alternative optimal
Initial Tableau Entering Variable

Basis X1 X2 S1 S2 RHS Ratio


Z -2 -4 0 0 0
S1 1 2 1 0 5 5/2=2.5
S2 1 1 0 1 4 4/1=4

Leaving Variable
Four Special cases in Simplex method
Alternative optimal
Optimal solution is 10 when x2=5/2, x1=0.

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 min
How do we know that alternative optimal exist ?
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
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
Four Special cases in Simplex method
Alternative optimal

Any point on BC represents an


alternate optimum with Z=10

Objective Function
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.
Four Special cases in Simplex method
Unbounded Solution
Example
Max Z= 2x1+ x2
Subject to
x1 – x2 ≤10
2x1 ≤ 40
x1, x2≥0
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
Four Special cases in Simplex method

Unbounded Solution

Basis X1 X2 S1 S2 RHS Ratio


Z -2 -1 0 0 0
S1 1 -1 1 0 10 10 min
S2 2 0 0 1 40 20

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
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

 All the ratios are negative and undefined.


 So, solution space is unbounded

61
Four Special cases in Simplex method

Unbounded Solution
Objective function

Unbounded

0
Solution

≤1
Space

2
x

2x1 ≤ 40

1
x
Optimal Point
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
Four Special cases in Simplex method
 Infeasible Solution:
MAX Z= 2x1 + 6x2
s. t.
4x1 + 3x2 < 12
2x1 + x2 > 8
x1, x2 >= 0
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

An artificial variable( A1=2) is still positive, so the


problem is infeasible
Four Special cases in Simplex method
 Infeasible Solution:

x2

4x1 + 3x2 < 12

2x1 + x2 > 8

2x1 + 6x2 =Z

x1

You might also like