I am using Pygad to compute an optimization problem, however the algorithm is reaching local minima (not the ideal solution) before all the generations have run. I would like to be able to check after each generation if the fitness has saturated for a certain number of generations and if so reinitialize a new population using the 'sol per pop', 'gene number', and 'gene space' from the current instance. Is this possible to do in Pygad? Any help would be appreciated.
I have tried to setup the 'On Generation' callback, but I can't seem to find anyway to call a new population initialization and pass it back into the 'population' attribute.
This is an example that applies what you mentioned. If the fitness saturates for 10 generations, a new population is generated.