Giter Club home page Giter Club logo

epidemic's Introduction

Epidemic

This is a small simulation of an epidemic inside a mobile population. It is implemented in C++ and is not to be used as representing real epidemics.

How it works

The Simulation spawns a number of People with common attributes:

struct Person
{
    // Status
    bool alive; // 0 if dead
    bool infected; // 1 if true
    bool immune; // 1 if true;
    int days_infected = 0;
    
    Person() : alive(true), infected(false), immune(false), days_infected(0), xpos(rand()%1000), ypos(rand()%1000){};
    
    // Position
    double xpos = rand()%1000;
    double ypos = rand()%1000;
};

Everything happens inside a 1000x1000 square plane. Each Person gets a random starting point, from which they move in a random walk (implemented with std::mt19937). If they get too close to the "walls", they are moved to a random point inside the plane.

If a person gets too close to an infected person, they get infected. For each timestep, there is a chance SPONT_INF of spontaneous infection. If the person is infected for more than 14 timesteps (days), they get immune; if they are infected, they can also die with a chance of LETALITY.

The simulation is started from the command line by invoking

./epidemic <Number of Timesteps> <Size of initial population>

e.g.: ./epidemic 100 1000.

Simulation Running

Building

Epidemic depends on lava/matplotlib-cpp for building. See the instructions and installation requirements there.

If you do not whish to plot the output, you can export the data in ParaView-compatible .csv.NUM_STEP files (where NUM_STEP is a running index). Uncomment the #define CSVOUTPUT and comment out the #define ANIMATION guards in the src/Simulation.cpp file to enable CSV-only output.

Build with CMake inside a build directory.

Dependenies

python
matplotlib

For Linux and macOS:

git clone https://github.com/mjjrt/Epidemic
cd Epidemic
mkdir build && cd build
cmake ..
cmake --build .

./epidemic 100 1000

Windows

TBD.

Known Bugs

  • The matplotlibcpp.h dependency seems to have a bug in the plt::legend() template function. Therefore, it is not possible to fix the legend to one place without restructuring the image. That's why the plot looks so off-center.

TODO

  • Implement infection susceptibility
  • Faster Check Loops
  • Better Plotting/Rendering
  • Documentation

epidemic's People

Contributors

mjjrt avatar

Watchers

 avatar

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.