0

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.

Jack Elsey
  • 134
  • 1
  • 13
  • 1
    Find out parameters where it takes long and discover the reason that integration takes so long. It is likely that the step size goes to zero. This is often due to a singularity in the function, like a division that goes too close to zero, certain jumps that should enter sliding mode, ... Make that singularity less singular, using smooth approximations that differ from the original only in a small interval. Change the solver method to DOP853 or Radau. Cut the vector field off to be constant or linearly growing outside some region-of-interest,... – Lutz Lehmann Mar 19 '21 at 00:43
  • @LutzLehmann Thanks. I was able to solve my problem by changing to the LSODA solver. – Jack Elsey Mar 27 '21 at 13:44

0 Answers0