Using parfor for CVX

#1

Hello all,
I’m using CVX inside a Matlab function to solve my problem. I was able to call this function inside a parfor loop, which will save me a lot of time. It seems to be working, so can I guarantee that the result will be correct, or your recommendation is to don’t use cvx inside parfor.
Best Regards,

(Mark L. Stone) #2

Please read the answer, shoiwn below, by CVX developer mcg in this post Matlab parallel toolbox from 6 1/2 years ago. I don’t know whether anything has changed since then. If you get a result, I am not in a position to guarantee its correctness, but I am not aware of any reports in which an answer (other than NaN) has been obtained which was incorrect when using parfor,

mcgMichael C. Grant

Feb '13

CVX simply cannot be used with parfor . If it works sometimes, that’s an interesting artifact, but it should not be relied upon.

(YL) #3

You can just encapsulate CVX in a function and call the function in the parfor loop. I think the results will be reliable since the whole procedure is guaranteed. The parfor loop mechanism will ensure each independent parallel calculating process has it’s own working space in the memory and be deployed into a single cpu core. So that I think there is no difference compared calculating using only one cpu core.This is helpful when facing some problems such as using Monte Carlo simulation to validate your algorithm with different randomly generated scenarios. The core concept I think is to isolate each parallel computing completely without any local variable intertwined.