MATLAB: Parallel computing of optimization problem

optimizationparallel computing

Hi all,
I am trying to parallelize my optimization code. Below is my original code
options=optimset('TolX',1e-8,'TolFun',1e-8);
[x,resnorm,residual,exitflag] = lsqnonlin(@objfun,x0,[],[],options);
To implement parallel computing, I rewrite it into
matlabpool open 2
options=optimset('TolX',1e-8,'TolFun',1e-8,'UseParallel', 'always');
[x,resnorm,residual,exitflag] = lsqnonlin(@objfun,x0,[],[],options);
matlabpool close
After running matlab, I saw the following in the command window:
Starting matlabpool using the 'local' profile ... connected to 2 labs.
I have tested np=2, 8, 12, but the time cost does not change with the number of processors. So is there anything I missed in my code? Thanks.
Related Question