利用修正单纯形法解线性规划问题(精).doc
《利用修正单纯形法解线性规划问题(精).doc》由会员分享,可在线阅读,更多相关《利用修正单纯形法解线性规划问题(精).doc(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品文档,仅供学习与交流,如有侵权请联系网站删除利用修正单纯形法解线性规划问题一 软件示意:二 代码说明:Dim A(1 To 3, 1 To 6) As Double 矩阵ADim a1(1 To 3) As Double 矩阵A的第一列向量Dim a2(1 To 3) As Double 矩阵A的第二列向量Dim a3(1 To 3) As Double 矩阵A的第三列向量Dim a4(1 To 3) As Double 矩阵A的第四列向量Dim a5(1 To 3) As Double 矩阵A的第五列向量Dim a6(1 To 3) As Double 矩阵A的第六列向量Dim B_(1
2、 To 3, 1 To 3) As Double 基矩阵B的逆矩阵Dim XB(1 To 3) As Double 基本可行解Dim b(1 To 3) As Double 右端向量bDim C(1 To 6) As Double 检验数Dim CB(1 To 3) As Double 基本可行解对应的检验数Dim (1 To 3) As Double 单纯形乘子矢量Dim r(1 To 6) As Double 检验矢量rDim r_min As Double 检验矢量最小值Dim k_sign As Integer 检验矢量最小值对应的位置Dim Y(1 To 3, 0 To 6) As
3、Double 矩阵yDim just_vector(1 To 3) As DoubleDim liji_min As Double 用于判断离基变量所用值Dim r_sign As Integer 用于记录离基变量对应的位置Dim main_yuan As Double 用于存放主元Dim Erk(1 To 3, 1 To 3) As DoubleDim Exchange_B(1 To 3, 1 To 3) 在矩阵Erk与矩阵B_进行乘法运算时,作为矩阵B_的替换矩阵Dim Exchange_XB(1 To 3) 在矩阵Erk与XB_进行乘法运算时,作为XB_的替换矩阵Dim iterativ
4、e_time As Integer 定义迭代的次数Dim XB_optimization(1 To 6) As Double 最优解Private Sub Command1_Click()窗口1For iterative_time = 1 To 1000 开始了迭代循环 Select Case k_sign Case 1 If (r_sign - 3) = 3 Then CB(1) = C(2) 付值给基本可行解对应的检验数 CB(2) = C(3) CB(3) = C(6) XB_optimization(1) = 0 XB_optimization(2) = XB(1) XB_optimi
5、zation(3) = XB(2) XB_optimization(4) = 0 XB_optimization(5) = 0 XB_optimization(6) = XB(3) End If Case 2 If (r_sign - 3) = 1 Then CB(1) = C(2) 付值给基本可行解对应的检验数 CB(2) = C(5) CB(3) = C(6) XB_optimization(1) = 0 XB_optimization(2) = XB(1) XB_optimization(3) = 0 XB_optimization(4) = 0 XB_optimization(5) =
6、 XB(2) XB_optimization(6) = XB(3) End If Case 3 If (r_sign - 3) = 2 Then CB(1) = C(2) 付值给基本可行解对应的检验数 CB(2) = C(3) CB(3) = C(6) XB_optimization(1) = 0 XB_optimization(2) = XB(1) XB_optimization(3) = XB(2) XB_optimization(4) = 0 XB_optimization(5) = 0 XB_optimization(6) = XB(3) End If End Select For i
7、 = 1 To 3 计算单纯形乘子矢量 (i) = CB(1) * B_(1, i) + CB(2) * B_(2, i) + CB(3) * B_(3, i) Next i For j = 1 To 6 计算检验矢量r r(j) = C(j) - (1) * A(1, j) + (2) * A(2, j) + (3) * A(3, j) Next j r_min = r(1) 预先给定一个值 k_sign = 1 For i = 1 To 6 找出最小检验值 If (r(i) r_min) Then r_min = r(i) 最小检验值 k_sign = i 最小检验值所在位置,对应进基矢量
8、位置 End If Next i If r_min 0 Then For i = 1 To 3 对应进基矢量所得的y值 Y(i, k_sign) = B_(i, 1) * A(1, k_sign) + B_(i, 2) * A(2, k_sign) + B_(i, 3) * A(3, k_sign) Next i For i = 1 To 3 确定离基变量 If Y(i, k_sign) 0 Then just_vector(i) = Y(i, 0) / Y(i, k_sign) End If Next i For i = 1 To 3 If (just_vector(i) 0 Then li
9、ji_min = just_vector(i) 预先给定一个值 Exit For End If Next i r_sign = 4 For i = 1 To 3 找出最小检验值 If (just_vector(i) 0) Then liji_min = just_vector(i) 最小检验值 r_sign = i + 3 最小检验值所在位置,对应进基矢量位置 End If Next i main_yuan = Y(r_sign - 3, k_sign) If main_yuan 0 Then Select Case (r_sign - 3) 计算矩阵Erk Case 1 Erk(1, 1)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 利用 修正 单纯 形法解 线性规划 问题
限制150内