重心法选址.doc_第1页
重心法选址.doc_第2页
重心法选址.doc_第3页
重心法选址.doc_第4页
重心法选址.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

2单设施重心法选址2.1实验目的掌握单设施重心法选址的原理,能够计算简单选址题目中待选设施的位置;掌握单设施重心选址的算法流程,能够设计类似题目的算法流程,并编写程序。2.2实验过程(1)单设施重心法选址的原理重心法选址模型示意图如图2-1所示。图2-1 单设施重心法选址选址示意图求解目标:C-总成本最低 其中:fi-序号为i的点的运输费率; Vi-序号为i的点的产量或者销量; di-序号为i的点到待选设施点的相对距离。待选设施位置的计算公式:其中:Xc-重心的X坐标; Yc-重心的Y坐标; Xi-第i个地点X坐标; Yi-第i个地点Y坐标; (2)算法流程图,如图2-2所示。图2-2 算法流程图2.3实验结果(1)单设施重心法选址程序参数设定及其求解界面如图2-3所示。图2-3 单设施重心法选址程序参数设定及其求解界面(2)参数设定及其求解界面变量声明部分(代码)Private Sub Command1_Click() If Text1.Text = Then MsgBox X-横坐标不允许为空 Text1.SetFocus Exit Sub ElseIf IsNumeric(Text1.Text) = False Then MsgBox X-横坐标必须为数值型数据! Text1.Text = Text1.SetFocus Exit Sub End If If Text2.Text = Then MsgBox Y-纵坐标不允许为空 Text2.SetFocus Exit Sub ElseIf IsNumeric(Text2.Text) = False Then MsgBox Y-纵坐标必须为数值型数据! Text2.Text = Text2.SetFocus Exit Sub End If If Text3.Text = Then MsgBox 产量或销量不允许为空 Text3.SetFocus Exit Sub ElseIf IsNumeric(Text3.Text) = False Then MsgBox 产量或销量应为数值型数据! Text3.Text = Text3.SetFocus Exit Sub ElseIf Val(Text3.Text) 0 Then MsgBox 产量或销量应为正数,否则无实际意义! Text3.Text = Text3.SetFocus Exit Sub End If If Text4.Text = Then MsgBox 运输费率不允许为空 Text4.SetFocus Exit Sub ElseIf IsNumeric(Text4.Text) = False Then MsgBox 运输费率应为数值型数据! Text4.Text = Text4.SetFocus Exit Sub ElseIf Val(Text4.Text) 0 Then MsgBox 运输费率应为正数,否则无实际意义! Text4.Text = Text4.SetFocus Exit Sub End If If Text5.Text = Then MsgBox X0-横坐标不允许为空 Text5.SetFocus Exit Sub ElseIf IsNumeric(Text5.Text) = False Then MsgBox X0-横坐标必须为数值型数据! Text5.Text = Text5.SetFocus Exit Sub End If If Text6.Text = Then MsgBox Y0-纵坐标不允许为空 Text6.SetFocus Exit Sub ElseIf IsNumeric(Text6.Text) = False Then MsgBox Y0-纵坐标必须为数值型数据! Text6.Text = Text6.SetFocus Exit Sub End If If Text7.Text = Then MsgBox 精度不允许为空 Text7.SetFocus Exit Sub ElseIf IsNumeric(Text7.Text) = False Then MsgBox 精度应为数值型数据! Text7.Text = Text7.SetFocus Exit Sub ElseIf Val(Text7.Text) = 2 Then Command2.Enabled = True End IfEnd SubPrivate Sub Command2_Click() Xc = Val(Text5.Text) Yc = Val(Text6.Text) JD = Val(Text7.Text) Dim SumCO As Double Dim SumCN As Double Dim Sum1 As Double Dim Sum2 As Double Dim Sum3 As Double For j = 1 To 10000 SumCO = 0 SumCN = 0 Sum1 = 0 Sum2 = 0 Sum3 = 0 For i = 1 To List1.ListCount di = Sqr(Xc - Val(List1.List(i - 1) 2 + (Yc - Val(List2.List(i - 1) 2) 距离公式 SumCO = SumCO + Val(List3.List(i - 1) * Val(List4.List(i - 1) * di Sum1 = Sum1 + (Val(List1.List(i - 1) * Val(List3.List(i - 1) * Val(List4.List(i - 1) / di Sum2 = Sum2 + (Val(List2.List(i - 1) * Val(List3.List(i - 1) * Val(List4.List(i - 1) / di Sum3 = Sum3 + (Val(List3.List(i - 1) * Val(List4.List(i - 1) / di Next i Xc = Sum1 / Sum3 Yc = Sum2 / Sum3 For i = 1 To List1.ListCount di = Sqr(Xc - Val(List1.List(i - 1) 2 + (Yc - Val(List2.List(i - 1) 2) SumCN = SumCN + Val(List3.List(i - 1) * Val(List4.List(i - 1) * di Next i If (SumCO - SumCN) = JD Then Text8.Text = Xc Text9.Text = Yc Text10.Text = SumCN Text11.Text = j Exit For End If Next jEnd SubPrivate Sub List1_Click() For i = 1 To List1.ListCount If List1.Selected(i - 1) = True Then h = InputBox(请输入要改的参数:, 参数修正) If h And IsNumeric(h) = True Then List1.List(i - 1) = h Else: MsgBox 输入的数据必须为数值型数据 End If End If Next iEnd SubPrivate Sub List2_Click() For i = 1 To List2.ListCount If List2.Selected(i - 1) = True Then h = InputBox(请输入要改的参数:, 参数修正) If h And IsNumeric(h) = True Then List2.List(i - 1) = h Else: MsgBox 输入的数据必须为数值型数据 End If End If Next iEnd SubPrivate Sub List3_Click() For i = 1 To List3.ListCount If List3.Selected(i - 1) = True Then h = InputBox(请输入要改的参数:, 参数修正) If h And IsNumeric(h) = True And Val(h) 0 Then List3.List(i - 1) = h Else: MsgBox 输入的数据必须为数值型数据 End If End If Next iEnd SubPrivate Sub List4_Click() For i = 1 To List4.ListCount If List4.Selected(i - 1) = True Then h = I

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论