Replace pickle with dill
Dill is a fork of pickle that allows to serialise inner function (or class or whatever with inner structure). In a pipeline to train multiple independent algos, pygad can be used on multiprocess, with multiprocess package (not multiprocessing).
I modified and used pygad with dill and it works as expected. Would you replace pickle? I have a fork on my GitHub with dill imported as pickle and everything goes smooth on my system and pygad is spawned on several core without problems.
@SimonG85,
Thanks for your suggestion and apologize for the late follow-up.
The big issue with the pickle library is that it cannot detect the referenced object to pickle. We have to workaround it to pickle the object.
In PyGAD, this issue is represented in picking the pygad.GA objects. The fitness function is not pickled.
I tried dill and found that it can pickle the fitness function but it failed to load some variables referenced in the function.
For now, I am satisfied by the cloudpickle library (https://github.com/cloudpipe/cloudpickle). This would be the replacement of the pickle lib in PyGAD.