Simulating the Model with a Stochastic Solver

SimBiology® software includes three stochastic solvers. The stochastic solvers more accurately calculate the change in species amounts with a small number of molecules.

  1. Get the active configuration set for the model, Mobj.

    cs = getconfigset(Mobj)
     Configuration Settings - default (active)
         SolverType:                  ode15s
         StopTime:                    10
    
       SolverOptions:
         AbsoluteTolerance:           1.000000e-006
         RelativeTolerance:           1.000000e-003
         SensitivityAnalysis:         false
    
       RuntimeOptions:
         StatesToLog:                 all
    
       CompileOptions:
         UnitConversion:              false
         DimensionalAnalysis:         true
    
       SensitivityAnalysisOptions:
         Inputs:                      0
         Outputs:                     0
    

    The configset object, cs, contains all the simulation settings, including the stop time and solver.

  2. Set the SolverType to the ssa stochastic solver, and list the configuration set again.

    set(cs, 'SolverType', 'ssa');
    cs 

    Notice that the SolverOptions for the stochastic solver are different from the ODE options.

    Configuration Settings - default (active)
         SolverType:                  ssa
         StopTime:                    10.000000
    
       SolverOptions:
         LogDecimation:               1
    
       RuntimeOptions:
         StatesToLog:                 all
    
       CompileOptions:
         UnitConversion:              false
         DimensionalAnalysis:         true
    
       SensitivityAnalysisOptions:
         Inputs:                      0
         Outputs:                     0
  3. Change the value for the LogDecimation property.

    cs.SolverOptions.LogDecimation = 10;
    

    Increasing this setting lets you record fewer data points and decrease run time.

  4. Run the simulation.

    [t_ssa, x_ssa] = sbiosimulate(Mobj, cs);
  5. Plot the results.

    FH1 = figure;
    set(gcf, 'color', 'white');
    plot(t_ssa,x_ssa(:,1:4));
    title('Gene Regulation with SSA Solver');
    xlabel('Time (second)');
    ylabel('Amount (molecule)');
    axis([0, 10, 0, 50]);

    The resulting plot may resemble the following figure.

  6. Another method to visualize stochastic simulations is through ensemble runs.

    simDataObj = sbioensemblerun(Mobj, 10, cs);
    sbiosubplot(simDataObj);

    The resulting plot may resemble the following:

    • Click Back or Forward to navigate through the plots.

      Note:   To remove the model object from the Workspace type

      delete(Mobj);

See Also

Was this topic helpful?