parfor error for global SA Morris method using SimBiology
古いコメントを表示
hi, I am trying to use parallel toolbox to speed up my global SA with Morris method. Basically it averages elementary effects for a specific parameters across the entire parameter space. An elementary effect is calculated as EE = (f(p) - f(p+delta))/delta. For more details see Wentworth et al. J. UNCERTAINTY QUANTIFICATION, Vol. 4, pp. 266–297 (https://projects.ncsu.edu/crsc/reports/ftp/pdf/crsc-tr15-01.pdf).
So far I failed with my attempts, such as for this code - here using SimBiology 'sbioselect' and 'sbiosimulate'
clear variables; close all; clc;
format shortG
r = 5; % number of trajectories
l = 10; s = 2;
delta = l/(s*(l-1));
disp("Load model & parameter file")
paramsFile = strcat('PARAMETERS/Lotka_parameters.csv');
paramsDF = readtable(paramsFile);
sbioloadproject('SBPROJ/lotka.sbproj','m1')
p = length(paramsDF.parameter);
% Morris ===========================================================
d = zeros(r,p);
for i = 1:r
f = zeros(1,(p+1));
% an example for the Morris C matrix capturing one trajectory in parameter space
C = [15 0.085556 15;
15 0.005 15;
15 0.005 9.4444;
9.4444 0.005 9.4444];
% for each trajectory for p parameters, there are p+1 evaluations to be made
for j = 1:(p+1)
for k = 1:size(C,2) % columns = parameters
blub = sbioselect(m1, 'Name', paramsDF.parameter(k));
blub.Value = C(j,k);
end
[t,y] = sbiosimulate(m1);
f(j) = y(end,varNo); % looking for the endpoint as the sensitivity function
end
% Calculating elementary effects
v = zeros(1,p);
for j = 1:p
Cindex = find(diff(C(:,j)) ~= 0);
v(j) = ((f(Cindex) - f(Cindex+1))/delta;
end
d(i,:) = v;
end
%% disp("Calculating EE statistics")
... based on d(i,j)
Although the code is correct from the syntaxt point of view, at run time I get the error:
Load model & parameter file
Starting parallel pool (parpool) using the 'local' profile ...
connected to 4 workers.
Error using sbiosimulate (line 136)
Expected input number 1, MOBJ, to be one of these types:
SimBiology.Model
Instead its type was double.
Error in test (line 19)
parfor i = 1:r
Any comments would be very appreciated. I attach lotka.sbproj and parametr file as well.
Best, M
採用された回答
その他の回答 (0 件)
コミュニティ
その他の回答 SimBiology コミュニティ
カテゴリ
ヘルプ センター および File Exchange で Extend Modeling Environment についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!