Using parfor for CVX

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,

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.

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.

Hi, yl_convexopt. Recently, I also encapsulated CVX in a function and call the function in the parfor loop, but I kept receiving a warning as,
Warning: A non-empty CVX problem already exists in this scope.
It is being overwritten.

In cvxprob (line 28)
In cvx_begin (line 41)
In SSR (line 11)
In parallel_function>make_general_channel/channel_general (line 923)
In remoteParallelFunction (line 46)

It seems that some cores did not finish the current optimization process and then being occupied by another process.