I am using scipy.optimize.differential_evolution to minimize a multi-parameter objective function in parallel. For each iteration a small minority of the population require an extremely long time to evaluate the objective function, resulting in most of my CPU cores sitting idle. Each objective function evaluation requires a call to scipy.integrate.solve_ivp, which is where I think computation is getting bogged down.
I would like to modify my objective function so that its call to solve_ivp
is abandoned if it takes too long. What would be the easiest way to do this?
I know the multiprocessing package can be used to terminate processes that take too long, but I don't think that's an option because differential_evolution
already uses multiprocessing.Pool
for parallelization, and pool processes can't create more processes?
The only other option that occurs to me is creating a modified version of solve_ivp
(source) with a built-in kill switch timer.