MATLAB Answers

Apply Parallel Computing to Simbiology

2 views (last 30 days)
Jesse Chao
Jesse Chao on 19 Jul 2021
Commented: Jesse Chao on 23 Jul 2021
Hello guys,
Please bare with my naive, if I ask something silly. It is my first time try to use the parallel computing.
Beacuse my model in Simbiology is quite complicated, I am trying to use parallel computing toolbox to speed up my model fitting.
However, I got this error and I could not eliminate it... I don't know if my code is wrong completely or I misunderstand the application of the parallel computing toolbox or it is able to be fixed.
Here is my code.
%%
% Estimate Parameters
EstimationFunction = {'lsqnonlin', 'fmincon', 'fminunc'};
parfor i = 1:length(EstimationFunction)
fitConst = sbiofit(model,gData,responseMap,estimatedParams,dose, string(EstimationFunction(i)),[],variants,...
'ErrorModel','constant','ProgressPlot',true);
% Plot Results
s = struct;
s.Labels.XLabel = 'Time (hour)';
s.Labels.YLabel = 'Concentration (microgram/milliliter)';
plot(fitConst,'AxesStyle',s);
plotActualVersusPredicted(fitConst);
plotResidualDistribution(fitConst);
fitProp = sbiofit(model,gData,responseMap,estimatedParams,dose,string(EstimationFunction(i)),[],variants,...
'ErrorModel','proportional','ProgressPlot',true);
% Plot Results
plot(fitProp,'AxesStyle',s);
plotActualVersusPredicted(fitProp);
plotResidualDistribution(fitProp);
fitExp = sbiofit(model,gData,responseMap,estimatedParams,dose,string(EstimationFunction(i)),[],variants,...
'ErrorModel','exponential','ProgressPlot',true);
% Plot Results
plot(fitExp,'AxesStyle',s);
plotActualVersusPredicted(fitExp);
plotResidualDistribution(fitExp);
fitComb = sbiofit(model,gData,responseMap,estimatedParams,dose,string(EstimationFunction(i)),[],variants,...
'ErrorModel','combined','ProgressPlot',true);
% Plot Results
plot(fitComb,'AxesStyle',s);
plotActualVersusPredicted(fitComb);
plotResidualDistribution(fitComb);
%%
% Information Criteria for Model Selection
allResults = [fitConst,fitProp,fitExp,fitComb];
ErrorModelNames = {'constant error model','proportional error model','exponential error model',...
'combined error model'};
LogLikelihood = [allResults.LogLikelihood]';
AIC = [allResults.AIC]';
BIC = [allResults.BIC]';
t1 = table(LogLikelihood,AIC,BIC);
t1.Properties.RowNames = ErrorModelNames;
end
Here is the error I got.
Error using SimBiology.fit.internal.plots.liveplots.Dashboard/initializePlots
Cannot set WindowStyle to 'docked' when MATLAB is started with no display or when the -noFigureWindows option is specified.
Error in SimBiology.fit.internal.plots.liveplots.Dashboard
Error in SimBiology.fit.internal.plots.liveplots.Controller/createDashboard
Error in SimBiology.fit.internal.FitObject/initializeLivePlotsController (line 770)
obj.LivePlotsController.createDashboard(bounds);
Error in SimBiology.fit.internal.FitObject/fit (line 169)
[obj, cleanupDashboard] = obj.initializeLivePlotsController(); %#ok<ASGLU>
Error in sbiofit (line 298)
[varargout{1:nargout}] = fitObject.fit(modelObj, data, responseMap, estimInfo, varargin{:});
Error in runfitdoxdata20200223model (line 131)
parfor i = 1:length(EstimationFunction)
Please give me any suggestion or advice. Thank you very much.
Have a nice day.
Jesse

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 20 Jul 2021
Hi Jesse,
The simplest fix would be to change 'ProgressPlot',true to 'ProgressPlot',false. The issue is that you're trying to create plots on workers, but the workers do not have a display.
Another option would be to rely on sbiofit to do the parallelization by changing the parfor to a for loop and adding the name-value argument 'UseParallel',true to the sbiofit calls. This would allow you to keep the progress plots.
Also, it's not clear which of these approaches will be faster. A lot depends on the details of your problem and your parallel computing setup.
-Arthur
  2 Comments
Jesse Chao
Jesse Chao on 23 Jul 2021
Hello Arthur,
Thank you very much for your explicit answer. I managed to solve this problem by using the suggestion you provided.
Thank your very much.
Have a nice day.
Jesse

Sign in to comment.

More Answers (0)

Communities

More Answers in the  SimBiology Community

Community Treasure Hunt

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

Start Hunting!