Coder Social home page Coder Social logo

covid19's Introduction

Bayesian Inference of Epidemic Models

coming soon...

Project structure

  • epidemics - The Python module and files.
  • epidemics/cantons - Cantons models and cantons data preparation.
  • epidemics/country - Country models and country data preparation.
  • epidemics/data - Base classes for data representation and preprocessing.
  • epidemics/data/downloads - Raw files downloaded by the Python scripts.
  • epidemics/data/cache - Files processed by the Python scripts.
  • src/epidemics - The C++ code.
  • src/epidemics/model/country - C++ country-level model implementations.
  • src/epidemics/model/cantons - C++ canton-level model implementations.
  • test/py - Python unit tests.
  • test/cpp - C++ unit tests.

Compilation

Install the boost library by following these instructions. In macOS you can run

brew install boost

From the repository root folder do:

pip3 install jinja2
git submodule update --init --recursive
mkdir -p build
cd build
cmake ..
make

Tests

To run the tests, run the following command (from the repository root):

cd tests
./run_all_tests.sh

To run only Python tests, run cd tests/py && ./run.sh. To run only C++ tests, run cd build && ./libepidemics_unittests.

Debugging

If the C++ code is crashing, try enabling the backward-cpp library for printing the stack trace:

cmake -DENABLE_BACKWARD_CPP=ON ..
make

Code formatting

Python

Install yapf.

pip3 install yapf

Format a file in-place

yapf -i FILE

Format all python files recursively in a directory in-place

yapf -ir DIR

C++

Install clang-format as part of clang using your package manager or download a static build

Format a file in-place

clang-format -i FILE

Troubleshooting

If the changes in the code are not reflected in the results, try erasing epidemics/data/cache and epidemica/data/downloads folders. The cache decorators attempt to detect changes in the code, but may not always be successful.

Adding a new country-level model (C++)

Follow these steps to create a new C++ country-level model. The steps are shown on an example of creating a XYZ model from the existing SIR model.

  1. Make a copy of src/epidemics/models/country/sir.h and name it xyz.h.
  2. Change the sir namespace to xyz.
  1. Update the Parameters struct.
  2. Update the State struct: change the number of states in StateBase parent class, and customize named getters.
  3. Update the model, the Solver::rhs function.
  4. Edit src/epidemics/bindings/generate_bindings.py and add your model to the main function in the generate_country or generate_canton function.
  5. Edit CMakeLists.txt and add your model to the GENERATED_COUNTRY_BINDINGS variable.
  6. Create a test/py/test_country_xyz.py analoguous to test_country_sir.h and test your code. You may skip testing the derivatives, since AD should already be tested.

In the case AD does not support some operation, add it in src/epidemics/utils/autodiff.h. Create a test in test/cpp/test_autodiff.cpp!

covid19's People

Contributors

wadaniel avatar pkarnakov avatar ikicic avatar michaich avatar gtarabat avatar mboden1 avatar webepasc avatar

Forkers

ga48nuq

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.