Open
Description
On line 1683 in pygad.py the code says
solution_idx = self.best_solutions.index(list(sol))
apparently assuming that self.best_solutions
is always a list
. However, it is possible that self.best_solutions
is a numpy.ndarray
, in which case the index
method is undefined and the program crashes.
Adding
if type(self.best_solutions) is numpy.ndarray:
self.best_solutions = self.best_solutions.tolist()
before the first if statement (if (self.save_solutions) and (len(self.solutions) > 0) and (list(sol) in self.solutions):
) seems to resolve the issue.