SIR-Simulator

Welcome to this little Epidemic Simulator! Here you can use an agent-based simulation to explore the effects of certain epidemic parameters on the evolution of a disease. "SIR" stands for "Susceptible, Infected, Recovered" and is a common epidemiological model on which this simulator is based on. More explanations below.

Bevor you start you have to choose a population size. Keep in mind that for large population sizes >1000 the calculations can take a view seconds. After choosing a population size you start the simulation with the green "Start"-button. Now the simulation menu occures and some coordinate systems. On the right hand side you will find a box wich will provide you with further informations.

Theory

The name of this simulator comes from the so called SIR-Model, which gives a set of coupled first order differential equations of the variables S, I and R which stand for the fractions of Susceptibel, Infected and Recovered or Removed individuals. One can get the dynamic of an epidemic from $$ \tau \dot{S} = -R_0 S I $$ $$ \tau \dot{I} = (R_0 S - 1)I $$ $$ \tau \dot{R} = I $$ where τ is the average infection duration. For all times \(S + I + R = 1 \) holds. \(R_0\) is the so called basic reproduction number and can be seen as the average number of new infections, when a infected person comes into a fully suscptibel society, i.e. \(S \approx 1\). But this holds only as long as a infected individual meets only susceptible. As soon as \(I\) rises, the susceptible density diminishes and with it the average reproduction. The basic reproduction number can be seen as potential transmissibility for a disease, since this counts not only for the first infected person, but everyone who spreads pathogenes among a fully susceptible enviroment.
With this in mind one can divide the basic reproduction number into three factors: the infection duration τ, the average infection probability \(q\) and the amount of contacts per time unit \(k\). \(R_0\) is the product of these 3 parameters: $$ R_0 = τ \cdot k \cdot q. $$ There are a view important properties: at first on may find through simple analysis that the point, when the spread of the disease diminishes, i.e. when \(I\) begins to decline, is at a susceptible density of \(S =\)\(1 \over R_0\). And if \(R_0 < 1\) a epidemic will not arise in the first place, which follows direclty from the meaning as average number of new infections from the first infected one: if the first person infects less than one other person, the disease will not spread.
For \(R_0 > 1\) a epidemic clearly can happen and for \(R_0 = 1\) we call the disease "endemic".
Another important value is the effective reproduction number, which takes into account, that with rising infected density, susceptible persons become less. But they are needed for the epidemic growth and with declining individuals to infect, the reproduction reduces as well. The effective reproduction number is hence given by $$ R_{eff} = R_0 S. $$ This number can be a measure for the actual epidemic spread at a time. Note that \(R_{eff} \approx R_0\) only at the beginning, whenn \(S \approx 1\). Containment policies should be interessted in reducing \(R_{eff}\) below \(1\), after which the amount of new infections will decline.

Methods Of This Simulation

The simulation generates virtual connections of N (which is the population size) agents. Therefor a function contact_matrix() sets a certain probability that a random agent will have contact with another random agent. The result is a triangular matrix with all the connection probabilities for all agents with all the other agents. The function takes into account whether one of the agents is already infected or both are susceptible, to in- or decrease the probability, dependent on the input parameters from the simulation control panel.
This matrix is handed to the function contact_bool(), which pulls a draw for every entry to replace the probabilities with "true" or "false" values. "true" represents the case, that two agents had a contact, while "false" excludes it.
After this setup the simulation proceeds to calculate with the function infection_probability() for each contact, i.e. the entries with "true" values, a infection probability. The function infection_bool() pulls now a draw from this: is the value generated from infection_probability() smaller than the \(q\) from the control panel, an infection took place. For each Agent the date of infection is stored in an evolution_array, together with the infection duration τ from the control panel. This provides the current state (\(S\), \(I\) or \(R\)) of each agent which can be extracted to calculate the graphs. With every time step the simulation goes through this process.
Many aspects are not considered by this simulation. For example, there no social structures like families or colleagues implemented, the agents behave more "particle-like". Also assumption of a constant Number of agents, staying in the same area is not very realistic, since in reality for example travellers betwenn cities/regions are more common, than a fully isolated village. But not just numerically, also in the theoretical ansatz of the SIR-Model there are some simplifications, like neglecting the vital dynamics of natural births and deaths. But with every step towards a more realistic model, the simulation becomes more complex and at a certain point to sophisticated to run this in the browser.


For questions and comments send E-Mail to: BGutsche@gmx.de