Giter Site home page Giter Site logo

tsir's Introduction

Crazy fast code for the SIR model on temporal networks

It follows the model descriptions in this blog post: https://petterhol.me/2018/07/20/getting-down-to-the-brass-tacks-of-sir-on-temporal-networks/ The algorithm is discussed here: https://petterhol.me/2018/07/23/crazy-fast-code-for-sir-on-temporal-networks/

To get it running you need:

  1. Make a directory o (for complier object files)
  2. Compile it by gcc by typing make.
  3. Run it via a Python wrapper.

I supply two Python wrappers: One for simply calculating the average outbreak size given a network and the two parameters (per-contact transmission probability and recovery rate). You can run it like:

python3 tsir_single.py gallery01.tsv 0.5 2

The first argument is the file containing the network. The input format is a blank-space separated contact list (vertex-id 1, vertex-id 2, time). It will neglect multiple contacts and self-contacts. The example network comes from: http://www.sociopatterns.org/datasets/ The second argument is the transmission probability, the third is the recovery rate.

Another python wrapper is for scanning the parameter space (at least a part of it) and plotting a heat map of the outbreak size. You can run that one like:

python3 tsir_scan.py gallery01.tsv gallery01.pdf

The last argument is the name of the output figure file. The suffix determines the format.

Notes for the July 2020 update

I have tried to simplify the code without making it slower by moving preprocessing to the Python wrapper. (Running the code from Python was anyway more or less needed to conveniently seed the C code with a 64-bit uint.) It uses 10^6 averages, which is probably more than enough for larger data sets.

I have refrained from expanding this into a full Python library mostly because the research projects I can imagine building on this code would anyway need to add something to the C program. For example, adding measurements about individual nodes or links should be straightforward.

tsir's People

Contributors

pholme avatar

Watchers

James Cloos 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.