Simplex Method

2. Simplex Method – standard form
Key concept:Change constraints from inequality to equality
then find the solutions of the linear equations’ system.
x1 + x2  3
x1 - 2x2 ≤ 4
加上slack variable ( 0)
使得等式成立
x1 - 2x2 + s1 = 4
x1 + x2 – s2 = 3
Maximize f = 4x1 + 3x2
x1 + x2 ≤ 3
2x1 - x2  3
7/14/2017
x1  0, x2  0
加上surplus variable ( 0)
使得等式成立
Maximize f = 4x1 + 3x2
標準化
x1 + x2 + s1
=3
2x1 - x2
- s2 = 3
x1, x2, s1, s2  0
1
a11xc1 1+x1a12
+ a+1ncxnnx=
+ xc22x+2 …
+…
n b1
2.1 The steps of Simplex Method
1. Transform into standard form.
2. Establish simplex tableau.
目標函數
的係數
3. Choose the basic variables xB for initial
feasible solution. (正常狀況下是slack var.s)
Max
4. Calculate the cost fj of each xj to produce i
objective benefit.
5. Calculate the pure objective benefit Cj – fj 1
of each xj under the current xB.
6. Choose the max benefit producer xj* (the
xj with max Cj – fj) as pivot variable.
2
Simplex Tableau
C1
C2
.. Cj ..
Cn
cB
xB
x1
x2
.. xj*..
xn
bi
i
cB1
xB1
a11
a12
…
a1n
b1
b1
a1j
cB2
xB2
a21
a22
…
a2n
b2
b2
a2j
amn
bm
bm
amj
技術矩陣
7. Do the ratio test i = bi/aijof each xBi.
…
… … …
Replace xB* (the xB having min i) with xj*.
8. Do pivoting (elementary row operations),
m cBm xBm am1 am2
such that aij* = 1 (aij*: the coefficient in
xB*’s row and xj*’s column), and such
that the other coefficients in xj*’s column
∑icBiaij
fj
are 0. ------ A new tableau is obtained.
Cj-fj
…
9. Repeat from 4. until no Cj – fj > 0. x 在目標函
B
數上的係數
7/14/2017
∑icBibi
目標函數值
2
2.2 Simplex method’s example
Max f = 12x1 + 8x2 + 0s1 + 0s2 + 0s3
Max f = 12x1 + 8x2
5x1 + 2x2 + s1
step 1
5x1 + 2x2 ≤ 150
2x1 + 3x2
step 2
2x1 + 3x2 ≤ 100
4x1 + 2x2 ≤ 80
x1, x 2 
0
Cj 12
4x1 + 2x2
step 3
step 4
step 5
i
cB
xB
8
0
0
= 150
+ s2
= 100
+ s3 = 80
x 1 , x 2 , s1 , s 2 , s3  0
0
bi
i
0
150
30
1
0
100
50
0
0
1
80
20
0
0
0
0 ∑icBibi=0
8
0
0
0
x1
x2 s1 s2 s3
1 cB1=0 xB1=s1
5
2
1
0
2 cB2=0 xB2=s2
2
3
0
3 cB3=0 xB3=s3
4
2
fj
0
Cj-fj
12
step 6
step 7
step 8
step 9
7/14/2017
pivot Variable
x1
ratio
test
pivoting
Row 3
用x1換s3
x
[N|B] x = [b]
Initial
N
-1
Feasible
B
NX
+
X
B-1[b]
NXN +NBXBB==[b]
Solution
B
3
Max f = 12x1 + 8x2 + 0s1 + 0s2 + 0s3
2.2 Simplex method’s example – cont’s
5x1 + 2x2 + s1
= 150
2x1 + 3x2
+ s2
= 100
4x1 + 2x2
+ s3 = 80
Pivoting
x 1 , x 2 , s1 , s2 , s3  0
Loop 1
step 1
step 2
step 3
step 4
step 5
step 6
step 7
step 8 step 9
Loop 2
step 1
step 2
step 3
step 4
step 5
step 6
step 7
step 8
Cj
12
8
0
0
0
s3
step 9
i
cB
xB
x1
x2
s1
s2
1
cB1=0
xB1=s1
50
-0.5
2
1
0
150
-1.25
50
0
2
cB2=0
xB2=s2
20
32
0
1
-0.5
0
3 ccB3B3=12
=0 xB3=x
=s1
41
0.5
2
0
0
0.25
1
fj
0
12
06
0
0
03
Cj-fj
12
0
82
0
0
-3
0
7/14/2017
bi
i
-
-5*Row3+Row1
100
60
30
-2*Row3+Row2
80
20
40
Row3/4
∑
∑icicBiBibbi=240
i=0
4
2.2 Simplex method’s example – cont’s
step 1
step 2
Cj
step 3
step 4
step 5
12
8
0
0
0
step 6
step 7
step 8
step 9
i
cB
xB
x1
x2
s1
s2
s3
bi
1
cB1=0
xB1=s1
0
0
1
0.25
-1.375
65
2
cB2=8
xB2=x2
0
1
0
0.5
-0.25
30
3
cB3=12 xB3=x1
1
0
0
-0.25
0.375
5
fj
12
8
0
1
2.5
Cj-fj
0
0
0
-1
-2.5
沒有大於0的值
7/14/2017
i
∑icBibi=300
x1 = 5,
x2 = 30,
Max f =300
5
2.3 Summary for simplex method
Maximize f = C1x1 + C2x2 + … + Cnxn
a11x1 + a12x2 + … + a1nxn = b1
a21x1 + a22x2 + … + a2nxn = b2
……
ai1x1 + ai2x2 + … + ainxn = bi
……
am1x1 + am2x2 + … + amnxn = bm
x1, x2, …, xn  0
7/14/2017
C1
C2
.. Cj ..
Cn
i
cB
xB
x1
x2
.. xj*..
xn
bi
i
1
cB1
xB1
a11
a12
…
a1n
b1
b1
a1j
2
cB2
xB2
a21
a22
…
a2n
b2
…
…
…
amn
bm
m cBm xBm
…
am1
am2
fj
∑icBiaij
Cj-fj
…
∑icBibi
6
2.3.1 simplex method example again (example from Topic 1)
Max f = 1.5xa + 1.2xg
Max f = 1.5xa + 1.2xg
1.5xa + 2xg ≤ 1200
1.5xa + 2xg + s1
標準化
3xa + 3xg ≤ 2100
6xa + 3xg ≤ 3600
xa, xg  0
Cj 1.5 1.2
i
cB
xB
3xa + 3xg
+ s2
= 2100
6xa + 3xg
+ s3 = 3600
xa, xg, s1, s2, s3  0
0
0
0
xg
s1
s2
s3
1 cB1=0 xB1=s1 1.5
2
1
0
0
1200 800
2 cB2=0 xB2=s2
3
3
0
1
0
2100 700
3 cB3=0 xB3=s3
6
3
0
0
1
3600
0
0
0
0
0
∑icBibi=0
0
0
0
Cj-fj
1.5 1.2
bi
i
xa
fj
7/14/2017
= 1200
600
7
2.3.1 simplex method example again (cont’)
Cj 1.5
1.2
0
0
0
cB
xB
xa
xg
s1
s2
1
cB1=0
xB1=s1
0
cB2=0
xB2=s2
-1/4
2
3/2
3*
1
2
0
1.5
03
0
1
xB3=xa
16
0
0
fj
1/2
3
1.5
0 0.75
0
0
0
-1/2
0
2100
300 200 (-3)+
?
1/6
600 1200
1
3600
6
0.25
0 ∑icBibi=900
Cj-fj
1.5
0 0.45
1.2
0
0
0 1.5xg +s2-0.5s3= 300
-0.25
3 cB3=1.5
Cj 1.5
1.2
0
0
s3
bi
-1/4
300
0
1200
i
i
–
s2= 300-1.5xg+0.5s3
s2 /1.5= 300/1.5-xg+(0.5/1.5)s3
0 xg= 200-2s2 /3 +s3/3 <<< i=2
xg= 1200-2xa+(1/3)s3<<< i=3
s3 s2對目標函數值最沒貢獻,
bi
i
所
i
cB
xBB
xa
xg
s1
s2
1
cB1=0
xB1
B1=s11
0
-1/4
0
1
0
1/6
2 cB2=1.2
xB2
B2=xgg
0
1
0
2/3 -1/3
200
3 cB3=1.5
xB3=xaa
1
1/2
0
0
0
-1/3
1/6
1/3
1.5 0.75
1.2
0
0
0.9
0.25
0.1
600
500
∑icBibi=900
=990
0
0 -0.25
-0.9
-0.1
fjj
7/14/2017
Cjj-fjj
0
0.45
0
(-1.5)+
-1/4以換成有貢獻的x
300
-1/3
350
g
8
fj 與Cj-fj是什麼?
5x1 + 2x2 + s1 = 150
s1 = 150 - 5x1 - 2x2
x1每增加1
每個s1就會減少5
2x1 + 3x2 + s2 = 100
s2 = 100 - 2x1 - 3x2
x1每增加1
每個s2就會減少2
4x1 + 2x2 + s3 = 80
s3 = 80 - 4x1 - 2x2
x1每增加1
每個s3就會減少4
fj 是xj生產basic var.s的單位成本
Cj-fj 是xj當basic var.s後可創造的單位利益
7/14/2017
9