gillespy2.solvers package

Subpackages

Module contents

class gillespy2.solvers.CLESolver(model=None, debug=False)[source]

Bases: GillesPySolver

A Chemical Langevin Equation Solver for GillesPy2 models.

This solver uses an algorithm that calculates multiple reactions in a single step over a given tau step size. The change in propensities over this step are bounded by bounding the relative change in state, yielding greatly improved run-time performance with very little trade-off in accuracy.

Parameters:

model (gillespy2.Model) – The model on which the solver will operate.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by CLE_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'CLESolver'
pause_event = None
rc = 0
result = None
run(model=None, t=None, number_of_trajectories=1, increment=None, seed=None, debug=False, profile=False, live_output=None, live_output_options={}, timeout=None, resume=None, tau_tol=0.03, **kwargs)[source]

Function calling simulation of the model. This is typically called by the run function in GillesPy2 model objects and will inherit those parameters which are passed with the model as the arguments this run function.

Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int or float) – Simulation run time.

  • number_of_trajectories – The number of times to sample the chemical master equation. Each

trajectory will be returned at the end of the simulation. By default number_of_trajectories = 1. :type number_of_trajectories: int

Parameters:
  • increment (float) – Save point increment for recording data.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • debug (bool) – Set to True to provide additional debug information about the simulation.

  • profile (bool) – Set to True to provide information about step size (tau) taken at each step.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – Contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

  • tau_tol (float) – Tolerance level for Tau leaping algorithm. Larger tolerance values will result in larger tau steps. Default value is 0.03.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

stop_event = None
class gillespy2.solvers.NumPySSASolver(model=None)[source]

Bases: GillesPySolver

This solver produces simulations of systems via Stochastic Simulation Algorithm.

Parameters:

model (gillespy2.Model) – The model on which the solver will operate.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by the ssa_solver.run :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'NumPySSASolver'
pause_event = None
rc = 0
result = None
run(model=None, t=None, number_of_trajectories=1, increment=None, seed=None, debug=False, live_output=None, live_output_options={}, timeout=None, resume=None, **kwargs)[source]

Run the SSA algorithm. Uses a NumPy array for storing results and for generating the timeline.

Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int or float) – The end time of the solver.

  • number_of_trajectories (int) – Number of trajectories to simulate. By default number_of_trajectories = 1.

  • increment (float) – The time step of the solution.

  • seed (int) – The random seed for the simulation. Defaults to None.

  • debug (bool) – Set to True to provide additional debug information about the simulation.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – dictionary contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

stop_event = None
class gillespy2.solvers.ODECSolver(model: Optional[Model] = None, output_directory: Optional[str] = None, delete_directory: bool = True, resume=None, variable: bool = False)[source]

Bases: GillesPySolver, CSolver

This Solver produces the deterministic continuous solution via Ordinary Differential Equations. Uses integrators from SUNDIALS to perform calculations used to produce solutions.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by odc_c_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

static get_supported_integrator_options()[source]

Get the supported integrator options

name = 'ODECSolver'
run(model: Model = None, t: int = None, number_of_trajectories: int = 1, timeout: int = 0, increment: int = None, seed: int = None, debug: bool = False, profile: bool = False, variables={}, resume=None, live_output: str = None, live_output_options: dict = {}, integrator_options: dict[str, float] = None, **kwargs)[source]
Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int) – End time of simulation.

  • number_of_trajectories (int) – Number of trajectories to simulate. This is deterministic and will always have same results.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • increment (float) – Time step increment for plotting.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • variables (dict) – Dictionary of species and their data that will override existing species data.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – Dictionary that contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

target = 'ode'
class gillespy2.solvers.ODESolver(model=None)[source]

Bases: GillesPySolver

This solver produces the deterministic continuous solution via Ordinary Differential Equations. Uses integrators from scipy.integrate.ode to perform calculations used to produce solutions.

Parameters:

model (gillespy2.Model) – The model on which the solver will operate.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by ode_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'ODESolver'
pause_event = None
rc = 0
result = None
run(model=None, t=None, number_of_trajectories=1, increment=None, integrator='lsoda', integrator_options={}, live_output=None, live_output_options={}, timeout=None, resume=None, **kwargs)[source]
Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int or float) – End time of simulation.

  • number_of_trajectories – Number of trajectories to simulate. By default number_of_trajectories = 1.

This is deterministic and will always have same results. :type number_of_trajectories: int

Parameters:
  • increment (float) – Time step increment for plotting.

  • integrator (str) – integrator to be used from scipy.integrate.ode. Options include ‘vode’, ‘zvode’, ‘lsoda’, ‘dopri5’, and ‘dop853’. For more details, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.ode.html

  • integrator_options (dict) – a dictionary containing options to the scipy integrator. for a list of options, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.ode.html. Example use: {max_step : 0, rtol : .01}

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – dictionary contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

stop_event = None
class gillespy2.solvers.SSACSolver(model: Optional[Model] = None, output_directory: Optional[str] = None, delete_directory: bool = True, resume=None, variable: bool = False)[source]

Bases: GillesPySolver, CSolver

This solver produces simulations of systems via Stochastic Simulation Algorithm.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by ssa_c_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'SSACSolver'
run(model: Optional[Model] = None, t: Optional[int] = None, number_of_trajectories: int = 1, timeout: int = 0, increment: Optional[int] = None, seed: Optional[int] = None, debug: bool = False, profile: bool = False, variables={}, resume=None, live_output: Optional[str] = None, live_output_options: dict = {}, **kwargs)[source]

Call out and run the solver. Collect the results.

Parameters:
  • model (gillespy.Model) – The model on which the solver will operate.

  • t (int) – The end time of the solver

  • number_of_trajectories (int) – The number of times to sample the chemical master equation. Each trajectory will be returned at the end of the simulation.

  • increment (float) – The time step of the solution

  • seed (int) – The random seed for the simulation. Defaults to None.

  • debug (bool) – Set to True to provide additional debug information about the simulation.

Returns:

Simulation trajectories.

target = 'ssa'
class gillespy2.solvers.TauHybridCSolver(model=None, output_directory=None, delete_directory=True, resume=None, variable=False, constant_tau_stepsize=None)[source]

Bases: GillesPySolver, CSolver

This solver uses a root-finding interpretation of the direct SSA method, along with ODE solvers to simulate ODE and Stochastic systems interchangeably or simultaneously.

class ErrorStatus(value)[source]

Bases: IntEnum

An enumeration.

INTEGRATOR_FAILED = 3
INVALID_AFTER_SSA = 4
LOOP_OVER_INTEGRATE = 2
NEGATIVE_STATE_AT_BEGINING_OF_STEP = 6
NEGATIVE_STATE_NO_SSA_REACTION = 5
UNKNOWN = 1
classmethod get_solver_settings()[source]

Returns a list of arguments supported by tau_hybrid_c_solver.run. :return: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

classmethod get_supported_features()[source]

Get the set of supported features.

classmethod get_supported_integrator_options() Set[str][source]

Get the supported integrator options

name = 'TauHybridCSolver'
run(model: Model = None, t: int = None, number_of_trajectories: int = 1, timeout: int = 0, increment: int = None, seed: int = None, debug: bool = False, profile: bool = False, variables={}, resume=None, live_output: str = None, live_output_options: dict = {}, tau_step: int = 0.03, tau_tol=0.03, integrator_options: dict[str, float] = None, use_root_finding=False, **kwargs)[source]
Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int) – End time of simulation.

  • number_of_trajectories (int) – Number of trajectories to simulate. By default number_of_trajectories = 1.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • increment (float) – Time step increment for plotting.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • variables (dict) – Dictionary of species and their data that will override existing species data.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – dictionary contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • tau_tol – Tolerance level for Tau leaping algorithm. Larger tolerance values will

result in larger tau steps. Default value is 0.03. :type tau_tol: float

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

target = 'hybrid'
class gillespy2.solvers.TauHybridSolver(model=None, profile_reactions=False, constant_tau_stepsize=None)[source]

Bases: GillesPySolver

This solver uses a root-finding interpretation of the direct SSA method, along with ODE solvers to simulate ODE and Stochastic systems interchangeably or simultaneously. Uses integrators from scipy.integrate.ode to perform calculations used to produce solutions.

Parameters:

model (gillespy2.Model) – The model on which the solver will operate.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by tau_hybrid_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

classmethod get_supported_features()[source]

Get the set of supported features.

name = 'TauHybridSolver'
rc = 0
result = None
run(model=None, t=None, number_of_trajectories=1, increment=None, seed=None, debug=False, profile=False, tau_tol=0.03, event_sensitivity=100, integrator_options={}, live_output=None, live_output_options={}, timeout=None, **kwargs)[source]

Function calling simulation of the model. This is typically called by the run function in GillesPy2 model objects and will inherit those parameters which are passed with the model as the arguments this run function.

Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int or float) – Simulation run time.

  • number_of_trajectories (int) – Number of trajectories to simulate. By default number_of_trajectories = 1.

  • increment (float) – Save point increment for recording data.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • debug (bool) – Set to True to provide additional debug information about the simulation.

  • profile (bool) – Set to True to provide information about step size (tau) taken at each step.

  • tau_tol – Tolerance level for Tau leaping algorithm. Larger tolerance values will

result in larger tau steps. Default value is 0.03. :type tau_tol: float

Parameters:
  • event_sensitivity (int) – Number of data points to be inspected between integration steps/save points for event detection. Default event_sensitivity = 100

  • integrator_options (dict) – contains options to the scipy integrator. by default, this includes rtol=1e-9 and atol=1e-12. for a list of options, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.LSODA.html. Example use: {max_step : 0, rtol : .01}

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

stop_event = None
class gillespy2.solvers.TauLeapingCSolver(model=None, output_directory=None, delete_directory=True, resume=None, variable=False, constant_tau_stepsize=None)[source]

Bases: GillesPySolver, CSolver

A Tau Leaping solver for GillesPy2 models. This solver uses an algorithm that calculates multiple reactions in a single step over a given tau step size. The change in propensities over this step are bounded by relative change in state, yielding greatly improved run-time performance with very little trade-off in accuracy.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by tau_leaping_c_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'TauLeapingCSolver'
run(model: Optional[Model] = None, t: Optional[int] = None, number_of_trajectories: int = 1, timeout: int = 0, increment: Optional[int] = None, seed: Optional[int] = None, debug: bool = False, profile: bool = False, variables={}, resume=None, live_output: Optional[str] = None, live_output_options: dict = {}, tau_tol=0.03, constant_tau_stepsize=None, **kwargs)[source]
Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int) – End time of simulation.

  • number_of_trajectories (int) – Number of trajectories to simulate. By default number_of_trajectories = 1.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • increment (float) – Time step increment for plotting.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • variables (dict) – Dictionary of species and their data that will override existing species data.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – dictionary contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • tau_tol – Tolerance level for Tau leaping algorithm. Larger tolerance values will

result in larger tau steps. Default value is 0.03. :type tau_tol: float

Parameters:

constant_tau_stepsize – If set, overrides the automatic stepsize selection and uses the given value as the stepsize on each step.

Returns:

A result object containing the results of the simulation

Return type:

gillespy2.Results

target = 'tau_leap'
class gillespy2.solvers.TauLeapingSolver(model=None, debug=False, constant_tau_stepsize=None)[source]

Bases: GillesPySolver

A Tau Leaping solver for GillesPy2 models. This solver uses an algorithm that calculates multiple reactions in a single step over a given tau step size. The change in propensities over this step are bounded by bounding the relative change in state, yielding greatly improved run-time performance with very little trade-off in accuracy.

Parameters:

model (gillespy2.Model) – The model on which the solver will operate.

classmethod get_solver_settings()[source]

Returns a list of arguments supported by tau_leaping_solver.run. :returns: Tuple of strings, denoting all keyword argument for this solvers run() method. :rtype: tuple

name = 'TauLeapingSolver'
pause_event = None
rc = 0
result = None
run(model=None, t=None, number_of_trajectories=1, increment=None, seed=None, debug=False, profile=False, live_output=None, live_output_options={}, timeout=None, resume=None, tau_tol=0.03, **kwargs)[source]

Function calling simulation of the model. This is typically called by the run function in GillesPy2 model objects and will inherit those parameters which are passed with the model as the arguments this run function.

Parameters:
  • model (gillespy2.Model) – The model on which the solver will operate. (Deprecated)

  • t (int or float) – Simulation run time.

  • number_of_trajectories (int) – Number of trajectories to simulate. By default number_of_trajectories = 1.

  • increment (float) – Save point increment for recording data.

  • seed (int) – The random seed for the simulation. Optional, defaults to None.

  • debug (bool) – Set to True to provide additional debug information about the simulation.

  • profile (bool) – Set to True to provide information about step size (tau) taken at each step.

  • live_output (str) – The type of output to be displayed by solver. Can be “progress”, “text”, or “graph”.

  • live_output_options (dict) – Contains options for live_output. By default {“interval”:1}. “interval” specifies seconds between displaying. “clear_output” specifies if display should be refreshed with each display.

  • timeout (int) – If set, if simulation takes longer than timeout, will exit.

  • resume (gillespy2.Results) – Result of a previously run simulation, to be resumed.

  • tau_tol (float) – Tolerance level for Tau leaping algorithm. Larger tolerance values will result in larger tau steps. Default value is 0.03.

Returns:

A result object containing the results of the simulation.

Return type:

gillespy2.Results

stop_event = None