Problem with parallel run of Pattern Search (Global Optimization)

5 views (last 30 days)
Hi All, I have a problem with running pattern search, using 4 available cpu cores. I change the 'UseParallel' default to 'on' with psoptimset, but it only uses 1 cpu core. matlabpool size returns 4 (so I am connected to 4 cpu cores.) If I use fmincon, with 'UseParallel' --> 'on' it uses 4 cpus, but it does not work with pattern search. Any Idea?

Answers (1)

Konrad Malkowski
Konrad Malkowski on 18 Apr 2011
Hi Sina, Have you taken a look at the following:
There are certain conditions that have to be met for patternsearch to take advantage of Parallel Computing Toolbox. It is hard to guess from your brief description.
cheers
Konrad
  2 Comments
Sina
Sina on 19 Apr 2011
Hi Konrad; I tried a simple optimization problem. below you can find the code and the results. Using parallel toolbox makes the process much slower !!!
the code:
function test
clear all
clc
x0 = [10 10];
lb = [0 0];
ub = [20 20];
Options=psoptimset('PollMethod','GSSPositiveBasisNp1','UseParallel','always'...
,'CompleteSearch','on','CompletePoll', 'on', 'Vectorized', 'off','Display','off' ); %,'UseParallel','always','Vectorized','on'
% Solving regularly, without parallel toolbox
t=tic;
for j=1:100
x = patternsearch(@OBJ,x0,[],[],[],[],lb,ub,Options);
end
t=toc(t);
matlabpool size;
fprintf('ElapsedTime=%6.3f PoolSize=%2.1f\n',t,ans);
% Solving with parallel toolbox, with different matlabpool sizes
for n=1:4
command = ['matlabpool open ' num2str(n)];
eval(command)
t=tic;
for j=1:100
x = patternsearch(@OBJ,x0,[],[],[],[],lb,ub,Options);
end
t=toc(t);
matlabpool size;
fprintf('ElapsedTime=%6.3f PoolSize=%2.1f\n',t,ans);
matlabpool close
end
end
function y = OBJ(x)
y = ( 4 - 2.1*x(1)^2 + x(1)^(4/3) )*x(1)^2 ...
+ x(1)*x(2) + ( -4 + 4*x(2)^2 )*x(2)^2;
end
the printed results on Command Window:
ElapsedTime= 4.360 PoolSize=0.0
Starting matlabpool using the 'local' configuration ... connected to 1 labs.
ElapsedTime=51.672 PoolSize=1.0
Sending a stop signal to all the labs ... stopped.
Starting matlabpool using the 'local' configuration ... connected to 2 labs.
ElapsedTime=57.076 PoolSize=2.0
Sending a stop signal to all the labs ... stopped.
Starting matlabpool using the 'local' configuration ... connected to 3 labs.
ElapsedTime=54.798 PoolSize=3.0
Sending a stop signal to all the labs ... stopped.
Starting matlabpool using the 'local' configuration ... connected to 4 labs.
ElapsedTime=57.315 PoolSize=4.0
Sending a stop signal to all the labs ... stopped.
>>
Konrad Malkowski
Konrad Malkowski on 20 Apr 2011
Hi Sina,
This looks like a case where the overhead of parallel computation (i.e., communication, synchronization, etc) outweigh the performance benefits of running in parallel. Try a problem that requires a much longer execution time per iteration of the objective function.

Sign in to comment.

Categories

Find more on Platform and License in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!