0

I am trying to solve a complex optimization problem using Matlab's Particle Swarm Optimization. The objective function called in PSO solves an interior optimization problem using matlab's fsolve() function, where the solution from fsolve is used to compute the function evaluation that PSO will try to minimize.

Typically, without PSO wrapped around the problem, we run fsolve() in parallel to compute the central differences to perform gradient calculations; however, I am aware that I cannot do this if I want to run PSO in parallel since there cannot be nested parallel functions.

The next thought was to run fsolve in serial, when computing the gradients, and free up the parallel pool to allow PSO to evaluate the objective function (which involves solving the interior optimization problem) on multiple cores at the same time.

i.e.: if there are 5 particles in the swarm, I want to run each interior optimization problem on a different core simulataneously for each iteration. My question is then, is it possible (even in serial) to run fsolve on different cores simultaneously?

Unforunately, due to the nature of the work, I am unable to share the code for this work, but moreso need to figure out if this is possible before moving forward with the current direction.

Any and all thoughts on this would be greatly appreciated. Thanks!

I have tried to implement the described thought above, but am getting errors that I am unable to diagnose at the moment. I expected each particle iteration to run slower since fsolve cannot use multiple cores to compute the gradients, but overall, I thought that allowing PSO to compute each particles solution individually on different cores would still be more efficient than running all of the iterations in serial with fsolve running in parallel.

1 Answers1

0

Edit: Despite what I say below, I wasn't able to get fsolve to work inside a parfor loop or using parfeval. I get an Undefined function 'fsolve' ... error. It appears that parallel execution of fsolve is unsupported. Even if you only call it once per worker, it will still cause that worker to fail. Any iteration of fsolve inside each worker (and hence my answer below) is irrelevant.


It shouldn’t matter how many times a function is called inside each parallel worker. Each iteration is separated from the others in time. As long as the overall code block is compatible with parallel execution, the instruction stream within is executed as normal MATLAB code on each worker.

FragileX
  • 626
  • 1
  • 8