accelerating model simulations and analyses -凯发k8网页登录

main content

accelerating model simulations and analyses

what is acceleration?

normally, when simulating or analyzing a model in simbiology®, the model is expressed in matlab® code. you can accelerate the simulation by converting the model to compiled c code, which executes faster. because this compilation step has a small time overhead, acceleration is not recommended for individual simulations of small models. however, for large models, or for repeated simulations during analysis, acceleration can provide a significant speed increase that outweighs the small time overhead.

when to accelerate

the functionality to accelerate simulations performs optimally under the following conditions:

  • running repeated simulations with different initial conditions

  • running very long simulations (for example, simulations that take longer than a minute to run)

prerequisites for accelerating simulations and analyses

to prepare your models for accelerated simulations, install and set up a compiler:

  1. install a c compiler (if one is not already installed on your system). for a current list of supported compilers, see .

  2. ensure that any user-defined functions in your model can be used for code generation from matlab, so they can convert to compiled c. for more information, see language, function, and object support for c and c code generation (matlab coder) or contact .

note

  • on windows®, if you have not installed another compiler, simbiology uses the lcc-win64 compiler for model accelerations. if you have installed another supported compiler, it will be selected automatically. for better performance of the acceleration functionality, you may want to install a other than lcc-win64, and it will be selected automatically.

accelerate simulations programmatically

use if you are accelerating a simbiology model. for a simfunction object and an exported model (), use the corresponding accelerate method.

using sbioaccelerate

follow the two-step process for acceleration.

  1. run sbioaccelerate to prepare your model for accelerated simulations. use the same input arguments that you plan to use with in the next step. for example:

    sbioaccelerate(model,configset,doses);

    for a very large model, this step may take a minute or longer to complete.

  2. run with the same input arguments that you used with sbioaccelerate. for example:

    simdata = sbiosimulate(model,configset,doses);

if you pass in an array of doses to sbioaccelerate, you can simulate the model using any subset of these doses and do not need to run acceleration again.

for illustrated examples, see the following.

using accelerate

a simfunction object is automatically accelerated at the first function execution. hence it is not necessary to accelerate the model before you create the object. however, manually accelerate using the method of the object if you want it accelerated in your deployment applications.

for exported model, see .

when to rerun acceleration

if you make any modifications to the model, such as changes to reactions or adding events, you need to rerun the acceleration, before running simulations.

however, there are exceptions. you do not need to accelerate again if you are making the changes to:

  • any variants

  • property of species

  • property of compartments

  • property of parameters

  • property of configset

  • property of solveroptions

  • , , and properties of scheduledose and repeatdose

  • property of scheduledose

  • , , and properties of repeatdose

  • , , and properties of any applicable objects

accelerate simulations using simbiology model analyzer

you can enable the model acceleration in the simbiology model analyzer app by checking the prepare the model for accelerated simulation box in the model step of the program.

troubleshooting accelerated simulations

if you have custom functions, use persistent variables only for those (constant) variables that you do not want to recalculate or reload every function call. the reason is that during the acceleration process, simbiology converts the model and custom functions to compiled c code. if you try to use a persistent variable to share data across generated (or compiled) c functions, you may have different results. for instance, if you use a persistent variable to count how many times a function is called, each compiled function will have a separate count. those persistent variables in the corresponding compiled functions will be different from the one used in the matlab function that you defined.

if you specify custom functions in simbiology expressions, you might see the following warning if your code is not compatible with code generation from matlab:

the simbiology expression and any user-defined functions
could not be accelerated. please check that these expressions 
and any user-defined functions are supported for code generation
as described in the code generation from matlab documentation.

where expression is any of the following:

  • reaction rate/rule expression

  • initial assignment rule expression

  • repeated assignment rule expression

  • event trigger expression

  • event function expression

for more information, see language, function, and object support for c and c code generation (matlab coder) or contact .

see also

| | | |

related topics

网站地图