logo

您所在位置网站首页 > 海量文档  > 教学课件 > 职业教育

基于VB的-单纯型法-解-线性规划-代码.doc 6页

本文档一共被下载: ,您可全文免费在线阅读后下载本文档。

  • 支付并下载
  • 收藏该文档
  • 百度一下本文档
  • 修改文档简介
全屏预览

下载提示

1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
特别说明: 下载前务必先预览,自己验证一下是不是你要下载的文档。
  • 上传作者 lyxbb(上传创作收益人)
  • 发布时间:2018-04-07
  • 需要金币100(10金币=人民币1元)
  • 浏览人气
  • 下载次数
  • 收藏次数
  • 文件大小:54 KB
下载过该文档的会员
你可能关注的文档:
基于VB的 单纯型法 解 线性规划 代码 1. Form窗体代码: Option Explicit Private Sub Command1_Click Dim nVariables As Long, nConstraints As Long Dim s As String, c As Double, a As Double, x As Double Dim i As Long, j As Long, items As Variant, items1 As Variant Dim ret As Boolean, stopN As Long stopN 100 'in every stopN, the iteration will be stoped to ask if continue s "max,0.8,2.5,1" 'for c in max z cx s s & ";" & "0.6,-0.1,-0.2, ,1" 'for a and b b at the end in ax b s s & ";" & "-0.3,0.6,-0.4, ,3" s s & ";" & "-0.1,-0.3,0.8, ,5" s s & ";" & "1,1,1, ,58.5" items Split s, ";" nConstraints UBound items ReDim a nConstraints items1 Split items 0 , "," nVariables UBound items1 ReDim c nVariables As Double, a nConstraints, nVariables + 1 As Double, x nVariables As Double If items1 0 "max" Then c 0 1 '1 for max, standard; 0 for min, non-standard End If For j 1 To nVariables c j items1 j Next j For i 1 To nConstraints items1 Split items i , "," For j 1 To nVariables a i, j items1 j - 1 Next j If items1 nVariables " " Then a i, 0 1 '1 for , standard ; 0 for , non-standard; 2 for , ElseIf items1 nVariables " " Then a i, 0 2 End If a i, nVariables + 1 items1 nVariables + 1 Next i 'c , a may also be read from text file ret Simplex c , a , x , stopN If ret Then If c 0 1 Then Print "Max value " & x 0 Else Print "Min value " & x 0 End If For i 1 To nVariables Print i, x i Next i Else MsgBox "Cannot solve the problem!", vbCritical End If End Sub 添加一个标准模块(.bas),代码如下: Option Explicit 'Simplex method 'Problem: max or min z cx, s.t. ax or or b, and x 0 with b 0 'Add slack variables, obtain Standard Form: max or min z cx, s.t. ax b and x 0 Public Function Simplex c As Double, a As Double, x As Double, stopN As Long As Boolean 'Simplex method, coded by btef please let this line remain Dim nVariables As Long, nConstraints As Long, table As Double, index As Long Dim n As Long

发表评论

请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换图片

©2010-2019 max.book118.com 原创力文档. All Rights Reserved 工信部备案号:蜀ICP备08101938号-1 经营许可证:川B2-20180569 公安局备案号:51011502000106

“原创力文档”前称为“文档投稿赚钱网”,本网站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有【成交的100%(原创)】