无约束多维优化坐标轮换法vb编程.doc

上传人:hw****26 文档编号:3187731 上传时间:2019-05-24 格式:DOC 页数:6 大小:88.50KB
下载 相关 举报
无约束多维优化坐标轮换法vb编程.doc_第1页
第1页 / 共6页
无约束多维优化坐标轮换法vb编程.doc_第2页
第2页 / 共6页
无约束多维优化坐标轮换法vb编程.doc_第3页
第3页 / 共6页
无约束多维优化坐标轮换法vb编程.doc_第4页
第4页 / 共6页
无约束多维优化坐标轮换法vb编程.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、坐标轮换法程序框图Vb 运行界面Vb 编程程序Private Sub Command1_Click()Dim s110 As DoubleDim s100 As DoubleDim s200 As DoubleDim s210 As DoubleDim x100(10000000) As DoubleDim x110(10000000) As DoubleDim x200(10000000) As DoubleDim x210(10000000) As DoubleDim 1 As DoubleDim 2 As DoubleDim k As LongDim a1#, a2#, a3#, a4#

2、, a5#, a6#Dim h#, e1#, e#Dim 0#, 1#, 2#, 3#, a#, b#Dim xx1#, xx2#, yy1#, yy2#, yy3#Dim f2#, f1#, fxx#0 = Val(Text10.Text)h = Val(Text11.Text)e1 = Val(Text12.Text)x100(0) = Val(Text7.Text)x110(0) = Val(Text8.Text)a1 = Val(Text1.Text): a2 = Val(Text2.Text): a3 = Val(Text3.Text): a4 = Val(Text4.Text):

3、a5 = Val(Text5.Text): a6 = Val(Text6.Text)e = Val(Text9.Text)k = 0m1: s100 = 1: s110 = 0一维搜索求最优解1 = 0xx1 = x100(k) + s100 * 1: xx2 = x110(k) + s110 * 1: yy1 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a62 = 0 + hxx1 = x100(k) + s100 * 2: xx2 = x110(k) + s110 * 2: yy2 = a1 * xx

4、1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6If yy1 yy2 Thenh = 2 * hElseh = -0.25 * h3 = 11 = 22 = 3yy3 = yy1yy1 = yy2yy2 = yy3End If3 = 0 + hxx1 = x100(k) + s100 * 3: xx2 = x110(k) + s110 * 3: yy3 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Do While yy2 yy3h

5、 = 2 * h1 = 2yy1 = yy22 = 3yy2 = yy33 = 0 + hxx1 = x100(k) + s100 * 3: xx2 = x110(k) + s110 * 3: yy3 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6LoopIf h 0 Thena = 1ya = yy1b = 3yb = yy3Elsea = 3b = 1ya = yy3yb = yy1End If1 = a + 0.382 * (b - a)2 = a + 0.618 * (b - a)xx1 = x

6、100(k) + s100 * 1: xx2 = x110(k) + s110 * 1: yy1 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6xx1 = x100(k) + s100 * 2: xx2 = x110(k) + s110 * 2: yy2 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Do While Abs(b - a) e1If yy1 yy2 Thenh = 2 * hElseh = -0.

7、25 * h3 = 11 = 22 = 3yy3 = yy1yy1 = yy2yy2 = yy3End If3 = 0 + hxx1 = x200(k) + s200 * 3: xx2 = x210(k) + s210 * 3: yy3 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Do While yy2 yy3h = 2 * h1 = 2yy1 = yy22 = 3yy2 = yy33 = 0 + hxx1 = x200(k) + s200 * 3: xx2 = x210(k) + s210 * 3

8、: yy3 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6LoopIf h 0 Thena = 1ya = yy1b = 3yb = yy3Elsea = 3b = 1ya = yy3yb = yy1End If1 = a + 0.382 * (b - a)2 = a + 0.618 * (b - a)xx1 = x200(k) + s200 * 1: xx2 = x210(k) + s210 * 1: yy1 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a

9、4 * xx1 + a5 * xx2 + a6xx1 = x200(k) + s200 * 2: xx2 = x210(k) + s210 * 2: yy2 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Do While Abs(b - a) e1If yy1 yy2 Thenn0 = 0b = 22 = 1yy2 = yy1Elsen0 = 1a = 11 = 2yy1 = yy2End IfIf n0 = 0 Then1 = a + 0.382 * (b - a)xx1 = x200(k) + s2

10、00 * 1: xx2 = x210(k) + s210 * 1: yy1 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Else2 = a + 0.618 * (b - a)xx1 = x200(k) + s200 * 2: xx2 = x210(k) + s210 * 2: yy2 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6End IfLoop2 = (a + b) / 2x200(k + 1) = x2

11、00(k) + s200 * 2x210(k + 1) = x210(k) + s210 * 2xx1 = x200(k): xx2 = x210(k): f1 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6xx1 = x200(k + 1): xx2 = x210(k + 1): f2 = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6If Abs(x200(k + 1) - x200(k) 2 + (x210(k

12、 + 1) - x210(k) 2) = e And Abs(f2 - f1) / f2) = e Thenxx1 = x200(k + 1): xx2 = x210(k + 1)fxx = a1 * xx1 2 + a2 * xx2 2 + a3 * xx1 * xx2 + a4 * xx1 + a5 * xx2 + a6Elsex100(k + 1) = x200(k): x110(k + 1) = x210(k)k = k + 1GoTo m1End IfText13.Text = xx1Text14.Text = xx2Text15.Text = fxxEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 精品笔记

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。