@@ -56,9 +56,10 @@ def updatePositions(self, population):
56
56
gBest , maxValues , minValue = self ._gBest , self ._maxValues , self ._minValue
57
57
position , rate , loudness = self ._position , self ._rate , self ._loudness
58
58
59
- localBest = prototype .makeNewFromPrototype ()
60
59
if gBest is None :
61
60
gBest = position [0 ]
61
+ prevBest = prototype .makeEmptyFromPrototype ()
62
+ prevBest .updatePositions (gBest )
62
63
63
64
populationSize = self ._populationSize
64
65
for i in range (populationSize ):
@@ -81,10 +82,6 @@ def updatePositions(self, population):
81
82
82
83
gBest = self ._lf .updatePosition (population [i ], position , i , gBest )
83
84
84
- localTemp = prototype .makeEmptyFromPrototype ()
85
- localTemp .updatePositions (position [i ])
86
- if localTemp .dominates (localBest ):
87
- localBest = localTemp
88
85
89
86
globalBest = prototype .makeEmptyFromPrototype ()
90
87
globalBest .updatePositions (gBest )
@@ -96,9 +93,9 @@ def updatePositions(self, population):
96
93
for j in range (self ._chromlen ):
97
94
position [i , j ] = gBest [j ] + 𝜂 * mean
98
95
99
- if globalBest .dominates (localBest ):
100
- rate [i ] *= (_currentGeneration / 𝜂 ) ** 3
101
- loudness [i ] *= alpha
96
+ if prevBest .dominates (globalBest ):
97
+ rate [i ] *= (currentGeneration / 𝜂 ) ** 3
98
+ loudness [i ] *= self . _alpha
102
99
103
100
position [i ] = self ._lf .optimum (position [i ], population [i ])
104
101
0 commit comments