Skip to content

Commit e34bcd8

Browse files
authored
Add files via upload
1 parent 016727c commit e34bcd8

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

algorithm/Dlba.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, configuration, numberOfCrossoverPoints=2, mutationSize=2, cro
2121
mutationProbability)
2222

2323
self._chromlen, self._minValue, self._alpha, self._pa = 0, 0, .9, .25
24-
self._f1, self._f2, self._loudness, self._rate = None, None, None, None
24+
self._loudness, self._rate = None, None
2525

2626
self._gBest = None
2727
self._position = [[]]
@@ -41,8 +41,6 @@ def initialize(self, population):
4141
population[i] = prototype.makeNewFromPrototype(positions)
4242
if i < 1:
4343
self._chromlen = len(positions)
44-
self._f1 = np.zeros(self._chromlen, dtype=float)
45-
self._f2 = np.zeros(self._chromlen, dtype=float)
4644
self._rate = np.zeros(populationSize, dtype=float)
4745
self._loudness = np.zeros(populationSize, dtype=float)
4846
self._position = np.zeros((populationSize, self._chromlen), dtype=float)
@@ -55,8 +53,7 @@ def initialize(self, population):
5553
def updatePositions(self, population):
5654
mean = np.mean(self._loudness)
5755
currentGeneration, prototype = self._currentGeneration, self._prototype
58-
f1, f2, gBest = self._f1, self._f2, self._gBest
59-
maxValues, minValue = self._maxValues, self._minValue
56+
gBest, maxValues, minValue = self._gBest, self._maxValues, self._minValue
6057
position, rate, loudness = self._position, self._rate, self._loudness
6158

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

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

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

0 commit comments

Comments
 (0)