Our simulation implements an agent-based approach, storing time-series infection data in pandas DataFrames. At each time step (nominally 30 total) of our simulation, we allow each infected individual to infect to other, uninfected individuals. Infection is modeled as a draw from a binomial distribution with a set rate. For low enough transmission rates, our we can simulate 30 time steps of spread for 1 million agents in less than 30 minutes on a 1.8 GHz Intel Core i5 processor. As such, our code is amenable for usage in exploration of parameter space.
This approach is implemented in:
- 0 dimensions: each infected individual is able to infect any other with equal probability (trans_rate).
- 1 dimension: each infected individual is able to infect other individuals within a certain threshold distance with a certain probability (trans_rate). Past this threshold, the probability of infection falls off as distance cubed.
- 2 dimensions: similar to the one dimensional case. Limiting pairwise calculations was one of the primary concerns in maintaining computational feasibility; usage of various distance matrix calculations required too much memory for a personal laptop. As such, an outer threshold is also set, past which distance calculations are not performed.
Initial uninfected and infected populations can be initialized with custom distributions; in our plots, we employ uniform and normal distributions to aid the debugging process.
Along the way, matplotlib plots and animations allow for visual demonstration of the simulation, serving both as a debugging tool and an end product.
The simulation can be used to determine, for example, the effectiveness of lockdowns at various stages of the disease's spread.
Included with the project is various data that can be used to benchmark the model.
Try It out
jupyter-notebook, matplotlib, numba, numpy, python, scipy