Open Halone228 opened 2 years ago
Can you provide the minimum example of your code? Particularly the part where you try to save the GA instance?
Sometimes you use some objects that need some workaround to pickle. A minimum code sample will be helpful to figure out the issue.
Yes, pickle is the problem. In my program, I used tqdm to show the progress of the population, however, tqdm has a rate estimation mechanism that uses time, and time objects cannot be serialized.
def on_generations(self,*args):
self.tqdm.update(1)
At this point, most likely serelization fall
def update(self, n=1):
...
if self.n - self.last_print_n >= self.miniters:
cur_t = self._time()
dt = cur_t - self.last_print_t
if dt >= self.mininterval and cur_t >= self.start_t + self.delay:
cur_t = self._time()
Because in tqdm update functions uses time functions, which cannot be serialized.
Can you provide the minimum example of your code? Particularly the part where you try to save the GA instance?
@krkaufma,
This is the part of the code that saves the GA instance: https://github.com/ahmedfgad/GeneticAlgorithmPython/blob/7699a561611113d51054bc371536659551827eee/example.py#L59
Yes, pickle is the problem. In my program, I used tqdm to show the progress of the population, however, tqdm has a rate estimation mechanism that uses time, and time objects cannot be serialized.
def on_generations(self,*args): self.tqdm.update(1)
At this point, most likely serelization fall
def update(self, n=1): ... if self.n - self.last_print_n >= self.miniters: cur_t = self._time() dt = cur_t - self.last_print_t if dt >= self.mininterval and cur_t >= self.start_t + self.delay: cur_t = self._time()
Because in tqdm update functions uses time functions, which cannot be serialized.
Good that you found the issue.
You can try the cloudpickle
library. https://github.com/cloudpipe/cloudpickle
It may solve your issue. I am testing it to see if it could replace the pickle
library.
When i trying save GA instance, a got error from pickle
TypeError: cannot pickle 'Clock' object
Whats worng?