Skip to Main Content Skip to Search
Product Documentation

Accelerating Model Simulations and Analyses

What Is Acceleration?

Normally, when simulating or analyzing a model in SimBiology, you express the model in MATLAB code. You can accelerate the simulation or analysis 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.

What Simulations and Analyses Can Be Accelerated?

You can accelerate the following:

When to Accelerate Simulations and Analyses

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

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 Supported and Compatible Compilers at www.mathworks.com.

      Tip   On 32-bit Windows® platforms, the lcc compiler is automatically installed. However, for better performance of the acceleration functionality, you may want to install a supported compiler other than lcc. You can also use mex -setup to choose and configure a different C compiler, as described in Building MEX-Files in the MATLAB External Interfaces documentation.

  2. Run mex -setup once after compiler installation, as described in the mex reference page.

  3. 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 the Code Generation from MATLAB Code.

Accelerating a Simulation or Analysis

Accelerating simulations is a two step process:

  1. Use the sbioaccelerate function to prepare your model for accelerated simulations. Use the same input arguments that you plan to use with sbiosimulate. For example:

    sbioaccelerate(modelObj, configsetObj, doseObj);

    This step prepares your model for acceleration and may take a minute or longer to complete for very large models.

      Note   You need to run sbioaccelerate again, before running simulations, if you make any modifications to this model, other than:

      • Changes to any variants

      • Changes to values for the InitialAmount property of species

      • Changes to the Capacity property of compartments

      • Changes to the Value property of parameters

  2. Use the sbiosimulate function with the same input arguments that you used with sbioaccelerate. For example:

    simdataObj = sbiosimulate(modelObj, configsetObj, doseObj);

Troubleshooting Accelerated Simulations and Analyses

If you have user-defined functions, do not use persistent variables in these functions. Persistent variables are not compatible with the functionality used for accelerating simulations.

If you specify user-defined 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:

For more information, see the Code Generation from MATLAB documentation.

  


Free Computational Biology Interactive Kit

See how to analyze, visualize, and model biological data and systems using MathWorks products.

Get free kit

Trials Available

Try the latest computational biology products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS