You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# The functions numpy.any()/numpy.all()/numpy.where()/numpy.equal() are very slow.
1647
1647
# So, list membership operator 'in' is used to check if the solution exists in the 'self.solutions' list.
1648
1648
# Make sure that both the solution and 'self.solutions' are of type 'list' not 'numpy.ndarray'.
1649
-
# if (self.save_solutions) and (len(self.solutions) > 0) and (numpy.any(numpy.all(self.solutions == numpy.array(sol), axis=1))):
1650
-
# if (self.save_solutions) and (len(self.solutions) > 0) and (numpy.any(numpy.all(numpy.equal(self.solutions, numpy.array(sol)), axis=1))):
1649
+
# if (self.save_solutions) and (len(self.solutions) > 0) and (numpy.any(numpy.all(self.solutions == numpy.array(sol), axis=1)))
1650
+
# if (self.save_solutions) and (len(self.solutions) > 0) and (numpy.any(numpy.all(numpy.equal(self.solutions, numpy.array(sol)), axis=1)))
1651
+
# print("BBBBBB", len(self.best_solutions))
1651
1652
if (self.save_solutions) and (len(self.solutions) >0) and (list(sol) inself.solutions):
1652
1653
solution_idx=self.solutions.index(list(sol))
1653
1654
fitness=self.solutions_fitness[solution_idx]
1655
+
elif (self.save_best_solutions) and (len(self.best_solutions) >0) and (list(sol) inself.best_solutions):
1656
+
solution_idx=self.best_solutions.index(list(sol))
1657
+
fitness=self.best_solutions_fitness[solution_idx]
1654
1658
elif (self.keep_elitism>0) and (self.last_generation_elitismisnotNone) and (len(self.last_generation_elitism) >0) and (list(sol) inlast_generation_elitism_as_list):
1655
1659
# Return the index of the elitism from the elitism array 'self.last_generation_elitism'.
1656
1660
# This is not its index within the population. It is just its index in the 'self.last_generation_elitism' array.
@@ -1859,7 +1863,7 @@ def run(self):
1859
1863
1860
1864
# Appending the best solution in the initial population to the best_solutions list.
0 commit comments