Any simulation speed differences between models loaded with SimBiology() vs sbioloadproject?
3 views (last 30 days)
Show older comments
The question is in the title. I haven't seen much difference in numerical efficiency between the same model opened in sbioloadproject versus using simbiology('mymodel.sbproj). Is this your experience? Am I missing something?
Some background: [Note: I'm using v2019b to remain in sync with one of my clients, so this may have changed in new releases]. In response to earlier questions I've learned that sbioloadproject does not load the graphical layout of the model, and that sbiosaveproject doesn't save this positional notation. The upshot is that a model that is loaded with simbiology or with sbioloadproject and then saved using sbiosaveproject will lose all positional notation. A very carefully laid out model subjected to this load and save sequence goes from well-organized and understandable to ... a bowl of spaghetti (with Species being meatballs, I suppose). In my opinion, graphical layout is exceptionally important in discussing a model with non-modelers. As in "make or break" in terms of credibility. For this reason, I cannot envision any use for the sbiosaveproject command.
The workaround is to open the model interactively with Simbiology('mymodel.sbproj' for example), then run scripts, then save interactively using "Save as" from the SB dashboard. One other point that I've been coached on by the excellent technical support from Mathworks is that the simbiology() command to open a model is not useful "as is" in scripts now because it returns control of the program to the script before opening the model. So a script
mc = simbiology('mymodel.sbproj');
sbiosimulate(mc);
throws an error that the handle mc doens't point to a model. So the simbiology() and "Save As" commands must be interactive. If you want to preserve positional notation and add to or change the model with scripts you cannot run batch files exclusively.
The question above pertains to scripts that open the model and use it but just generate output data which can be saved in batch files as .mat files and such. That is, how much of a numerical penalty am I incurring opening the model in simbiology() vs sbioloadproject?
If there is little difference in speed of model execution, then some cool workarounds would be
simbiology('mymodel.sbproj','ExecuteBeforeReturn',true); % True would force simbiology to open the model before returning control to a script.
% default is false. This would allow simbiology in scripts
or
sbioloadproject('mymodel.sbproj','LoadPositional', true); % This would load the same positional stuff that simbiology() loads.
Default would be true to avoid inadvertently losing positional info. A false flag could be set if, for example, this would result in much faster execution.
One or the other of the above would allow a script to open a model without information loss. To complement this a change in sbiosaveproject would allow the use of models with meaningful graphical layouts to be modified in scripts and saved without information loss. So sbiosaveproject('mymodel.sbproj') should check to see if the positional stuff is loaded, and if so, should save it in the sbproj file.
If there is a significant loss of computational speed when simbiology() is used to load the model, then the workaround is just to use sbioloadproject, do the calculations, save the results, and then exit without saving.
If one is just using scripts to create models and the graphical layout is immaterial, then sbioloadproject and sbiosaveproject would seem to work "as is". But then one must figure out how to explain matlab script code to biologists and physicians and scientists who may be, to put it mildly, "math averse". :>D
As always, thanks!
0 Comments
Accepted Answer
Arthur Goldsipe
on 19 May 2020
I don't expect you to see any noticeable performance impact when simulating a model from the command line, while the same model is open in the SimBiology app. When you modify a model from the command line, there is some overhead in communicating model changes to the model to the app. I can imagine some rare cases where that overhead could be noticeable.
So, until MathWorks gives you a better option (which is definitely on our radar), I suggest you do what you propose: Keep the model open in the app while working with it from the command line.
More Answers (0)
See Also
Categories
Find more on Extend Modeling Environment in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!