Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
180 lines (144 sloc) 7.51 KB

pyssa : Python package for stochastic simulations

Build Status Updates Documentation Status pypi License Code style: black

Introduction

pyssa is a Python package for stochastic simulations. It offers a simple api to define models, perform stochastic simulations on them and visualize the results in a convenient manner.

Install

Install with pip:

$ pip install pyssa

Documentation

Usage

from pyssa.simulation import Simulation

 V_r = np.array([[1, 0], [0, 1], [0, 0]])  # Reactant matrix
 V_p = np.array([[0, 0], [1, 0], [0, 1]])  # Product matrix
 X0 = np.array([100, 0, 0])  # Initial state
 k = np.array([1.0, 1.0])  # Rate constants
 sim = Simulation(V_r, V_p, X0, k)  # Declare the simulation object
 # Run the simulation
 sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10)

You can change the algorithm used to perform the simulation by changing the algorithm parameter

sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10, algorithm="tau_adaptive")

You can run the simulations on multiple cores by specifying the n_procs parameter

sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10, n_procs=4)

Plotting

sim.plot()

images/plot_basic.png

Plot of species A, B and C

Accessing the results

results = sim.results

Benchmarks

We chose numba after extensive testing and benchmarking against python and cython implementations.

N a m e ( t i m e i n m s ) Min Max Mea n Std Dev Med ian IQR Out lie rs OPS Rou nds Ite rat ion s
t e s t _ n u m b a _ b e n c h m a r k 314 .17 58 (1. 0) 342 .99 15 (1. 0) 322 .93 18 (1. 0) 11. 459 0 (1. 0) 318 .79 83 (1. 0) 9.1 533 (1. 0) 1;1 3.0 966 (1. 0) 5 1
t e s t _ c y _ b e n c h m a r k 17, 345 .76 98 (55 .21 ) 19, 628 .39 31 (57 .23 ) 18, 255 .39 31 (56 .53 ) 862 .47 11 (75 .27 ) 18, 148 .93 58 (56 .93 ) 1,0 30. 367 6 (11 2.5 7) 2;0 0.0 548 (0. 02) 5 1
t e s t _ p y _ b e n c h m a r k 27, 366 .36 81 (87 .11 ) 28, 417 .83 33 (82 .85 ) 27, 782 .24 82 (86 .03 ) 387 .27 58 (33 .80 ) 27, 728 .42 24 (86 .98 ) 347 .38 91 (37 .95 ) 2;0 0.0 360 (0. 01) 5 1

License

Copyright (c) 2018-2019, Dileep Kishore, Srikiran Chandrasekaran. Released under: Apache Software License 2.0

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

You can’t perform that action at this time.