Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan committed Jun 18, 2024
1 parent e34bcd8 commit aa72c74
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions algorithm/Dlba.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def updatePositions(self, population):
gBest, maxValues, minValue = self._gBest, self._maxValues, self._minValue
position, rate, loudness = self._position, self._rate, self._loudness

localBest = prototype.makeNewFromPrototype()
if gBest is None:
gBest = position[0]
prevBest = prototype.makeEmptyFromPrototype()
prevBest.updatePositions(gBest)

populationSize = self._populationSize
for i in range(populationSize):
Expand All @@ -81,10 +82,6 @@ def updatePositions(self, population):

gBest = self._lf.updatePosition(population[i], position, i, gBest)

localTemp = prototype.makeEmptyFromPrototype()
localTemp.updatePositions(position[i])
if localTemp.dominates(localBest):
localBest = localTemp

globalBest = prototype.makeEmptyFromPrototype()
globalBest.updatePositions(gBest)
Expand All @@ -96,9 +93,9 @@ def updatePositions(self, population):
for j in range(self._chromlen):
position[i, j] = gBest[j] + 𝜂 * mean

if globalBest.dominates(localBest):
rate[i] *= (_currentGeneration / 𝜂) ** 3
loudness[i] *= alpha
if prevBest.dominates(globalBest):
rate[i] *= (currentGeneration / 𝜂) ** 3
loudness[i] *= self._alpha

position[i] = self._lf.optimum(position[i], population[i])

Expand Down

0 comments on commit aa72c74

Please sign in to comment.