From aa72c742d76f0bd195feb7fbcc7cfb4fb2f3c8f0 Mon Sep 17 00:00:00 2001 From: Miller Cy Chan Date: Tue, 18 Jun 2024 10:32:30 +0800 Subject: [PATCH] Add files via upload --- algorithm/Dlba.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/algorithm/Dlba.py b/algorithm/Dlba.py index 8add96c..a7ef697 100644 --- a/algorithm/Dlba.py +++ b/algorithm/Dlba.py @@ -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): @@ -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) @@ -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])