Skip to main content

COVID-19 agent-based simulator

Project description

Covasim

Covasim is a stochastic agent-based simulator designed to be used for COVID-19 (novel coronavirus, SARS-CoV-2) epidemic analyses. These include projections of indicators such as numbers of infections and peak hospital demand. Covasim can also be used to explore the potential impact of different interventions.

Requirements

Python >=3.6 (64-bit). (Note: Python 2 is not supported.)

We also recommend, but do not require, using Python virtual environments. For more information, see documentation for venv or Anaconda.

Quick start guide

Install with pip install covasim. If everything is working, the following Python commands should bring up a plot:

import covasim as cv
sim = cv.Sim()
sim.run()
sim.plot()

Detailed installation instructions

  1. Clone a copy of the repository. If you intend to make changes to the code, we recommend that you fork it first.

  2. (Optional) Create and activate a virtual environment.

  3. Navigate to the root of the repository and install the Covasim Python package using one of the following options:

    • To install with webapp support (recommended):

      python setup.py develop

    • To install as a standalone Python model without webapp support:

      python setup.py develop nowebapp

    • To install Covasim and optional dependencies (be aware this may fail since it relies on private packages), enter:

      python setup.py develop full

    The module should then be importable via import covasim.

Detailed usage

There are several examples in the examples directory. These can be run as follows:

  • python examples/simple.py

    This example creates a figure using default parameter values.

  • python examples/run_sim.py

    This shows a slighly more detailed example, including creating an intervention and saving to disk.

  • python examples/run_scenarios.py

    This shows a more complex example, including running an intervention scenario, plotting uncertainty, and performing a health systems analysis.

Structure

All core model code is located in the covasim subfolder; standard usage is import covasim as cv. The other subfolders, cruise_ship and webapp, are also described below.

The model consists of two core classes: the Person class (which contains information on health state), and the Sim class (which contains methods for running, calculating results, plotting, etc.).

covasim

The structure of the covasim folder is as follows:

  • base.py: The ParsObj class, plus basic methods of the BaseSim class, and associated functions.
  • healthsystem.py: The HealthSystem class, for determining hospital capacity and treatment rates.
  • interventions.py: The Intervention class, for adding interventions and dynamically modifying parameters.
  • parameters.py: Functions for creating the parameters dictionary and loading the input data.
  • people.py: The Person class, and functions to create a population of people.
  • requirements.py: A simple module to check that imports succeeded, and turn off features if they didn't.
  • run.py: Functions for running simulations (e.g. parallel runs and scenarios).
  • sim.py: The Sim class, which performs most of the heavy lifting: initializing the model, running, and plotting.
  • utils.py: Functions for choosing random numbers, many based on Numba, plus other helper functions.
  • version.py: Version, date, and license information.

cruise_ship

A version of the Covasim model specifically adapted for modeling the Diamond Princess cruise ship. It uses its own parameters file (parameters.py) and has slight variations to the model (model.py).

webapp

For running the interactive web application: please see the README.md in that folder for more information, including information on running locally and Docker deployment.

Disclaimer

The code in this repository was developed by IDM to support our research in disease transmission and managing epidemics. We’ve made it publicly available under the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 License to provide others with a better understanding of our research and an opportunity to build upon it for their own work. We make no representations that the code works as intended or that we will provide support, address issues that are found, or accept pull requests. You are welcome to create your own fork and modify the code to suit your own modeling needs as contemplated under the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

covasim-0.20.1.tar.gz (439.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

covasim-0.20.1-py3-none-any.whl (409.1 kB view details)

Uploaded Python 3

File details

Details for the file covasim-0.20.1.tar.gz.

File metadata

  • Download URL: covasim-0.20.1.tar.gz
  • Upload date:
  • Size: 439.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for covasim-0.20.1.tar.gz
Algorithm Hash digest
SHA256 06b2b88339c5f040d289e007b2339e8f3851638112456e370a2ae4d3816641a2
MD5 40c6c3da49d73d0f7a3f5cd7233ce0df
BLAKE2b-256 8e374b2c0680e9619296a2a16dd6a7b1db29413ad17e15af1552f645acd7b9cc

See more details on using hashes here.

File details

Details for the file covasim-0.20.1-py3-none-any.whl.

File metadata

  • Download URL: covasim-0.20.1-py3-none-any.whl
  • Upload date:
  • Size: 409.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for covasim-0.20.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44ca41c01c4827838f6c0d9534f3ae3026a303890d207062bf0ea8a7c3498074
MD5 fed552341bdedc0712999a73f6956a0c
BLAKE2b-256 e59e73bd82afcef6a9a0872ed5751c4ad06dbd63253b1036ee372a6ed5a80d69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page