3.2.11.5. causality/Stochsim.hpp¶
3.2.11.5.1. Class causality::MassActionKinetics¶
-
class causality::MassActionKinetics¶
A helper class for performing stochastic simulations where events are drawn according to the law of mass action. Importantly, if the underlying derivation graph is enlarged then
syncSize()must be called before callingdraw().
3.2.11.5.1.1. Synopsis¶
3.2.11.5.1.2. Details¶
Construct a new instance, based on the given derivation graph. The rates returned by the input, reaction, and output rate callbacks may be cached.
- Throws
LogicErrorif !dg_.- Throws
LogicErrorif neither dg_->hasActiveBuilder() nor dg_->isLocked().- Throws
LogicErrorif !inputRate.- Throws
LogicErrorif !reactionRate.- Throws
LogicErrorif !outputRate.
-
void syncSize()¶
Enlarges the internal data structures to the current size of the underlying derivation graph.
-
std::pair<std::optional<Action>, double> draw(const DGPetriNetMarking &m)¶
- Returns
an action, randomly selected according to the low of mass action based on the given population/marking and the rates. The second returned component is the sum of reactivity for the given reactions/hyperedges.
If no events are possible, then the second component is 0.0 and the first component has no vallue.
Use
rngReseed()to seed the pseudo-random bit generator used for the selection.- Throws
LogicErrorif m is not a marking on the underlying derivation graph.
Requires
syncSize()to have been called since the last time the underlying derivation graph has changed size.