A C++ stochastic simulation library that provides a simple API to define species, reactions, and vessels. It supports customizable observers and batch simulations.
To simulate a reaction, see the following example:
#include <iostream>
#include <random>
#include "stochastic.hpp"
int main() {
double end_time = 10.0;
std::mt19937 rng(42);
auto v = stochastic::Vessel{"A + B -> 2B"};
auto A = v.add("A", 10);
auto B = v.add("B", 1);
double rate = 0.1;
v.add((A + B) >> rate >>= B + B);
auto observer = [](const stochastic::Observation &ob) {
std::cout << ob.time << " A=" << ob.state.at("A")
<< " B=" << ob.state.at("B") << '\n';
};
stochastic::gillespie(v, end_time, observer, rng);
}See the examples directory for more usage examples.
To build the library using CMake, run the following commands:
cmake -S . -B build
cmake --build buildTo run the tests, first build the library, then the following command:
ctest --test-dir build