Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Jun 15, 2024
1 parent 016727c commit e34bcd8
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 @@ -21,7 +21,7 @@ def __init__(self, configuration, numberOfCrossoverPoints=2, mutationSize=2, cro
mutationProbability)

self._chromlen, self._minValue, self._alpha, self._pa = 0, 0, .9, .25
self._f1, self._f2, self._loudness, self._rate = None, None, None, None
self._loudness, self._rate = None, None

self._gBest = None
self._position = [[]]
Expand All @@ -41,8 +41,6 @@ def initialize(self, population):
population[i] = prototype.makeNewFromPrototype(positions)
if i < 1:
self._chromlen = len(positions)
self._f1 = np.zeros(self._chromlen, dtype=float)
self._f2 = np.zeros(self._chromlen, dtype=float)
self._rate = np.zeros(populationSize, dtype=float)
self._loudness = np.zeros(populationSize, dtype=float)
self._position = np.zeros((populationSize, self._chromlen), dtype=float)
Expand All @@ -55,8 +53,7 @@ def initialize(self, population):
def updatePositions(self, population):
mean = np.mean(self._loudness)
currentGeneration, prototype = self._currentGeneration, self._prototype
f1, f2, gBest = self._f1, self._f2, self._gBest
maxValues, minValue = self._maxValues, self._minValue
gBest, maxValues, minValue = self._gBest, self._maxValues, self._minValue
position, rate, loudness = self._position, self._rate, self._loudness

localBest = prototype.makeNewFromPrototype()
Expand All @@ -74,9 +71,9 @@ def updatePositions(self, population):
r4 = np.random.randint(0, populationSize)

for j in range(self._chromlen):
f1[j] = ((minValue - maxValues[j]) * currentGeneration / 𝛽1 + maxValues[j]) * beta
f2[j] = ((maxValues[j] - minValue) * currentGeneration / 𝛽2 + minValue) * beta
position[i, j] = gBest[j] + f1[j] * (position[r1][j] - position[r2][j]) + f2[j] * (position[r3][j] - position[r3][j])
f1 = ((minValue - maxValues[j]) * currentGeneration / 𝛽1 + maxValues[j]) * beta
f2 = ((maxValues[j] - minValue) * currentGeneration / 𝛽2 + minValue) * beta
position[i, j] = gBest[j] + f1 * (position[r1][j] - position[r2][j]) + f2 * (position[r3][j] - position[r3][j])

if rand > rate[i]:
𝜀 = np.random.uniform(low=-1, high=1)
Expand Down

0 comments on commit e34bcd8

Please sign in to comment.