Skip to content
Python package for stochastic simulations
Python Makefile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial commit Aug 9, 2018
docs Chore: Update api documentation Mar 23, 2019
pyssa Bump version: 0.8.1 → 0.8.2 Apr 20, 2019
tests Refactor: Move algorithms to sub module. Fixes #94 Apr 13, 2019
.editorconfig Initial commit Aug 9, 2018
.gitignore Add .vscode to `.gitignore` Nov 10, 2018
.pre-commit-config.yaml Chore: Add `pre-commit` hook to format using `black`. Fixes #20 Nov 18, 2018
.pylintrc Chore: Create `pylintrc` to ignore error `C0330`. Fixes #21 Nov 18, 2018
.pyup.yml create pyup.io config file Dec 1, 2018
.travis.yml Chore: Trigger travis deploy only on master. Fixes #97 Apr 14, 2019
AUTHORS.rst Update AUTHORS.rst Nov 10, 2018
CONTRIBUTING.rst Initial commit Aug 9, 2018
HISTORY.rst Chore: Update CHANGELOG Apr 20, 2019
LICENSE
MANIFEST.in Fix: Include `*.pyx` files into MANIFEST Nov 3, 2018
Makefile Initial commit Aug 9, 2018
Pipfile Chore: Update black version. Fixes #101 Apr 20, 2019
Pipfile.lock Chore: Update dependencies May 4, 2019
README.md Add: Multiprocessing to `README.md` Feb 9, 2019
azure-pipelines.yml Chore: Add `develop` branch to azure ci Feb 2, 2019
codecov.yml Update algorithm file locations Apr 13, 2019
readthedocs.yml Chore: Add python 3.6 support for readthedocs Dec 1, 2018
requirements.txt Chore: Update dependencies May 4, 2019
requirements_dev.txt Chore: Update dependencies May 4, 2019
setup.cfg Bump version: 0.8.1 → 0.8.2 Apr 20, 2019
setup.py Bump version: 0.8.1 → 0.8.2 Apr 20, 2019
tox.ini Chore: Fix typo in codecov Dec 2, 2018

README.md

pyssa : Python package for stochastic simulations

Build Status Build Status codecov 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()

Plot of species A, B and C

Accessing the results

results = sim.results

You can also access the final states of all the simulation runs by

final_times, final_states = results.final

Benchmarks

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

Name (time in ms) Min Max Mean StdDev Median IQR Outliers OPS Rounds Iterations
test_numba_benchmark 314.1758 (1.0) 342.9915 (1.0) 322.9318 (1.0) 11.4590 (1.0) 318.7983 (1.0) 9.1533 (1.0) 1;1 3.0966 (1.0) 5 1
test_cy_benchmark 17,345.7698 (55.21) 19,628.3931 (57.23) 18,255.3931 (56.53) 862.4711 (75.27) 18,148.9358 (56.93) 1,030.3676 (112.57) 2;0 0.0548 (0.02) 5 1
test_py_benchmark 27,366.3681 (87.11) 28,417.8333 (82.85) 27,782.2482 (86.03) 387.2758 (33.80) 27,728.4224 (86.98) 347.3891 (37.95) 2;0 0.0360 (0.01) 5 1

License

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

Credits

You can’t perform that action at this time.