Timing out long running evaluation?

49 views
Skip to first unread message

Carl Gold

unread,
May 4, 2018, 8:38:13 AM5/4/18
to deap-users
Is it possible to use a multiprocessing pool but kill any evaluation that runs past a certain time?   The next generation would be formed from just those individuals that completed evaluation under the threshold (the duration of my evaluations depends on the individual).  I imagine I could do this in the evaluation code, but I am wondering if there is a way to set a timeout at the pool level.  Thanks!

Carl

Mark Sale

unread,
Jul 28, 2021, 8:30:11 AM7/28/21
to deap-users
Carl posted this question 3 years ago, I have the same question, long running calcalution of fitness, would like to time it out, using multi processing - any ideas?

Derek Tishler

unread,
Jul 28, 2021, 11:37:50 AM7/28/21
to deap-users
Instead of using Deap or specifically Deap's toolbox to manage the evaluation with the registered pool's map function, you could manually launch the evaluation and check each process's status to implement a timeout. Perhaps something like:
https://stackoverflow.com/questions/26063877/python-multiprocessing-module-join-processes-with-timeout

For people new to deap: Deap is simply using map to pass the list of Individuals to the eval function. So instead of relying on Deap to perform this with no code/little changes, you can modify the algorithm(for example if using eaSimple() copy it from github source to your project and call it directly once modified) to implement any python code you like such as the above mentioned edit of manually managing the pool.

Mark Sale

unread,
Jul 28, 2021, 1:22:19 PM7/28/21
to deap-...@googlegroups.com
thanks Derek
That is pretty much what I'm doing, setting up a queue, using subprocess.Popen to poll them, start new ones. Works pretty well, just thought there might be an "official" method, using multiprocess rather than manually setting up the queue


--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deap-users/54a4e04a-0a27-401f-9e08-8eb24479faf9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages