Open acidnik opened 10 months ago
found the workaround myself:
try:
ga_instance = pygad.load('test')
ga_instance.fitness_func = fitness_func
still, would be nice to reflect this in documentation
PyGAD uses the cloudpickle
library which is able to pickle not only the objects but also the functions. So, yes the fitness function is pickled.
When you run the code for the first time with the commented print statement, then the cloudpickle
library saves the fitness function with the print line commented.
After loading the saved cloudpickle
object, it loads the saved fitness function with the commented print statement.
As you suggested, you can force change the fitness function by setting the fitness_func
attribute.
steps to reproduce:
expected results:
TEST TEST TEST
being printedactual results: nothing happens
does this means that the code of fitness function is saved too? is there a way to update my code after the ga was saved?