Skip to content

harper493/epidemia

Repository files navigation

Epidemia is a program to simulate an epidemic, exploring realistic infection processes. It
is licensed under GPLv3.

It is written in Python3.8 and C++, and also requires a few non-default packages: numpy,
matplotlib and TkInter, and boost for C++.

To run it from the command line:

python3.8 epidemia.py [-p population] [-i infectiousness] -P

will run for the specified population (in the range 10000-10000000) and infectiousness (default is 2.5,
anything in the range 1.5-4 should produce interesting results). It will show what is going on day by
day and when it has finished it will plot a graph (thanks to -P).

Many more options to control how it runs are described in the documentation.

Why Another Simulation?
-----------------------

The basis of epediemology is the "SIR [susceptible, infected, recovered] model", dating from the
1930s. It is where the term "R0" comes from, the initial rate of infection. But the
classic model fails to follow the actual infection rate curves seen during the
Covid-19 pandemic. In reality, the infection rate drops continuously, leading to
a steady curve in a log/linear graph. The SIR model predicts a straight line until
very close to the end o fthe pandemic.

The principal reason for this seems to be that the SIR model assumes that any infected
person is just as likely to infect any susceptible person. This is obviously not
true - if an infected person is in Los Angeles, they are way more likely to infect
their spouse, drinking buddy or workmate than someone in North Dakota. What's
more, people form clusters (family, friends, workmates) that will establish
local herd immunity long before it is established globally.

There is no obvious mathematical way to model this. Instead, epipdemia simulates
each peson individually, up to a population of tens of millions. On a modern
multi-core CPU, the 100+ day course of a pandemic among 10,000,000 people can
be simulated in about 10 seconds.

Installation
------------

First clone or copy the files from github to some suitable directory. Then cd to the directory.

Now you will need python3.8, a Python virtual environment for it, and all the needed packages. Do
the following while running as sudo.

apt install python3.8
apt install libboost-dev-all
apt-get install python3.8-venv
python3.8 -m venv .venv
source .venv/bin/activate
pip3 install numpy
pip3 install matplotlib
apt install python3-tk
cd cpp
make

Once you've done this, the above command line will run epidemia.

For other systems, and other Linux variants, do whatever results in the same effect.

More Options
------------

You can get a list of command line options by typing:

python3.8 epidemia.py -h

The most useful ones are as follows:

-a n       Set the auto-immunity, i.e. the probability that someone exposed to the disease will
           become immune without becoming infectious. It must be a value between 0 and 1. The default is 0.
-i n       Set the "infectiousness". This corresponds very roughly to the R0 number for the infection,
           i.e. the number of people who will be infected by a single victim, but that is also
           highly dependent on the "social" conditions. A value in the range 1.5-4 typically gives
           interesting results.
-L path    Set the path for log files. If this is specified, detailed daily logs of the simulation
           are created in the directory, and the graph is saved as a .png file.
-N n       Set the proportion of cities to be infected initially. Must be a number in the range
           0-1. The default is 0.5.
-n n       Set the number of people initially infected. The default is 20, but that can make the first
           few days slow and boring.
-P         Plot results.
-p n       Set population.
-R n       Run n times with same parameters, graphing the results. This shows how much the results
           change due to the randomness of the simulation.

Many more simulation parameters are accessible through a Java style properties file. The file base.props
contains all of them. To change just a few, create a file in the same format and append its name to the
command line after the options.

Documentation
-------------

Documentation is a work in progress. It is at doc/epidemia.html.

About

Epidemia project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages