This repository contains codes for MAT3300 final project, Mathematical Modeling of COVID-19. If you have any question regarding this project, feel free to contact me at [email protected].
Python3
numpy
pandas
Data from John Hoopkins Univerisity is used. The downloaded data has been placed under data folder. Note: since recovery data after Aug 4, 2021 is not available, only data before Aug 4, 2021 (include) is used.
The data has been processed to recover active cases. If you wish to process it again, run
python data_preprocess.py
The four models are in simulator.py
. To run a simulation with a model, consult the following example
from simulator import DTMCSEIR, CTMCSEIR, ApproxSEIR, ExactSEIR
param = {
'ae': 1e-8,
'ai': 1e-8,
'gamma': 0.01,
'kappa': 0.1,
'beta': 0.1,
'rho': 0.01,
'mu': 0.01,
's': 5e7,
'e': 1e3,
'max_e': 1e3,
'max_i': 1e3
}
init_state = {
'i': 2,
'r': 3,
'p': 0,
'cr': 3
}
model = DTMC(param, init_state) # can be one of the four model
# run simulation for 100 days
for i in range(100):
model.step()
# access the result
result = model.history
# visualize the result
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
model.plot(ax)
plt.show()
Note: the DTMC model is strongly recommended for its speed. Plus, NEVER use the CTMC model in real world setting. It is SUPER SLOW in large problems.
To obtain the fitting result in the report, run
python fit_predict_dtmc.py
Note: slight differences are expected due to randomness in the DTMC model.
To fit the model to another time period, change line 156 to
# original
evaluate('2021-03-01', '2021-05-31', '2021-05-01',
# change to
evaluate('start date', 'end date', 'date to split the fitting and predicting period',
Please note that the fitting will last for a few hours because simulated annealing is slow.
First extract the outbreak periods (pre-extracted periods are in data). If you wish to extract it again using your standard of selecting a outbreak period, run
python extract_explode_date.py
To obtain the result in the report, run
python fit_explode.py