2.8 单纯形法步骤
下面以极小化问题为例给出单纯形法计算步骤.
求解线性规划标准形的单纯形法
Step 1 确定初始基本可行解.
Step 2 检验各非基变量的检验数.如果\sigma_j≥0(j=m+1,⋯,1),则当前的基本可行解就是最优解,算法结束;否则转Step 3.
Step 3 如果存在\sigma_j<0使得其对应变量x_j的系数列向量\mathbf p_j≤,即\mathbf p_j的每个分量均为非正数,则线性规划问题的解无界,算法结束;否则转Step 4.
Step 4 设\sigma_k=\displaystyle\min_j\{\sigma_j\}<0,选取x_k为入基变量.根据l=\mathop{\text{argmin}}\limits_i \left\{\theta_i=\displaystyle\frac{b_i'}{a_{ij}'}\Big|a_{ij}'>0 \right\}确定l,选取x_l为离基变量.转Step 5.
Step 5 以a_{lk}'为主元旋转运算,即利用行变换将第k个系数列向量变换为a_{lk}'=1,其它元素为0.转Step 2.
下面给出应用单纯形法求解问题(2.3.1)的完整过程.
例 1 用单纯形法求解
\begin{aligned} &\min z =-5x_1-2x_2\\ &\text{s.t.}\begin{cases} 30x_1+20x_2+x_3≤160\\ 5x_1+x_2≤15\\ x_1 ≤4\\ x_i≥0,~i=1,2,3 \end{cases}. \end{aligned}
解 通过引入3个非负松驰变量x_4,x_5,x_6,把模型标准化为
\begin{aligned} &\min z=-5x_1-2x_2\\ &\text{s.t.}\begin{cases} 30x_1+20x_2+x_3 + x_4&&=160\\ 5x_1+x_2 &+x_5 &=15\\ x_1 &&+x_6 =4\\ x_i≥0,~i=1,2,\cdots,6 \end{cases} \end{aligned},
则\mathbf A=\begin{pmatrix} 30 & 20 & 1 & 1& 0 &0\\5&1 & 0& 0 & 1 &0\\ 1 & 0 & 0 & 0 & 0&1\end{pmatrix},\mathbf b=\begin{pmatrix} 160\\15\\ 4\end{pmatrix},\mathbf c^\top=\begin{pmatrix} -5,-2,0,0,0,0\end{pmatrix}.
(1)确定初始基本可行解.
取基矩阵\mathbf B=(\mathbf p_4,\mathbf p_5,\mathbf p_6)=\begin{pmatrix} 1& 0 &0\\ 0 & 1 &0\\ 0 & 0&1\end{pmatrix},非基矩阵\mathbf N=(\mathbf p_1,\mathbf p_2,\mathbf p_3)=\begin{pmatrix} 30 & 20 & 1 \\5&1 & 0\\ 1 & 0 & 0 \end{pmatrix},则\mathbf{x_B}=(x_4,x_5,x_6)^\top,\mathbf{x_N}=(x_1,x_2,x_3)^\top,即
\begin{cases} x_4 = 160-(30x_1+20x_2+x_3)\\ x_5 = 15-(5x_1+x_2 )\\ x_6=4-x_1 \end{cases}.
而\mathbf{c_B}=(c_4,c_5,c_6)^\top=(0,0,0)^\top,\mathbf{c_N}=(c_1,c_2,c_3)^\top=(-5,-2,0)^\top.
令\mathbf{x_N}=\mathbf 0,则\mathbf{x_B}=(160,15,4)^\top,即\mathbf x^{(0)}=(0,0,0,160,15,4)^\top,代入目标函数得z_0=\mathbf{c^\top x}=0.
(2)检验各非基变量的检验数.
(\sigma_1,\sigma_2,\sigma_3)=\mathbf{c_N^\top}-\mathbf{c_B^\top}\mathbf{B}^{-1}\mathbf N=(-5,-2,0)-(0,0,0)\begin{pmatrix} 1& 0 &0\\ 0 & 1 &0\\ 0 & 0&1\end{pmatrix}\begin{pmatrix} 30 & 20 & 1 \\5&1 & 0\\ 1 & 0 & 0 \end{pmatrix}=(-5,-2,0),
其中\sigma_i<0(i=1,2),所以\mathbf{x_B}=(160,15,4)^\top不是最优解.
(3)此时\mathbf p_i\ge\mathbf 0(i=1,2),所以继续计算.因为\min\{\sigma_1,\sigma_2\}=\sigma_{\textcolor{red}{1}}=-5,故选择x_1进基;而
\theta=\displaystyle\min\left\{\frac{b_i}{a_{ik}}\Big|a_{ik}>0\right\}=\min\left\{\frac{160}{30},\frac{15}{5}\right\} =\frac{b_{\textcolor{red}{2}}'}{a_{\textcolor{red}{2}1}'}=5,
此时对应第2个基变量,其下标为5,故选择x_5离基.
(4)以a_{\textcolor{red}{21}}'为主元旋转运算.
\begin{aligned}\mathbf A&=\left(\begin{array}{c:c}\begin{matrix}30 & 20 & 1 & 1& 0 &0\\\textcolor{red}{5}&1 & 0& 0 & 1 &0\\ 1 & 0 & 0 & 0 & 0&1\end{matrix}&\begin{matrix}160\\50\\4 \end{matrix}\end{array}\right)\\&\rightarrow\left(\begin{array}{c:c}\begin{matrix}0 & 14 & 1 & 1& -6 &0\\\textcolor{red}{1}&1/5 & 0& 0 & 1/5 &0\\ 0 & -1/5 & 0 & 0 & -1/5&1\end{matrix}&\begin{matrix}70\\3\\1\end{matrix}\end{array}\right)\triangleq\mathbf A_1\end{aligned}\qquad\qquad,
此时得\mathbf x^{(1)}=(3,0,0,70,0,1)^\top,z_1=-15.
显然此时的目标函数值z_1比z_0下降了.
此时,从\mathbf A_1中取基矩阵\mathbf B=(\mathbf p_4,\mathbf p_1,\mathbf p_6)=\begin{pmatrix} 1& 0 &0\\ 0 & 1 &0\\ 0 & 0&1\end{pmatrix},\mathbf{x_B}=(x_4,x_1,x_6)^\top,非基矩阵\mathbf N=(\mathbf p_5,\mathbf p_2,\mathbf p_3)=\begin{pmatrix} -6 & 14 & 1 \\1/5&1/5 & 0\\ -1/5 & -1/5 & 0 \end{pmatrix},\mathbf{x_N}=(x_5,x_2,x_3)^\top,\mathbf{c_B}=(c_4,c_1,c_6)^\top=(0,-5,0)^\top,\mathbf{c_N}=(c_5,c_2,c_3)^\top=(0,-2,0)^\top.然后重复上面的(2)~(4).
因为非基变量检验数
\begin{aligned}(\sigma_5,\sigma_2,\sigma_3)&=\mathbf{c_N^\top}-\mathbf{c_B^\top}\mathbf{B}^{-1}\mathbf{N}\\&=(0,-2,0)-(0,-5,0)\begin{pmatrix} 1& 0 &0\\ 0 & 1 &0\\ 0 & 0&1\end{pmatrix}\begin{pmatrix} -6 & 14 & 1 \\1/5&1/5 & 0\\ -1/5 & -1/5 & 0 \end{pmatrix}\\&=(1,-1,0)\end{aligned},
其中只有\sigma_2=-1<0,所以x_2进基;又由增广矩阵\mathbf A'可知,\theta=\displaystyle\min\left\{\frac{70}{14},\frac{3}{1/5}\right\} =\frac{b_{\textcolor{red}{1}}'}{a_{\textcolor{red}{1}2}'},此时对应第1个基变量,其下标为4,可知\mathbf x_4离基.再以a_{\textcolor{red}{12}}为主元旋转运算.
\mathbf A_1=\left(\begin{array}{c:c}\begin{matrix}0 & 14 & 1 & 1& -6 &0\\{1}&1/5 & 0& 0 & 1/5 &0\\ 0 & -1/5 & 0 & 0 & -1/5&1\end{matrix}&\begin{matrix}70\\3\\1\end{matrix}\end{array}\right)\qquad\qquad\rightarrow\left(\begin{array}{c:c}\begin{matrix}0 & 1 & 1/14 & 1/14& -3/7 &0\\{1}&0 & -1/70& -1/70 & 0 &0\\ 0 & 0 & 1/70 & 1/70 & 1&1\end{matrix}&\begin{matrix}5\\2\\2\end{matrix}\end{array}\right)\triangleq\mathbf A_2,
得\mathbf x^{(2)}=(2,5,0,0,0,2)^\top,z_1=-20.
此时基变量为x_2,x_1,x_6,则非基变量x_3,x_4,x_5检验数
\begin{aligned}(\sigma_3,\sigma_4,\sigma_5)&=\mathbf{c_N^\top}-\mathbf{c_B^\top}\mathbf{B}^{-1}\mathbf{N}\\&=(0,0,0)-(-2,-5,0)\begin{pmatrix} 1& 0 &0\\ 0 & 1 &0\\ 0 & 0&1\end{pmatrix}\begin{pmatrix} 1/14 & 1/14& -3/7\\-1/70& -1/70 & 0\\ 1/70 & 1/70 & 1 \end{pmatrix}\\&=\displaystyle\left(\frac{1}{14},\frac{1}{14},0\right)\ge \mathbf 0,\end{aligned}
所以迭代停止,\mathbf x=(2,5,0)^\top为最优解,最优值z=-20.
图 2-3-1附录 / 附录程序显示了本例中单纯形法迭代过程.问题的可行域为三维空间的凸多面体,可以发现,每次迭代总是沿着可行域的边界搜索,即从凸多面体的一个顶点走向相邻的另一顶点.

图2-3-1单纯形法每次迭代总是沿着凸多面体的棱前进的
说明:对于目标函数极大化、约束为标准型的线性规划问题,在利用单纯形方法求解时,与极小化过程一致,不同之处是检验是否最优的判定准则和进基准则不同.即