I am trying to distribute the evaluation of problem statement wit ProcessPoolEvaluator.
As a start, I used two tutorial problems. The first code runs perfectly, while the second crashes every time...
from platypus import NSGAII, DTLZ2, ProcessPoolEvaluator
#simulate an computationally expensive problem
class DTLZ2_Slow(DTLZ2):
def evaluate(self, solution):
sum(range(1000000))
super(DTLZ2_Slow, self).evaluate(solution)
if __name__ == "__main__":
# define the problem definition
problem = DTLZ2_Slow()
# instantiate the optimization algorithm to run in parallel
with ProcessPoolEvaluator(4) as evaluator:
algorithm = NSGAII(problem, evaluator=evaluator)
algorithm.run(10000)
# display the results
for solution in algorithm.result:
print(solution.objectives)
I get the following error message:
Traceback (most recent call last):
File "<ipython-input-197-e9efb994a9ba>", line 18, in <module>
algorithm.run(10000)
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\core.py", line 405, in run
self.step()
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\algorithms.py", line 181, in step
self.initialize()
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\algorithms.py", line 191, in initialize
super(NSGAII, self).initialize()
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\algorithms.py", line 72, in initialize
self.evaluate_all(self.population)
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\core.py", line 378, in evaluate_all
results = self.evaluator.evaluate_all(jobs)
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\evaluator.py", line 115, in evaluate_all
return [f.result() for f in futures]
File "C:\Users\Maximilian\Anaconda3\lib\site-packages\platypus\evaluator.py", line 115, in <listcomp>
return [f.result() for f in futures]
File "C:\Users\Maximilian\Anaconda3\lib\concurrent\futures\_base.py", line 435, in result
return self.__get_result()
File "C:\Users\Maximilian\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.
Hi!
I am trying to distribute the evaluation of problem statement wit ProcessPoolEvaluator. As a start, I used two tutorial problems. The first code runs perfectly, while the second crashes every time...
The first one:
The secon one:
I get the following error message:
Has anyone a guess why the second code crashes?
Thanks very much in advance
Max