本文主要是介绍单纯形法迭代原理及解的判定,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
写于:2024年1月4日晚
修改:
基于以下线性规划做分析, max z = ∑ j = 1 n c j x j s.t. { ∑ j = 1 n a i j x j ≤ b i ( i = 1 , 2 , … , m ) x j ≥ 0 ( j = 1 , 2 , … , n ) \begin{aligned} & \max \mathrm{z}=\sum_{j=1}^n c_j x_j \\ & \text { s.t. }\left\{\begin{array}{l} \sum_{j=1}^n a_{i j} x_j \leq b_i(i=1,2, \ldots, m) \\ x_j \geq 0(j=1,2, \ldots, n) \end{array}\right. \end{aligned} maxz=j=1∑ncjxj s.t. {∑j=1naijxj≤bi(i=1,2,…,m)xj≥0(j=1,2,…,n)
标准化上述线性规划,得: max z = ∑ j = 1 n c j x j s.t. { ∑ j = 1 n a i j x j + x i ′ = b i ( i = 1 , 2 , … , m ) x j ≥ 0 ( j = 1 , 2 , … , n ) \begin{aligned} & \max \mathrm{z}=\sum_{j=1}^n c_j x_j \\ & \text { s.t. }\left\{\begin{array}{l}\sum_{j=1}^n a_{i j} x_j+x_i^{\prime}=b_i(i=1,2, \ldots, m) \\ x_j \geq 0(j=1,2, \ldots, n)\end{array}\right. \end{aligned} maxz=j=1∑ncjxj s.t. {∑j=1naijxj+xi′=bi(i=1,2,…,m)xj≥0(j=1,2,…,n)
为减少变量数以便于表示,将线性规划调整(主要是将松弛变量用 x i x_i xi 表示,其余变量用 x j x_j xj 表示)为 max z = ∑ j = 1 n c j x j s.t. { ∑ i = 1 m P i x i + ∑ j = m + 1 n P j x j = b x j ≥ 0 ( j = 1 , 2 , … , n ) \begin{aligned} & \max \mathrm{z}=\sum_{j=1}^n c_j x_j \\ & \text { s.t. }\left\{\begin{array}{l} \sum_{i=1}^m \mathbf{P}_i x_i+\sum_{j=m+1}^n \mathbf{P}_j x_j=\mathbf{b} \\ x_j \geq 0(j=1,2, \ldots, n) \end{array}\right. \end{aligned} maxz=j=1∑ncjxj s.t. {∑i=1mPixi+∑j=m+1nPjxj=bxj≥0(j=1,2,…,n)
其中, P i \mathbf{P}_i Pi 为 m 维标准单位列向量, P j = [ a 1 , j a 2 , j … a m , j ] \mathbf{P}_j=\left[\begin{array}{c} a_{1, j} \\ a_{2, j} \\ \ldots \\ a_{m, j} \end{array}\right] Pj= a1,ja2,j…am,j , P = [ 1 0 … 0 a 1 , m + 1 … a 1 n 0 1 … 0 a 2 , m + 1 … a 2 n … … … 0 a l , m + 1 a l j … 0 0 … 1 a m , m + 1 … a m n ] \mathbf{P}=\left[\begin{array}{cccc:ccc}1 & 0 & \ldots & 0 & a_{1, m+1} & \ldots & a_{1 n} \\ 0 & 1 & \ldots & 0 & a_{2, m+1} & \ldots & a_{2 n} \\ \ldots & \ldots & \ldots & 0 & a_{l, m+1} & a_{l j} & \ldots \\ 0 & 0 & \ldots & 1 & a_{m, m+1} & \ldots & a_{m n}\end{array}\right] P= 10…001…0…………0001a1,m+1a2,m+1al,m+1am,m+1……alj…a1na2n…amn , b = [ b 1 b 2 … b m ] \mathbf{b}=\left[\begin{array}{c}b_1 \\ b_2 \\ \ldots \\ b_m\end{array}\right] b= b1b2…bm 。
单纯形法–迭代原理
设初始基变量中前 m \mathrm{m} m 个为基变量,即 X 0 = ( x 1 0 , x 2 0 , … x m 0 , 0 , … , 0 ) T \mathbf{X}^0=\left(x_1^0, x_2^0, \ldots x_m^0, 0, \ldots, 0\right)^{\mathrm{T}} X0=(x10,x20,…xm0,0,…,0)T。
将 X 0 \mathbf{X}^0 X0 代入约束方程,得到 ∑ i = 1 m P i x i 0 = b \sum_{i=1}^m \mathbf{P}_i x_i^0=\mathbf{b} ∑i=1mPixi0=b, P j = ∑ i = 1 m P i a i j ( j = m + 1 , m + 2 , … , n ) \mathbf{P}_j=\sum_{i=1}^m \mathbf{P}_i a_{i j}(j=m+1, m+2, \ldots, n) Pj=∑i=1mPiaij(j=m+1,m+2,…,n) 。
再令 θ > 0 \theta>0 θ>0, θ ( P j − ∑ i = 1 m P i a i j ) = 0 \theta\left(\mathbf{P}_j-\sum_{i=1}^m \mathbf{P}_i a_{i j}\right)=0 θ(Pj−∑i=1mPiaij)=0 。
由 ∑ i = 1 m P i x i 0 = b \sum_{i=1}^m \mathbf{P}_i x_i^0=\mathbf{b} ∑i=1mPixi0=b 和 θ ( P j = ∑ i = 1 m P i a i j ) = 0 \theta\left(\mathbf{P}_j=\sum_{i=1}^m \mathbf{P}_i a_{i j}\right)=0 θ(Pj=∑i=1mPiaij)=0 相加,可得 ∑ i = 1 m P i x i 0 + θ ( P j − ∑ i = 1 m P i a i j ) = ∑ i = 1 m ( x i 0 − θ a i j ) P i + θ P j = b \sum_{i=1}^m \mathbf{P}_i x_i^0+\theta\left(\mathbf{P}_j-\sum_{i=1}^m \mathbf{P}_i a_{i j}\right)=\sum_{i=1}^m\left(x_i^0-\theta a_{i j}\right) \mathbf{P}_i+\theta \mathbf{P}_j=\mathbf{b} ∑i=1mPixi0+θ(Pj−∑i=1mPiaij)=∑i=1m(xi0−θaij)Pi+θPj=b。
即存在 X 1 = ( x 1 1 − θ a l j , x 2 1 − θ a 2 j , … x m 1 − θ a m j , 0 , 0 , … , θ , … , 0 ) T \mathbf{X}^1=\left(x_1^1-\theta a_{l j}, x_2^1-\theta a_{2 j}, \ldots x_m^1-\theta a_{m j}, 0,0, \ldots, \theta, \ldots, 0\right)^{\mathrm{T}} X1=(x11−θalj,x21−θa2j,…xm1−θamj,0,0,…,θ,…,0)T 满足约束 ∑ j = 1 n P j x j = b \sum_{j=1}^n \mathbf{P}_j x_j=\mathbf{b} ∑j=1nPjxj=b。
若 X 1 \mathbf{X}^1 X1 为基可行解,还需满足:所有分量全部大于等于 0;非零分量个数小于等于 m \mathrm{m} m 个。也就是需要使 x i 1 − θ a i j ( i = 1 , 2 , … , m ) x_i^1-\theta a_{i j}(i=1,2, \ldots, m) xi1−θaij(i=1,2,…,m) 中至少存在一个等于 0,其余均大于 0 。已知 θ > 0 \theta>0 θ>0,若存在一个 a i j > 0 a_{i j}>0 aij>0,且 θ = min { x i a i j ∣ a i j > 0 } \theta=\min \left\{\frac{x_i}{a_{i j}} \mid a_{i j}>0\right\} θ=min{aijxi∣aij>0},即可满足条件。
基于以上分析,单纯形表中迭代解操作为: x l x_l xl 作为换出变量, x j x_j xj 作为换入变量,通过行倍乘化 a l j a_{lj} alj 为 1,再将 P j \mathbf{P}_j Pj 化为标准单位向量。
P = [ 1 0 … 0 0 0 a 1 , m + 1 a 1 , m + 2 … a 1 , j a 1 , n − 1 a 1 , n 0 1 … 0 0 0 a 2 , m + 1 a 2 , m + 2 … a 2 , j a 2 , n − 1 a 2 , n 0 0 … … 0 0 a 3 , m + 1 a 3 , m + 2 … … a 3 , n − 1 a 3 , n … … … 1 … … … … … [ a l j ] … … 0 0 … … 1 0 a m − 1 , m + 1 a m − 1 , m + 2 … … a m − 1 , n − 1 a m − 1 , n 0 0 … 0 0 1 a m , m + 1 a m , m + 2 … a m , j a m , n − 1 a m , n ] ( m ∗ n ) \mathbf{P}=\left[\begin{array}{cccccc:cccccc} 1 & 0 & \ldots & 0 & 0 & 0 & a_{1, m+1} & a_{1, m+2} & \ldots & a_{1, j} & a_{1, n-1} & a_{1, n} \\ 0 & 1 & \ldots & 0 & 0 & 0 & a_{2, m+1} & a_{2, m+2} & \ldots & a_{2, j} & a_{2, n-1} & a_{2, n} \\ 0 & 0 & \ldots & \ldots & 0 & 0 & a_{3, m+1} & a_{3, m+2} & \ldots & \ldots & a_{3, n-1} & a_{3, n} \\ \ldots & \ldots & \ldots & 1 & \ldots & \ldots & \ldots & \ldots & \ldots & {\left[a_{l j}\right]} & \ldots & \ldots \\ 0 & 0 & \ldots & \ldots & 1 & 0 & a_{m-1, m+1} & a_{m-1, m+2} & \ldots & \ldots & a_{m-1, n-1} & a_{m-1, n} \\ 0 & 0 & \ldots & 0 & 0 & 1 & a_{m, m+1} & a_{m, m+2} & \ldots & a_{m, j} & a_{m, n-1} & a_{m, n} \end{array}\right]_{\left(m* n\right)} P= 100…00010…00………………00…1…0000…10000…01a1,m+1a2,m+1a3,m+1…am−1,m+1am,m+1a1,m+2a2,m+2a3,m+2…am−1,m+2am,m+2………………a1,ja2,j…[alj]…am,ja1,n−1a2,n−1a3,n−1…am−1,n−1am,n−1a1,na2,na3,n…am−1,nam,n (m∗n)
单纯形法–最优性检验
检验当前解是否为最优解,若不是确定换入换出变量。
由线性规划可得:
x i = b i − ( a i , m + 1 x m + 1 + a i , m + 2 x m + 2 + … + a i , n x n ) = b i − ∑ j = m + 1 n a i j x j x_i=b_i-\left(a_{i, m+1} x_{m+1}+a_{i, m+2} x_{m+2}+\ldots+a_{i, n} x_n\right)=b_i-\sum_{j=m+1}^n a_{i j} x_j xi=bi−(ai,m+1xm+1+ai,m+2xm+2+…+ai,nxn)=bi−∑j=m+1naijxj
z = ∑ j = 1 n c j x j = ∑ i = 1 m c i x i + ∑ j = m + 1 n c j x j = ∑ i = 1 m c i ⋅ ( b i − ∑ j = m + 1 n a i j x j ) + ∑ j = m + 1 n c j x j = ∑ i = 1 m c i b i − ∑ i = 1 m c i ∑ j = m + 1 n a i j x j + ∑ j = m + 1 n c j x j = ∑ i = 1 m c i b i − ∑ j = m + 1 n ( ∑ i = 1 m c i ⋅ a i j x j − c j ⋅ x j ) = ∑ i = 1 m c i b i + ∑ j = m + 1 n ( c j − ∑ i = 1 m c i a i j ) x j \begin{aligned} & z=\sum_{j=1}^n c_j x_j=\sum_{i=1}^m c_i x_i+\sum_{j=m+1}^n c_j x_j=\sum_{i=1}^m c_i \cdot\left(b_i-\sum_{j=m+1}^n a_{i j} x_j\right)+\sum_{j=m+1}^n c_j x_j=\sum_{i=1}^m c_i b_i-\sum_{i=1}^m c_i \sum_{j=m+1}^n a_{i j} x_j+\sum_{j=m+1}^n c_j x_j \\ & =\sum_{i=1}^m c_i b_i-\sum_{j=m+1}^n\left(\sum_{i=1}^m c_i \cdot a_{i j} x_j-c_j \cdot x_j\right)=\sum_{i=1}^m c_i b_i+\sum_{j=m+1}^n\left(c_j-\sum_{i=1}^m c_i a_{i j}\right) x_j \end{aligned} z=j=1∑ncjxj=i=1∑mcixi+j=m+1∑ncjxj=i=1∑mci⋅(bi−j=m+1∑naijxj)+j=m+1∑ncjxj=i=1∑mcibi−i=1∑mcij=m+1∑naijxj+j=m+1∑ncjxj=i=1∑mcibi−j=m+1∑n(i=1∑mci⋅aijxj−cj⋅xj)=i=1∑mcibi+j=m+1∑n(cj−i=1∑mciaij)xj
记 z 0 = ∑ i = 1 m c i b i \mathrm{z}_0=\sum_{i=1}^m c_i b_i z0=∑i=1mcibi、 z j = ∑ i = 1 m c i a i j z_j=\sum_{i=1}^m c_i a_{i j} zj=∑i=1mciaij,于是, z = z 0 + ∑ j = m + 1 n ( c j − z j ) x j = z 0 + ∑ j = m + 1 n σ j x j \mathrm{z}=\mathrm{z}_0+\sum_{j=m+1}^n\left(c_j-z_j\right) x_j=z_0+\sum_{j=m+1}^n \sigma_j x_j z=z0+∑j=m+1n(cj−zj)xj=z0+∑j=m+1nσjxj
根据如下流程图检验解的情况:
这篇关于单纯形法迭代原理及解的判定的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!