GeneticAlgorithmPython icon indicating copy to clipboard operation
GeneticAlgorithmPython copied to clipboard

For multi-objective optimization, Lists of Saved Best Solution Causes Error When Loadedd

Open MommyMythra opened this issue 1 year ago • 1 comments

Howdy!

I have been using pygad for a while, but I just noticed when flipping on save_best_solutions, the saved solution list is converted into a list of ndarrays as opposed to a list of lists. This creates a fundamental issue on line 1682 (I think) where the comparison throws up an ambiguity error. Using Python 3.8.

Fixed by changing line at 1887 to self.best_solutions = [arr.tolist() for arr in self.best_solutions]

May need to differentiate between multi-objective and single-objective optimization. This error may also exist with line 1893 with save_solutions.

Cheers, Mythra

MommyMythra avatar Sep 11 '24 22:09 MommyMythra

Thanks. This issue will be fixed in the next release!

ahmedfgad avatar Jan 07 '25 18:01 ahmedfgad