Apply Parallel Computing to Simbiology

3 次查看(过去 30 天)
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

采纳的回答

Arthur Goldsipe
Arthur Goldsipe 2021-7-20
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 个评论
Arthur Goldsipe
Arthur Goldsipe 2021-7-21
A co-worker just pointed out to me that plotting functions can usually be done on workers, even though the plots don't display. So I took another look. I suspect that part of the problem is that you've set your default figure WindowStyle to 'docked', which is not currently supported on parallel workers. You can also prevent this error (and other future errors if you try to run plotting code on workers) by setting the default figure WindowStyle back to 'normal'. (See here for more details on setting default graphics properties.)
Jesse Chao
Jesse Chao 2021-7-23
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

请先登录,再进行评论。

更多回答(0 个)

社区

更多回答在  SimBiology Community

类别

Help CenterFile Exchange 中查找有关 Scan Parameter Ranges 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by