亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? frmswarm.frm

?? 基本的微粒群演算法VB范例原始碼,對剛接觸PSO將會有初步的認知
?? FRM
字號:
VERSION 5.00
Begin VB.Form frmSwarm 
   Caption         =   "Form1"
   ClientHeight    =   7350
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8520
   LinkTopic       =   "Form1"
   ScaleHeight     =   7350
   ScaleWidth      =   8520
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdSwarm 
      Caption         =   "Fly the Swarm"
      Height          =   495
      Left            =   3840
      TabIndex        =   1
      Top             =   6600
      Width           =   1215
   End
   Begin VB.PictureBox picSwarm1 
      DrawWidth       =   3
      Height          =   4695
      Left            =   1080
      ScaleHeight     =   4635
      ScaleWidth      =   4995
      TabIndex        =   0
      Top             =   360
      Width           =   5055
   End
End
Attribute VB_Name = "frmSwarm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Particle swarm VB5 software by Russ Eberhart
' Last modified on May 13, 1998 new loops and lbest
Option Explicit
Option Base 1
  Dim iPOPSIZE As Integer       ' Population size
  Dim iDIMENSIONS As Integer    ' Number of dimensions
  Dim iPopindex As Integer      ' Index for population
  Dim iDimindex As Integer      ' Index for dimensions
  Dim fINITWT As Single         ' Initial inertia weight
  Dim fMAXVEL As Single         ' Maximum velocity allowed
  Dim nMAXITER As Integer       ' Maximum number of iterations
  Dim nIter As Integer          ' Number of iterations
  Dim fPos() As Single          ' Position for each particle
  Dim fTempPos() As Single      ' Temporary updated position for each particle
  Dim fVel() As Single          ' Velocity for each particle
  Dim fDumVel() As Single       ' Dummy velocity vector 1-dim array
  Dim fBestPos() As Single      ' Best previous position for each particle
  Dim fMaxPos As Single         ' Dynamic range
  Dim fInerWt As Single         ' Inertia weight
  Dim fErrVal() As Double       ' Function error value calculated by eval()
  Dim fPbestVal() As Double     ' Best error value over time for each particle
  Dim fERRCUTOFF As Double      ' Error value at which system stops
  Dim iUSEBETTER As Integer     ' Usebetter is kind of a momentum
  Dim iBetter() As Integer      ' This gets set in program
  Dim iGbest As Integer         ' Index for global best particle
  Dim iLbest As Integer         ' Index for local (neighborhood) best particle
  Dim iLOCAL As Integer         ' Neighborhood size specified in run file
  Dim iHOODSIZE As Integer      ' Neighborhood size used in program
  Dim iHOODINDEX As Integer     ' Neighborhood index (offset from particle)
  Dim iNeighbor() As Integer    ' Popindexes of neighbors resulting from iLOCAL
  Dim sOutfile As String        ' Filename for output
  
Private Sub cmdSwarm_Click()
  iDIMENSIONS = 2               ' Set number of dimensions for problem
  
  
  Open "psoinput.txt" For Input As #1
    Input #1, iPOPSIZE, fERRCUTOFF, fMAXVEL, fMaxPos, nMAXITER, iUSEBETTER, _
      fINITWT, iLOCAL, sOutfile
     ' Population size, error cutoff value, maximum velocity, maximum position
     ' (range), maximum no. of iterations, use momentum (usebetter), initial
     ' inertia weight, neighborhood (0=global, even no. for local neighborhood),
     ' filename for output
  Close #1

  ReDim fPos(iPOPSIZE, iDIMENSIONS)
  ReDim fTempPos(iPOPSIZE, iDIMENSIONS)
  ReDim fVel(iPOPSIZE, iDIMENSIONS)
  ReDim fBestPos(iPOPSIZE, iDIMENSIONS)
  ReDim fDumVel(iDIMENSIONS)
  ReDim fErrVal(iPOPSIZE)
  ReDim fPbestVal(iPOPSIZE)
  ReDim iBetter(iPOPSIZE)
  ReDim iNeighbor(-iPOPSIZE To iPOPSIZE)
  
    If iLOCAL > 0 Then iHOODSIZE = Int(iLOCAL / 2#) * 2# Else iHOODSIZE = iPOPSIZE
        
    Randomize
    ' Randomize the positions and velocities for entire population
    For iPopindex = 1 To iPOPSIZE
        For iDimindex = 1 To iDIMENSIONS
            fPos(iPopindex, iDimindex) = Rnd * fMaxPos
            fBestPos(iPopindex, iDimindex) = fPos(iPopindex, iDimindex)
            fVel(iPopindex, iDimindex) = Rnd * fMAXVEL
            If Rnd > 0.5 Then fPos(iPopindex, iDimindex) = -fPos(iPopindex, iDimindex)
            If Rnd > 0.5 Then fVel(iPopindex, iDimindex) = -fVel(iPopindex, iDimindex)
            'frmSwarm.Print "Init. Pos & Vel ", fPos(iPopindex, iDimindex) _
                , fVel(iPopindex, iDimindex)        ' for diagnostic purpose
        Next iDimindex
    Next iPopindex
       
    ' Main swarm loop here
    For nIter = 1 To nMAXITER
    
        ' Update inertia weight; linear from fINITWT to 0.4
        fInerWt = ((fINITWT - 0.4) * (nMAXITER - nIter) / nMAXITER) + 0.4
        
      For iPopindex = 1 To iPOPSIZE     'MAIN main loop starts here
            'Setup dummy velocity vector for current population member
            For iDimindex = 1 To iDIMENSIONS
                fDumVel(iDimindex) = fVel(iPopindex, iDimindex)
            Next iDimindex
            
            iBetter(iPopindex) = 0             ' Set to 0 unless new Pbest achieved
            
            Call evalf6(iPopindex)    ' evaluates f6 function error: fErrVal(iPopindex)
            
            If nIter = 1 Then
                fPbestVal(iPopindex) = fErrVal(iPopindex)
                iGbest = 1
            End If
            
            If fErrVal(iPopindex) < fPbestVal(iPopindex) Then   'If new Pbest
                fPbestVal(iPopindex) = fErrVal(iPopindex)
                
                For iDimindex = 1 To iDIMENSIONS    ' Reset Pbest location vector
                    fBestPos(iPopindex, iDimindex) = fPos(iPopindex, iDimindex)
                Next iDimindex
                
                If fPbestVal(iPopindex) < fPbestVal(iGbest) Then
                    ' color(iGbest) = DEFAULTCOLOR  need to dim these variables
                    iGbest = iPopindex
                    ' color(iGbest) = GBESTCOLOR
                End If
                
                If iUSEBETTER = 1 Then iBetter(iPopindex) = 1
            End If                                     ' End new Pbest loop
      Next iPopindex            'end MAIN main loop for gold gbest only
      
      Dim iXcoord As Integer, iYcoord As Integer
      picSwarm1.BackColor = vbBlack
      
      For iPopindex = 1 To iPOPSIZE         'update velocity, position, graph position
      
            ' Does neighborhood calculation of iLbest
            If iLOCAL > 0 Then
                For iHOODINDEX = 0 To iHOODSIZE
                    iNeighbor(iHOODINDEX) = iPopindex - (iHOODSIZE / 2#) + iHOODINDEX
                    'for iPopindex = 1,goes from 0 to 2 for iHOODSIZE of 2
                    '                       from -1 to 3 for iHOODSIZE of 4
                    ' Now wrap the ends of the array
                    If iNeighbor(iHOODINDEX) < 1 Then iNeighbor(iHOODINDEX) = iPOPSIZE + _
                      iNeighbor(iHOODINDEX)
                    If iNeighbor(iHOODINDEX) > iPOPSIZE Then iNeighbor(iHOODINDEX) = _
                      iNeighbor(iHOODINDEX) - iPOPSIZE
                    'Start with iNeighbor(0) as iLbest and try to beat it
                    If iHOODINDEX = 0 Then iLbest = iNeighbor(0)
                    If fPbestVal(iNeighbor(iHOODINDEX)) < fPbestVal(iLbest) Then _
                      iLbest = iNeighbor(iHOODINDEX)
                Next iHOODINDEX
            End If
                        
            If iLOCAL = 0 Then iLbest = iGbest
                        
            ' Update velocity vector for one particle Russ Reduced version
            For iDimindex = 1 To iDIMENSIONS        'fInerWt below
                fVel(iPopindex, iDimindex) = (0.5 + (Rnd / 2)) * fVel(iPopindex, iDimindex) + _
                 2# * Rnd * (fBestPos(iPopindex, iDimindex) - fPos(iPopindex, iDimindex)) + _
                 2# * Rnd * (fBestPos(iLbest, iDimindex) - fPos(iPopindex, iDimindex))
                 
                If fVel(iPopindex, iDimindex) > fMAXVEL Then
                    fVel(iPopindex, iDimindex) = fMAXVEL
                ElseIf fVel(iPopindex, iDimindex) < -fMAXVEL Then
                    fVel(iPopindex, iDimindex) = -fMAXVEL
                End If
            Next iDimindex
            
            'If it's going the right way, keep going
            If iBetter(iPopindex) = 1 Then
                For iDimindex = 1 To iDIMENSIONS
                    fVel(iPopindex, iDimindex) = fDumVel(iDimindex)
                Next iDimindex
            End If
            
          ' Graphics Loop: Graphically plot updated positions
        
            'Erase old position for two dimensions of one particle
            iXcoord = Int((picSwarm1.ScaleWidth / 2#) * (1 + _
              10 * fPos(iPopindex, 1) / fMaxPos))
            iYcoord = Int((picSwarm1.ScaleHeight / 2#) * (1 + _
              10 * fPos(iPopindex, 2) / fMaxPos))
            picSwarm1.PSet (iXcoord, iYcoord), vbBlack
            
            For iDimindex = 1 To iDIMENSIONS  'Define new positions for all dimensions
                fPos(iPopindex, iDimindex) = fPos(iPopindex, iDimindex) + _
                  fVel(iPopindex, iDimindex)
            Next iDimindex
            
            'Graph new position for two dimensions of one particle
            iXcoord = Int((picSwarm1.ScaleWidth / 2#) * (1 + _
              10 * fPos(iPopindex, 1) / fMaxPos))
            iYcoord = Int((picSwarm1.ScaleHeight / 2#) * (1 + _
              10 * fPos(iPopindex, 2) / fMaxPos))
            picSwarm1.PSet (iXcoord, iYcoord), vbGreen
            
      Next iPopindex                'end velocity, position, graph loop
        
        'Graph 2 dimensions of iGbest
            iXcoord = Int((picSwarm1.ScaleWidth / 2#) * (1 + _
              10 * fPos(iGbest, 1) / fMaxPos))
            iYcoord = Int((picSwarm1.ScaleHeight / 2#) * (1 + _
              10 * fPos(iGbest, 2) / fMaxPos))
            picSwarm1.PSet (iXcoord, iYcoord), vbWhite
        
        'Terminate on sufficiently low error
        If (fPbestVal(iGbest) < fERRCUTOFF) Or nIter >= nMAXITER Then
            MsgBox "Iter: " & nIter & "  Err: " & fPbestVal(iGbest) ', vbYesNo
            Open sOutfile For Append As #2       'psoutfile.txt
            Print #2, "Iter: ", nIter, " Best val: ", fPbestVal(iGbest); Now
            Print #2, "Neighborhood size (0 is global): ", iLOCAL
            For iDimindex = 1 To iDIMENSIONS
                Print #2, "Dim. ", iDimindex, "Pos. ", fPos(iGbest, iDimindex)
            Next iDimindex
            Close #2
            End                     'END PROGRAM
        End If
        
    Next nIter                       '   next nIter, end main loop
End Sub

    Sub evalf6(iPopindex)             ' evaluates f6 function error: fVal(iPopindex)
        Dim fNum As Double, fDenom As Double, fF6val As Double
        
        fNum = (Sin(Sqr((fPos(iPopindex, 1) * fPos(iPopindex, 1) + _
            fPos(iPopindex, 2) * fPos(iPopindex, 2))))) ^ 2 - 0.5
        fDenom = (1# + 0.001 * (fPos(iPopindex, 1) * fPos(iPopindex, 1) + _
            fPos(iPopindex, 2) * fPos(iPopindex, 2))) ^ 2
        fF6val = 0.5 - (fNum / fDenom)
        fErrVal(iPopindex) = 1# - fF6val
    End Sub
    
    'Sub evalsphere(iPopindex)
        'Dim fErrValdim(iPopindex, iDIMENSIONS) as Double
    
        'For iDimindex = 1 to iDIMENSIONS
            'fErrValDim(iPopindex, iDimindex) = (fPos(iPopindex, iDimindex))^2
        'Next iDimindex
    'End Sub
    

Private Sub Form_Load()
frmSwarm.Show
End Sub

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
视频一区二区不卡| 不卡的av在线| 国产成人亚洲精品青草天美| 91视频免费播放| 精品国内二区三区| 亚洲va欧美va国产va天堂影院| 黑人精品欧美一区二区蜜桃 | 色乱码一区二区三区88| 日韩欧美成人午夜| 亚洲高清中文字幕| 不卡的电影网站| 久久久www免费人成精品| 免费成人在线网站| 在线影视一区二区三区| 欧美高清一级片在线观看| 毛片基地黄久久久久久天堂| 色综合久久99| 国产日韩欧美综合一区| 久久精品国产999大香线蕉| 91免费观看视频| 国产精品天天看| 国产精品一二三四区| 91精品国产91热久久久做人人| 亚洲免费毛片网站| 99精品1区2区| 欧美国产禁国产网站cc| 国产成人综合精品三级| 精品蜜桃在线看| 日本不卡视频在线观看| 欧美久久久久久久久久| 亚洲国产aⅴ天堂久久| 97se亚洲国产综合自在线观| 国产女同互慰高潮91漫画| 免费高清不卡av| 日韩一区二区三区三四区视频在线观看| 一区二区欧美在线观看| 欧美唯美清纯偷拍| 亚洲国产精品久久人人爱蜜臀| 色综合天天狠狠| 亚洲自拍偷拍综合| 欧美日韩一级片在线观看| 亚洲一区视频在线观看视频| 欧洲国内综合视频| 亚洲一区二区精品久久av| 欧美色中文字幕| 激情伊人五月天久久综合| 精品国产乱码久久久久久图片| 蜜桃av噜噜一区二区三区小说| 日韩欧美一二三四区| 极品少妇xxxx偷拍精品少妇| 精品盗摄一区二区三区| 国产成人在线色| 国产精品久久久久久久久动漫| 99国产精品一区| 亚洲mv大片欧洲mv大片精品| 在线成人免费视频| 精品一区二区三区在线观看国产| 久久久国产午夜精品| 成人18视频日本| 亚洲午夜视频在线观看| 日韩女优毛片在线| 成人毛片视频在线观看| 亚洲免费观看高清完整版在线| 欧美在线一区二区| 免费观看一级特黄欧美大片| 日韩美女一区二区三区| 国产91精品入口| 亚洲国产视频a| 久久久久久麻豆| 91老司机福利 在线| 蜜臀av性久久久久蜜臀av麻豆| 国产婷婷色一区二区三区在线| 91毛片在线观看| 免费一级欧美片在线观看| 国产精品网站导航| 欧美高清hd18日本| 成人午夜在线视频| 日本欧美一区二区在线观看| 国产色产综合色产在线视频 | 欧美精品日韩精品| 国产精品中文有码| 亚洲一级二级三级在线免费观看| www国产成人| 欧美日韩精品一区二区三区蜜桃 | 亚洲日本va在线观看| 欧美一区二区三区在线看| 成人av在线播放网址| 午夜精品爽啪视频| 中文字幕在线视频一区| 亚洲午夜一二三区视频| 国产三区在线成人av| 欧美丰满一区二区免费视频 | 久久精品国产精品亚洲精品| 国产精品久久久久一区| 精品久久一区二区三区| 欧美在线免费观看亚洲| 菠萝蜜视频在线观看一区| 九九精品视频在线看| 亚洲妇熟xx妇色黄| 综合亚洲深深色噜噜狠狠网站| 56国语精品自产拍在线观看| 99r精品视频| 国产成人精品亚洲777人妖| 日本不卡中文字幕| 亚洲一二三四在线| 亚洲人一二三区| 国产精品久久久久久妇女6080 | 天天做天天摸天天爽国产一区| 国产精品污污网站在线观看| 精品粉嫩超白一线天av| 91精品国产免费| 欧美日韩免费在线视频| 日本高清不卡aⅴ免费网站| 成人免费毛片app| 国产精品一区二区你懂的| 精品一区二区三区香蕉蜜桃| 日韩福利视频导航| 日韩经典中文字幕一区| 亚洲va欧美va天堂v国产综合| 亚洲综合免费观看高清完整版| 亚洲欧美日本在线| 亚洲日本va在线观看| 亚洲欧洲另类国产综合| 中文字幕一区二区三区乱码在线| 国产精品日日摸夜夜摸av| 国产女人aaa级久久久级| 国产偷国产偷精品高清尤物| 国产视频911| 国产精品不卡在线| 亚洲女同女同女同女同女同69| 亚洲欧洲成人精品av97| 亚洲视频小说图片| 亚洲在线观看免费视频| 污片在线观看一区二区| 麻豆精品一二三| 激情av综合网| 成人av集中营| 色婷婷一区二区| 欧美一区二区三区视频在线| 精品少妇一区二区三区免费观看| 精品日产卡一卡二卡麻豆| 久久婷婷成人综合色| 国产精品欧美一区二区三区| 亚洲视频一区二区在线观看| 亚洲线精品一区二区三区| 免费精品99久久国产综合精品| 国产呦精品一区二区三区网站| 成人自拍视频在线观看| 91麻豆福利精品推荐| 欧美日韩激情一区二区三区| 精品国产一区二区三区四区四| 日本一区二区视频在线| 亚洲综合久久久久| 国内精品免费在线观看| 97国产一区二区| 欧美一级爆毛片| 中文字幕亚洲视频| 强制捆绑调教一区二区| 成人性视频免费网站| 这里只有精品视频在线观看| 久久精品一区二区三区av| 亚洲精品一二三| 久久精品国产免费看久久精品| 不卡一区在线观看| 欧美一卡二卡在线| 综合婷婷亚洲小说| 精品一区二区三区视频在线观看| 99re66热这里只有精品3直播 | 亚洲电影一区二区三区| 国产综合色视频| 欧美色男人天堂| 国产精品伦理在线| 久久激情五月激情| 在线观看视频欧美| 国产免费成人在线视频| 青娱乐精品视频在线| 色综合中文字幕国产| 日韩一卡二卡三卡| 亚洲国产aⅴ成人精品无吗| 成人午夜电影网站| 精品日韩一区二区三区| 亚洲一区二区三区四区中文字幕| 国产·精品毛片| 日韩欧美一级在线播放| 亚洲国产wwwccc36天堂| a级高清视频欧美日韩| 久久精品一区蜜桃臀影院| 视频在线在亚洲| 欧美性三三影院| 日韩毛片视频在线看| 国产91高潮流白浆在线麻豆| 欧美不卡一区二区| 免费高清视频精品| 欧美一区二区在线播放| 亚洲综合成人网| 在线观看亚洲专区| 亚洲精品自拍动漫在线| 91免费小视频| 自拍偷拍欧美激情| 一本久久综合亚洲鲁鲁五月天 |