Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
565 stars 153 forks source link

Pickle bug during parallelization #114

Closed simon19891101 closed 4 years ago

simon19891101 commented 4 years ago

Hi there, has anyone got "TypeError: can't pickle _thread.lock objects" during parallelization? I'm using python 3.7.3 and platypus 1.0.3. Much appreciated for your help!

My parallelization is below:

with ProcessPoolEvaluator(10) as evaluator:
    algorithm = NSGAII(problem, population_size=n_population, evaluator=evaluator)
    algorithm.run(n_population*n_generation)
simon19891101 commented 4 years ago

Resolved. Have to tightly follow the way the functions are imported as in https://github.com/Project-Platypus/Platypus/blob/master/examples/simple_parallel.py instead of using

from platypus import *

dhadka commented 4 years ago

@simon19891101 Thanks for reporting this. I'm going to create a separate issue to look into fixing the imports. Ideally, from platypus import * should work.

simon19891101 commented 4 years ago

Hi @dhadka, thanks. Had a go for "from platypus import *" and it worked this time. Probably because the python was upgraded from 3.6.8 to 3.7.3.