Code Monkey home page Code Monkey logo

compartmental-model's Introduction

Compartment model from AIforGood Simulator

Deon badge

AIforGood Simulator aims to provide epidimology modelling help to humanitarian NGOs who are working to contain coronavirus outbreak in refugee camps. Please fill out the contact form on our website if you want to get in touch or volunteer with us.

Model description

(pending a write up from Nick)

Running the repo

clone the repo and then change to the git directory and then:

pip install -r requirements.txt

Here is the workflow in generating CSVs for the report

  1. Prepare population level data

⋅⋅⋅Go to Parameters folder and open up camp_params.csv where you use the input the camp information and fill up the proportion for each age bracket and save it. Don't modify other camps information!

  1. Prepare contact matrix data (optional)

⋅⋅⋅Again in the Parameters folder, open up GenerateRandomParams.R where you can synthesize the contact matrix for the camp of interest. Save it as a seperate csv file.

  1. To run the baseline experiment
  • go to Scripts/fucntions.py and find the GenerateInfectionMatrix function to change where it is pointing to the contact matrix csv file
  • define the config file used to run the experiment and set up the name of the camp correctly as set out in the camp_params.csv
  • for a single run and just run the run_model.py file but notice the control parameters at the top (maybe we can build in some command line control here rather than modifying the py file every time)
python run_model.py
  1. To run different interventions
  • Modify the config.py under the Scripts directory to make copies with it along with appropriate naming convention

For example:

#running simulation with no intervention
from configs.baseline import camp, population_frame, population, control_dict
#running simulation with improving hygiene as an intervention
from configs.hygiene import camp, population_frame, population, control_dict
  • Can use the run_model_intervention.py file to run interventions in bulk (maybe we can build in multiprocessing here to speed up the run time)
  1. Retrieve outputs from CSV_output folder

⋅⋅⋅ These are the csvs that we will use to make a plot

compartmental-model's People

Contributors

billlyzhaoyh avatar nt409 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

compartmental-model's Issues

Analysis on shielding

Screenshot 2020-05-30 at 6 07 01 PM

The shielding implementation still leads to an increase in incidence counts across all four categories while accelerating the epidemic.

Producing visualisation for the modelling report

  • Run baseline experiment once the parameter values and contact matrix values are fixed and run all combinations of intervention strategies and extract the csvs

  • Visualise the following components from model (currently just the compartment model) outputs

  • Projected incidence of symptomatic COVID-19 cases, projected H, projected D prevalence plots overtime for the whole camp (accumulative I, daily I, accumulative H, daily H, accumulative D, daily D)

  • Projected incidence of symptomatic COVID-19 cases, projected H, projected D prevalence plots over time by age buckets (accumulative I, daily I, accumulative H, daily H, accumulative D, daily D)

  • Intervention plots ranked by effectiveness on flattening the curve (the number of asymptomatic infection or the number of severe cases)

  • Intervention plots ranked by effectiveness on flattening the curve (the number of asymptomatic infection or the number of severe cases)

  • Plot illustrating applying two or more interventions at the same time could yield the best results for mitigation and containment

See example plots at https://www.notion.so/yanhong/Visualising-the-output-from-models-for-the-report-3a62b5b7f277417a80c2fc795c184476 in Noiton

Interventions to be added

  • Better personal hygiene: each resident in Moria get handed two masks each but regular hand washing remains difficult in the future.

  • Building up hospital capacity: increase the hospital capacity from 6 ICU beds to some higher number

  • Sectoring the camp: divide camps into smaller zones to reduce global contact. This involves removing the central food queue.

  • Move offsite: once a person is found to be infectious, move the person offsite with the household residents and allow them to return only when they recover.

  • Shielding: group the high-risk population together and let them self manage the community. (age contact is limited to old people - old people only for example)

  • Removal of the high-risk population: under the pressure from NGOs, the greek army is starting to remove several hundred high-risk populations from the camp to relocate them either to hotels on the island or to mainland Greece

Improving parameter estimates/next steps

Easiest to justify if we can add in custom control and demographic data onto a model structure which has been tested more extensively/closer to published research (although not sure if the LSHTM Africa paper** has been peer reviewed/published yet?). This would give us a framework that could be applied to any camp/low resource setting in any country.

As it stands, many of the parameters are unjustified. Most that we do have references for are sourced from:

  1. LSHTM Africa
    https://cmmid.github.io/topics/covid19/reports/LSHTM-CMMID-20200419-Covid19-Africa-strategies.pdf

  2. Age-dependent effects in the transmission and control of COVID-19 epidemic
    https://www.medrxiv.org/content/10.1101/2020.03.24.20043018v2.full.pdf

  3. Projecting social contact matrices in 152 countries using contact surveys and demographic data
    https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5609774/#!po=63.3333

  • R0 calculation needs updating now have asymptomatic transmission at 50%. Currently wrong!

  • Paper (3.) has contact matrix for Greece (and 152 countries!). See new stuff in Parameters/ContactMatrices. Currently not happy with how this is implemented - would need to compare to LSHTM code to get right method of using this data (think need - beta S_i c_ij I_j /N_j instead of - beta S_i c_ij I_j and also need right method of changing from 16 x 16 matrix to 8 x 8 *** )

  • Need to find appropriate distributions to sample from for proper uncertainty estimates. As yet only sampling epidemiological parameters. Possibly worth sampling over death/hospitalisation probabilities too, and also control efficacies.

  • Need solid reference for as many params as possible (most likely all except the custom control ones which can be a bit more ad hoc)

  • Need to write up model in full

** Note LSHTM has much longer infectious period (still infectious in hospital etc) than we do. Since we calculate infection rate to give an appropriate R0... upshot is that our epidemic most likely has a comparable size but happens faster than it would in their model

*** unless we'd prefer to scale up rather than scale down... possibly better but will be slower. Likely unimportant decision since other uncertainties significant, so suggest go for faster model and run over a larger number of sampled runs

UI Issue on Model Ressult

On Model result page if you hover on graph the option for zoom-out , screenshot overlap on the key.
bug_01

In moving sick people offsite (or isolating symptomatically infected people), number of cases go way below 0 in some cases

Screenshot 2020-05-30 at 7 14 15 PM

Here are three experiments I run for moving people offsite with two different rates (10 per day and 50 per day) from 0-80, 0-120 to 0-200 simulation days. The function to reproduce this experiment is at https://github.com/AIforGoodSimulator/compartmental-model/blob/master/Scripts/run_model_interventions.py

This is a plot over time for the symptomatically infected compartment. The plot directly plot the column of Infected (symptomatic) * N. The top graph has negative 500 in some runs - could this be a bug?

The code to reproduce is plot is

sns.lineplot(x="Time",y='Infected (symptomatic)',ci="sd",data=the_data_frame_to_plot)

From your comment, I understand now that the people who are sick will instantly flow into hospital or recovery and it will be great to add a delay there and maybe have a way to count how many people are currently isolated because that gives us an idea on how many people we need to care for. In this case, in any given day we can still count the number of symptomatically infected people across the whole camp including those people who are now living offsite so we don't misrepresent the situation in plotting very low symptomatic infection numbers.

Analysis on better hygiene intervention

Screenshot 2020-05-29 at 1 28 54 AM

The table represents calculating the effective reduction in the cumulative number of cases in those four disease categories. The four experiments are all setting hygiene parameter in the control diet to 0.7 and vary the end of the control measure from 30 to 200. The functions to reproduce the results can be found at https://github.com/AIforGoodSimulator/compartmental-model/blob/master/Scripts/run_model_interventions.py with parts:
for hygiene_effective in [0.7,0.8,0.9]: camp, population_frame, population, control_dict=intialise_control_dict(hygiene_value=hygiene_effective,hygiene_timing=[0,200]) run_simulation(camp, population_frame, population, control_dict)

The reduction in total hospitalisation needs days make sense but the negative number in critical person-days suggest that the demand in that category actually increased after implementing the control measures. This might be counter-intuitive. Does this make sense?

Improvements on the current report

#TODO:

  • 1. Add percentages to the cumulative cases to signify what is the proportion of people getting something

  • 2. Add asymptomatic infections count to the table

  • 3. When the case number is reduced to 0 adjust the peak day not to be negative

  • 4. Need to adjust the hospitalisation and critical person days for the interventions that will naturally prolong it (for example by increasing the hospital capacity

A way to count how many symptomatically infected people are currently being isolated

Like moving high-risk residents offsite, can we have another bucket to track exactly how many people are being isolated at any given point?

This can also help us understand the isolation capacity - once the residents recover or disease, the capacity opens up for more residents to come in. This might require a small overhaul on the current function setup.

Analysis on increasing ICU capacity

Screenshot 2020-05-30 at 5 57 07 PM

(Ignore the caption of the table which I haven't changed yet)

if we are setting the critical compartment to be people needing critical care but may or may not get it, then an increase in critical care capacity wouldn't increase the person-days needing the critical care but just reduce the number of deaths. Does it mean that people in critical care now are more likely to survive for another day thus attributing to the increase in critical person-days? But why we are seeing an increase in hospitalisation person days? Is the ICU number impacting that compartment in any way?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.