Apply Parallel Computing to Simbiology

3 Ansichten (letzte 30 Tage)
Jesse Chao
Jesse Chao am 19 Jul. 2021
Kommentiert: Jesse Chao am 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

Akzeptierte Antwort

Arthur Goldsipe
Arthur Goldsipe am 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 Kommentare
Arthur Goldsipe
Arthur Goldsipe am 21 Jul. 2021
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 am 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  SimBiology Community

Kategorien

Mehr zu Scan Parameter Ranges finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by