ODE With Birth and Death Process
We follow on from the SIR model of Simple Problem but with additional birth and death processes.
\[\begin{split}\frac{dS}{dt} &= -\beta SI + B - \mu S\\
\frac{dI}{dt} &= \beta SI - \gamma I - \mu I\\
\frac{dR}{dt} &= \gamma I.\end{split}\]
which consists of two transitions and three birth and death process
Let’s define this in terms of ODEs, and unroll it back to the individual processes.
In [1]: from pygom import Transition, TransitionType, SimulateOde, common_models
In [2]: import matplotlib.pyplot as plt
In [3]: stateList = ['S', 'I', 'R']
In [4]: paramList = ['beta', 'gamma', 'B', 'mu']
In [5]: odeList = [
...: Transition(origin='S',
...: equation='-beta*S*I + B - mu*S',
...: transition_type=TransitionType.ODE),
...: Transition(origin='I',
...: equation='beta*S*I - gamma*I - mu*I',
...: transition_type=TransitionType.ODE),
...: Transition(origin='R',
...: equation='gamma*I',
...: transition_type=TransitionType.ODE)
...: ]
...:
In [6]: ode = SimulateOde(stateList, paramList, ode=odeList)
In [7]: ode2 = ode.get_unrolled_obj()
In [8]: f = plt.figure()
In [9]: ode2.get_transition_graph()
Out[9]: <graphviz.dot.Digraph at 0x7f75674942e8>
In [10]: plt.close()