Jesse Chao in MATLAB Answers
Last activity 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
Colton Harper in MATLAB Answers
Last activity on 15 Sep 2020

In March of 2020, there was a question about parfor loops and simbiology. (https://www.mathworks.com/matlabcentral/answers/510565-issues-with-doses-variants-in-parfor-loop-in-simbiology?s_tid=srchtitle) I currently use a parfor loop, but my model is fairly large and uses a lot of molecules -- around 40 species and 40 reactions. As a result, it takes a very long time to obtain my results. I was wondering if you think SimFunction (along with 'UseParallel' and 'AutoAccelerate') would be appropriate for me to use. -- Below, you'll find that I use a parfor appoach and make sure the files are accessible through the latter two functions. After seeing the aforementioned post, I'm wondering if I should be using SimFunction, sbiosimulate, sbioaccelerate, sbioensemblerun, or another method to optimize my approach. Here is the general structure for what I am trying to accomplish: I am using SimBiology 2019b. The solver I need to use is SSA, monte carlo style. I have a chemical reaction network set up. I add an event at 3000 seconds to set the concentration of an 'input' species to a given value. I have a species in the chemical reaction network that I view as the 'output' species. My goal is to run 100 simulations for each given input amount. Then, I would like to increase the input amount over 100 steps in a uniformly increasing manner at each step and observe the behavior of the 'output' species. Here is the structure of my code: for i = 1:100 %100 steps with uniform increasing 'input' species amounts sbioloadproject('model.sbproj'); cs = getconfigset(m1, 'default'); cs.SolverType = 'ssa'; solver = cs.SolverOptions; solver.LogDecimation = 1000; inputSpecies = sbioselect(m1,'Type','species','Name','inputSpecies'); %The 'input' species inputSpecies.InitialAmount = 0; parameterTimeunits = addparameter(m1,'Timeunits',1.0,'ValueUnits','minute','ConstantValue',true); parameterMolunits = addparameter(m1,'Molunits',1.0,'ValueUnits','molecule','ConstantValue',true); inputSpecies = addevent(m1, '(time/Timeunits) >= 3000', ['inputSpecies = (1500000*' num2str(i) ')*Molunits']); sbiosaveproject modelParallel.sbproj m1 inputSpecies clear m1; %simulate the model parfor j=1:100 %Number of simulation runs per input step [m1,inputSpecies] = loadSimBiologyModel('modelParallel.sbproj'); [t,x,names] = sbiosimulate(m1); parsave(['StochasticTest_Input' num2str(i) '_Instance' num2str(j)], inputSpecies, t, x, names); end end function [m2,inputSpecies2] = loadSimBiologyModel(filename) sbioloadproject(filename); m2 = m1; inputSpecies2 = inputSpecies; end function parsave(fname,inputSpecies,t,x, names) save(fname,'inputSpecies','t','x','names'); end %I'll then take all these datafiles, interpolate them, and combine it into one dateset. %Then I'll observe the amount of output over time for the varying range of input. With my current approach, I haven't become very familiar with parameters or doses. Would you be able to provide me some insights on A.) if SimFunciton (along with 'UseParallel' and 'AutoAccelerate') is appropriate and if so, B.) since the parameters and doses don't seem applicable to my setup, how can I adapt the function inputs appropriately? Any tips, suggestions, or critiques are happily welcomed. If you need any more info, please let me know.