03-Simplex Algorithm
03-Simplex Algorithm
Decisions
Introduction to the Simplex Algorithm
George Gross
Department of Electrical and Computer Engineering
University of Illinois at Urbana-Champaign
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 1
SOLUTION OF SYSTEMS OF LINEAR
EQUATIONS
We examine the solution of
Ax = b
unknowns:
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 2
SOLUTION OF SYSTEMS OF LINEAR
EQUATIONS
⎧ x1 − 2 x 2 + x 3 − 4 x 4 + 2 x 5 = 2 (i )
⎪
S1 ⎨
⎪
⎩ x1 − x 2 − x 3 − 3 x 4 − x 5 = 4 ( ii )
x 1 = 6 and x 2 = 2
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 7
BASIC FEASIBLE SOLUTION
A basic feasible solution is a basic solution in which
nonnegative
⎛ 5⎞ 5!
⎜ ⎟ = = 10
⎝ 2⎠ 3! 2!
we introduced above
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 10
SIMPLEX METHODOLOGY EXAMPLE
max Z = 5 x 1 + 2 x 2 + 3 x 3 − x 4 + x 5
s .t .
⎧ x 1 + 2x 2 + 2x 3 + x 4 = 8 (*)
canonical ⎪
⎪
⎨
⎪
form
⎪⎩ 3x 1 + 4x 2 + x3 + x5 = 7 (**)
xi ≥ 0 i = 1, … , 5
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 11
THE SIMPLEX SOLUTION METHOD
Z = − 8 + 7 = −1
The next step is to improve the basic feasible
solution by finding an adjacent basic feasible
solution
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 12
ADJACENT FEASIBLE SOLUTION
following traits
basic variable ≥ 0
nonbasic variable = 0
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 13
ADJACENT FEASIBLE SOLUTION
The search for an adjacent basic feasible solution
constraints
x1 + x4 = 8
3x 1 + x5 = 7
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 15
ADJACENT FEASIBLE SOLUTION
The largest value x 1 can assume without making
either x 4 or x 5 negative is
⎧ 7⎫ 7
min ⎨8, ⎬ =
⎩ 3⎭ 3
We have the new basic variable with the value
7
x1 = ,
3
and the other basic variable is
17
x4 =
3
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 16
ADJACENT FEASIBLE SOLUTION
x 2 = x 3 = 0 and x 5 = 0
max Z = 5 x 1 + 2 x 2 + 3 x 3 − x 4 + x 5
s .t .
non - ⎧
⎪ x 1 + 2x 2 + 2x 3 + x 4 = 8 (*)
canonical ⎪
⎨
form ⎪
for x1 ⎪⎩ 3x 1 + 4x 2 + x 3 + x5 = 7 (**)
xi ≥ 0 i = 1, … , 5
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 18
ADJACENT FEASIBLE SOLUTION
1
multiply equation (**) by − and add to
3
equation (*)
2x + 5x + 1 17
x4 − x 5 =
3 2
3 3
3 3
nonbasic variable
canonical form
of so-called tableaus
cj 5 2 3 –1 1
cB constraint
basic constants
variables x1 x2 x3 x4 x5
–1 x4 1 2 2 1 8
1 x5 3 4 1 1 7
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 25
THE SIMPLEX TABLEAU
The optimality check requires the evaluation of
⎛ T column corresponding ⎞
cj = cj− ⎜⎜ c B i
to x in canonical form ⎟⎟
⎝ j ⎠
For each nonbasic variable xj , for our example, we
have
⎡1 ⎤
c1 = 5 − ⎡⎣−1, 1⎤⎦ i ⎢ ⎥ = 3
⎣ 3⎦
⎡ 2⎤
c 2 = 2 − ⎡⎣−1, 1⎤⎦ i ⎢ ⎥ = 0
⎣4⎦
⎡ 2⎤
c 3 = 3 − ⎡⎣−1, 1⎤⎦ i ⎢ ⎥ = 4
⎣1 ⎦
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 26
THE SIMPLEX TABLEAU
cB cj 5 2 3 -1 1 constraint
basic
variables x1 x2 x3 x4 x5 constants
-1 x4 1 2 2 1 8
x5
1 3 4 1 1 7
cT 3 0 4 0 0 Z = –1
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 27
SIMPLEX TABLEAU
constraint equations:
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 28
THE SIMPLEX TABLEAU
2 x5 (7/1) = 7
min { 4, 7 } = 4
max Z = 5 x 1 + 2 x 2 + 3 x 3 − x 4 + x 5
s .t .
canonical ⎧
⎪ x1 + 2x2 + 2x3 + x4 = 8 (*)
form ⎪
⎨
for ⎪
x 4 and x 5 ⎪⎩ 3 x 1 + 4x2 + x3 + x5 = 7 (**)
xi ≥0 i = 1, … , 5
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 30
THE SIMPLEX TABLEAU
For the new basic feasible solution, we put the
equations into canonical form
cj 5 2 3 –1 1 constraint
cB basic constants
variables x1 x2 x3 x4 x5
3 x3 1/2 1 1 1/2 4
1 x5 5/2 3 –1/2 1 3
cT 1 –4 0 –2 0 Z = 15
x 3 = 4, x 5 = 3
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 32
THE SIMPLEX TABLEAU
optimal
6 1 2 6
x1 + x2 − x4 + x5 =
5 5 5 5
and construct the corresponding tableau
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 35
THE SIMPLEX TABLEAU
cj 5 2 3 –1 1 constraint
cB
basic constants
x1 x2 x3 x4 x5
variables
3 x3 2/5 1 3/5 – 1/5 17/5
16.2 > 15
cj ≤ 0 implies optimality
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 36
SIMPLEX TABLEAU EXAMPLE
max Z = 3 x 1 + 2x 2
s .t .
−x1 + 2x2 ≤ 4
3 x1 + 2x2 ≤ 14
x1 − x2 ≤ 3
x1 ≥ 0 x 2 ≥ 0
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 37
SIMPLEX TABLEAU EXAMPLE
We put this problem into standard form:
max Z = 3 x 1 + 2 x 2
canonical form
s .t .
⎫
−x1 + 2 x 2 + x 3 = 4 ⎪
⎪⎪
3 x1 + 2 x 2 + x4 = 14 ⎬
⎪
x1 − x 2 + x5 = 3 ⎪
⎪⎭
x 1, … , x 5 ≥ 0
x 3 , x 4 , x 5 are fictitious variables
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 38
SIMPLEX TABLEAU EXAMPLE
cj 3 2 0 0 0 constraint
cB basic
variables x1 x2 x3 x4 x5 constants
0 x3 –1 2 1 4
0 x4 3 2 1 14
0 x5 1 –1 1 3
cT 3 2 0 0 0 Z = 0
c j = c j − ( c BT • column corresponding to x j )
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 39
SIMPLEX TABLEAU EXAMPLE
The data in c T indicates that the highest relative
profits correspond to x 1 so want to make x 1 a
basic variable
To bring x 1 into the basis requires to evaluate
⎧ 14 ⎫
min ⎨∞ , , 3⎬ = 3
⎩ 3 ⎭
and so x 1 replaces x 5 with the value 3
We evaluate the basic variable at the adjacent
basic feasible solution and convert into canonical
form; the new tableau becomes
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 40
SIMPLEX TABLEAU EXAMPLE
cj 3 2 0 0 0 constraint
cB basic
variables x1 x2 x3 x4 x5 constants
0 x3 1 1 1 7
0 x4 5 1 –3 5
3 x1 1 –1 1 3
cT 0 5 0 0 –3 Z = 9
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 41
SIMPLEX TABLEAU EXAMPLE
components
c j = c j −( c T
B i column corresponding to x j )
for each nonbasic variable x j
definition
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 42
SIMPLEX TABLEAU EXAMPLE
The calculations give
c 1 = 0 by definition since x 1 is in the basis
⎡ 1 ⎤
⎢ ⎥ indicates possible
c2 = 2 − ⎡⎣0 0 3⎤⎦ ⎢ 5 ⎥ = 5
⎢ ⎥ improvement
⎣− 1 ⎦
c 3 = 0 by definition since x 3 is in the basis
c 4 = 0 by definition since x 4 is in the basis
⎡ 1 ⎤
⎢ ⎥
c 5 = 0 − ⎡⎣0 0 3⎤⎦ ⎢ − 3 ⎥ = − 3
⎢ ⎥
⎣ 1 ⎦
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 43
SIMPLEX TABLEAU EXAMPLE
cj 3 2 0 0 0 constraint
cB basic
x1 x2 x3 x4 x5 constants
variables
0 x3 1 –1/5 8/5 6
2 x2 1 1/5 –3/5 1
3 x1 1 1/5 2/5 4
cT 0 0 0 –1 Z = 14
c j≤ 0∀ j ⇒ optimum
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 45
SIMPLEX TABLEAU EXAMPLE
for x 1, x 2 and x 3
x4 x5
canonical form
5 5
x2 + 1
x4 − 2
x5
⎪
= 1⎬
5 5
x1 + 1
x4 + 2
x5
⎪
= 4⎭
5 5
given by
x4 = x5 = 0
x3 = 6
x2 = 1
x1 = 4
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 46
LINEAR PROGRAMMING EXAMPLE
s .t .
− x1 + 2x2 ≤ 4
3 x1 + 2 x 2 ≤ 14
x1 − x2 ≤ 3
x1 ≥ 0 x2 ≥ 0
The graphical representation corresponds to
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 47
LINEAR PROGRAMMING EXAMPLE
x2 = 4
2 x2
+
-x
D
3
3
=
3x 1
2
- x
+
E
3x 1
2x 2
2
1
-x
3x 1
=1
tableau 3
2x 2
4
+
2x 2
1 =
Z C
=
=9
Z
tableau 1
=3
B x1
A 1 2 3 tableau 2
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 48
LINEAR PROGRAMMING EXAMPLE
cj 3 2 0 0 0 constraint
cB basic
variables x1 x2 x3 x4 x5 constants
cT 0 0 0 –1 0 Z = 14
cj ≤ 0 ∀ j
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 51
LINEAR PROGRAMMING EXAMPLE
5 13 15
x1 = , x2 = , x3 = x4 = 0, x5=
2 4 4
cj ≤ 0 ∀ j
s .t .
Ax = b
x ≥ 0
In the simplex scheme, replace the optimality
check by the following : if each coefficient c j is ≥ 0
stop; else, select the nonbasic variable with the
most negative value in c to become the new basic
variable
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 54
MINIMIZATION LP
min Z = cT x max Z ′ = (− c T ) x
s.t . s.t .
Ax = b Ax = b
x ≥ 0 x ≥ 0
with the solutions of Z and Z ′ related by
min{ Z } = − max { Z ′}
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 55
COMPLICATIONS IN THE SIMPLEX
METHODOLOGY
Two variables x j and x k are tied in the selection
of the nonbasic variables to replace a current basic
variable when c j = c k ; the choice of the new
nonbasic variable to enter the basis is arbitrary
Two or more constraints may give rise to the
same minimum ratio value in selecting the basic
variable to be replaced
We consider the example of the following tableau
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 56
COMPLICATIONS IN THE SIMPLEX
METHODOLOGY
cj 0 0 0 2 0 3/2 constraint
c B basic
x1 x2 x3 x4 x5 x6 constants
variables
0 x1 1 1 –1 0 2
0 x2 1 2 0 1 4
0 x3 1 1 1 1 3
cT 0 0 0 2 0 3/2 Z = 0
cj 0 0 0 2 0 3/2 constraint
c B basic
x1 x2 x3 x4 x5 x6 constants
variables
2 x4 1 1 –1 2
0 x2 –2 1 2 1 0
0 x3 –1 1 1 1 1
cT –2 0 0 0 0 3/2 Z =4
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 59
COMPLICATIONS IN THE SIMPLEX
METHODOLOGY
x 1 = 0, x 2 = 0, x 3 = 1, x 4 = 2, x 5 = 0, and x 6 = 0 ,
cj 0 0 0 2 0 3/2 constraint
c B basic
x1 x2 x3 x4 x5 x6 constants
variables
2 x4 1/2 1 1/2 2
0 x5 –1 1/2 1 1/2 0
0 x3 1 –1 1 0 1
cT 0 –1 0 0 0 1/2 Z =4
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 62
DEGENERACY
the logical choice being the nonbasic variable x 6 to
enter the basis; this leads to finding the limiting
constraint from two equations
1
x6 = 2 − x4
2
1
x6 = 0 − x5
2
and no constraint in the third equation; thus
x 6 = min {4, 0 , ∞ }
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 63
DEGENERACY
max Z = 2 x1 + 3 x 2
s.t .
x1 − x2 + x3 = 2
−3 x1 + x2 + x4 = 4
x i ≥ 0, i = 1, ... ,4
ECE 307 © 2005 – 2009 George Gross, University of Illinois at Urbana-Champaign, All Rights Reserved. 65
MINIMUM RATIO RULE
COMPLICATIONS
cj 2 3 0 0 constraint
cB basic
variables x1 x2 x3 x4 constants
0 x3 1 –1 1 2
0 x4 –3 1 1 4
cT 2 3 0 0 Z = 0
3 x2 –3 1 1 4
cT 11 0 0 –3 Z = 12