66ccff
单纯形法是解线性规划问题(LP)的最经典方法,很多人都了解单纯形法是用单纯形表来进行求解的,但是不了解背后的原理。
这篇博文介绍单纯型表的直觉。
对于这样的一个线性规划问题:
x
1
,
x
2
≥
0
x_{1},x_{2}\geq0
x1?,x2?≥0
x
1
≤
3000
x_1 \le 3000
x1?≤3000
x
2
≤
4000
x_2 \le 4000
x2?≤4000
x
1
+
x
2
≤
5000
x_1+x_2 \le 5000
x1?+x2?≤5000
max
?
1.2
x
1
+
1.7
x
2
\max 1.2x_1+1.7 x_2
max1.2x1?+1.7x2?
可以对每一个不等式引入松弛变量:
紧 : x 1 , x 2 ,松: s 1 , s 2 , s 3 紧:x_1,x_2,松:s_1,s_2,s_3 紧:x1?,x2?,松:s1?,s2?,s3?
x
1
,
x
2
,
s
1
,
s
2
,
s
3
≥
0
x_{1},x_{2},s_1,s_2,s_3\geq0
x1?,x2?,s1?,s2?,s3?≥0
x
1
+
s
1
=
3000
x_1+\red{s_1}= 3000
x1?+s1?=3000
x
2
+
s
2
=
4000
x_2+\red{s_2}= 4000
x2?+s2?=4000
x
1
+
x
2
+
s
3
=
5000
x_1+x_2 +\red{s_3}= 5000
x1?+x2?+s3?=5000
max
?
1.2
x
1
+
1.7
x
2
\max 1.2x_1+1.7 x_2
max1.2x1?+1.7x2?
从(0,0)开始
紧 : x 1 , x 2 ,松: s 1 , s 2 , s 3 紧:x_1,x_2,松:s_1,s_2,s_3 紧:x1?,x2?,松:s1?,s2?,s3?
x 1 , x 2 , s 1 , s 2 , s 3 ≥ 0 x_{1},x_{2},s_1,s_2,s_3\geq0 x1?,x2?,s1?,s2?,s3?≥0
R
H
S
都用基变量表示
RHS都用基变量表示
RHS都用基变量表示
s
1
=
3000
?
x
1
s_1=3000-x_1
s1?=3000?x1?
s
2
=
4000
?
x
2
s_2=4000-x_2
s2?=4000?x2?
s
3
=
5000
?
x
1
?
x
2
s_3=5000-x_1-x_2
s3?=5000?x1??x2?
max
?
1.2
x
1
+
1.7
x
2
\max 1.2x_1+1.7 x_2
max1.2x1?+1.7x2?
进行一次迭代之后:( x 2 x_2 x2?松, s 2 s_2 s2?紧)
紧 : x 1 , s 2 ,松: x 2 , s 1 , s 3 紧:x_1,\red{s_2},松:\blue{x_2},s_1,s_3 紧:x1?,s2?,松:x2?,s1?,s3?
x 1 , x 2 , s 1 , s 2 , s 3 ≥ 0 x_{1},x_{2},s_1,s_2,s_3\geq0 x1?,x2?,s1?,s2?,s3?≥0
R
H
S
都用基变量表示
RHS都用基变量表示
RHS都用基变量表示
s
1
=
3000
?
x
1
s_1=3000-x_1
s1?=3000?x1?
x
2
=
4000
?
s
2
\blue{x_2} = 4000-\red{s_2}
x2?=4000?s2?
s
3
=
1000
?
x
1
+
s
2
s_3=\green{1000 -x_1 + s_2}
s3?=1000?x1?+s2?
max
?
1.2
x
1
+
1.7
(
4000
?
s
2
)
=
1.2
x
1
+
6800
?
1.7
s
2
\max 1.2x_1+1.7 \green{(4000-s_2)} = 1.2x_1 + 6800 - 1.7s_2
max1.2x1?+1.7(4000?s2?)=1.2x1?+6800?1.7s2?
再进行一次迭代:( x 1 x_1 x1?松, s 3 s_3 s3?紧)
紧 : s 3 , s 2 ,松: x 2 , x 1 , s 1 紧:\red{s_3},\red{s_2},松:\blue{x_2},\blue{x_1},s_1 紧:s3?,s2?,松:x2?,x1?,s1?
x 1 , x 2 , s 1 , s 2 , s 3 ≥ 0 x_{1},x_{2},s_1,s_2,s_3\geq0 x1?,x2?,s1?,s2?,s3?≥0
R
H
S
都用基变量表示
RHS都用基变量表示
RHS都用基变量表示
x
1
=
3000
?
s
1
x_1 = 3000 -s_1
x1?=3000?s1?
x
2
=
4000
?
s
2
\blue{x_2} = 4000-\red{s_2}
x2?=4000?s2?
x
1
=
1000
?
s
3
+
s
2
\blue{x_1} = 1000 -s_3+s_2
x1?=1000?s3?+s2?
max
?
1.2
x
1
+
6800
?
1.7
s
2
=
1.2
(
1000
?
s
3
+
s
2
)
+
6800
?
1.7
s
2
=
8000
?
1.2
s
3
?
0.5
s
2
\max 1.2x_1 + 6800 - 1.7s_2 = 1.2\green{(1000 -s_3+s_2)} + 6800 - 1.7s_2 =\purple{ 8000 -1.2s_3-0.5s_2}
max1.2x1?+6800?1.7s2?=1.2(1000?s3?+s2?)+6800?1.7s2?=8000?1.2s3??0.5s2?
注意到:因为变量前面的系数都小于0,因此无法继续改进,我们此时达到了最优值 8000