modfindbestandworstindividual.bas
来自「用vb编写的一个遗传算法的程序」· BAS 代码 · 共 24 行
BAS
24 行
Attribute VB_Name = "ModFindBestAndWorstIndividual"
'找出最优、最差个体
'并更新当前最优个体
Sub FindBestAndWorstIndividual()
Dim i As Integer
BestIndividual = Population(0)
WorstIndividual = Population(0)
For i = 1 To PopSize - 1
If Population(i).fitness > BestIndividual.fitness Then
BestIndividual = Population(i)
Best_Index = i
ElseIf Population(i).fitness < WorstIndividual.fitness Then
WorstIndividual = Population(i)
Worst_Index = i
End If
Next i
If Generation = 0 Then
CurrentBest = BestIndividual
ElseIf BestIndividual.fitness > CurrentBest.fitness Then
CurrentBest = BestIndividual
End If
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?