Skip to content

Commit 310069e

Browse files
authored
fix #1
1 parent 28f4472 commit 310069e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

algorithm/GeneticAlgorithm.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ def addToBest(self, chromosomeIndex):
7070
return
7171

7272
# find place for new chromosome
73-
j = self._currentBestSize
74-
for i in range(j, -1, -1):
75-
j = i
73+
i = self._currentBestSize
74+
while i > 0:
7675
pos = bestChromosomes[i - 1]
7776
# group is not full?
7877
if i < length_best:
@@ -85,9 +84,10 @@ def addToBest(self, chromosomeIndex):
8584
else:
8685
# group is full remove worst chromosomes in the group
8786
bestFlags[pos] = False
87+
i -= 1
8888

8989
# store chromosome in best chromosome group
90-
bestChromosomes[j] = chromosomeIndex
90+
bestChromosomes[i] = chromosomeIndex
9191
bestFlags[chromosomeIndex] = True
9292

9393
# increase current size if it has not reached the limit yet

0 commit comments

Comments
 (0)