Different answer using Box-Jenkins identification inside parfor loop

1 view (last 30 days)
I am using the Box-Jenkins method in the System Identification toolbox to identify a system from some experimental data, and am looping over several different i/o delays to find which gives the smallest RMS modelling error. I want to use a parfor loop for speed, however this is giving me an inaccurate answer. The following code reproduces my error:
clear;
load iddemo_heatexchanger_data
Data = iddata(ct,pt,Ts);
nb = 5;
nf = 5;
nc = 5;
nd = 5;
nk = 10;
anspar = 0;
parfor i = 1:1
BJModel = bj(Data,[nb nc nd nf nk],'focus','simulation');
ct_BJ = lsim(BJModel,pt,t);
anspar(i) = rms(ct-ct_BJ);
end
ansfor = 0;
for i = 1:1
BJModel = bj(Data,[nb nc nd nf nk],'focus','simulation');
ct_BJ = lsim(BJModel,pt,t);
ansfor(i) = rms(ct-ct_BJ);
end
BJModel = bj(Data,[nb nc nd nf nk],'focus','simulation');
ct_BJ = lsim(BJModel,pt,t);
ansnoloop = rms(ct-ct_BJ);
This gives me 1.3126 for ansfor and ansnoloop, but 1.3123 for anspar. The disparity between the parfor loop answer and the for loop/no loop answers is even larger with the data set I am using. Any ideas what might be causing this?
  3 Comments
Edric Ellis
Edric Ellis on 22 Oct 2014
One difference that may be relevant is that parallel pool workers run in single computational thread mode. Try launching your MATLAB client using the -singleCompThread command-line option and comparing the results.
Chris
Chris on 22 Oct 2014
This does indeed make the answers match. The difference seems to be in the Box-Jenkins models rather than the simulation stage, and the parallel loop seems to produce better results, so as long as I always find the models in parallel hopefully it should be ok.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!