Skip to main content

Starsim

Project description

Starsim is an agent-based modeling framework for simulating the spread of diseases among agents via dynamic transmission networks. Starsim supports the co-transmission of multiple diseases at once, capturing how they interact biologically and behaviorally. Users can also include non-infectious diseases either on their own or as factors affecting infectious diseases. Starsim allows detailed modeling of mother-child relationships from conception to study birth-related diseases. Additionally, Starsim lets users compare different intervention strategies, like vaccines or treatments, to see their impact through various delivery methods such as mass campaigns or targeted outreach.

Examples of diseases that have already been implemented in Starsim include sexually transmitted infections (HIV, HPV, and syphilis, including co-transmission), respiratory infections (tuberculosis and RSV), plus other diseases (Ebola and cholera) and underlying determinants of health (such as malnutrition).

Note: Starsim is a general-purpose, multi-disease framework that builds on our previous suite of disease-specific models, which included Covasim, HPVsim, and FPsim. In cases where a distinction needs to be made, Starsim is also known as the “Starsim framework”, while this collection of other models is known as the “Starsim suite”.

For more information about Starsim, please see the documentation.

Requirements

Python 3.9-3.12.

We recommend, but do not require, installing Starsim in a virtual environment, such as Anaconda.

Installation

Starsim is most easily installed via PyPI: pip install starsim.

Starsim can also be installed locally. To do this, clone first this repository, then run pip install -e . (don’t forget the dot at the end!).

Usage and documentation

Full documentation, including tutorials and an API reference, is available at https://docs.starsim.org.

You can run a simple demo via:

import starsim as ss
ss.demo()

Here is a slightly more realistic example of an SIR model with random connections between agents:

import starsim as ss

# Define the parameters
pars = dict(
    n_agents = 5_000,     # Number of agents to simulate
    networks = dict(      # Networks define how agents interact w/ each other
        type = 'random',  # Here, we use a 'random' network
        n_contacts = 10   # Each person has 10 contacts with other people
    ),
    diseases = dict(      # *Diseases* add detail on what diseases to model
        type = 'sir',     # Here, we're creating an SIR disease
        init_prev = 0.01, # Proportion of the population initially infected
        beta = 0.05,      # Probability of transmission between contacts
    )
)

# Make the sim, run and plot
sim = ss.Sim(pars)
sim.run()
sim.plot() # Plot all the sim results
sim.diseases.sir.plot() # Plot the standard SIR curves

More usage examples are available in the tutorials, as well as the tests folder.

Model structure

All core model code is located in the starsim subfolder; standard usage is import starsim as ss.

The model consists of core classes including Sim, Run, People, State, Network, Connectors, Analyzers, Interventions, Results, and more. These classes contain methods for running, building simple or dynamic networks, generating random numbers, calculating results, plotting, etc.

The structure of the starsim folder is as follows, roughly in the order in which the modules are imported, building from most fundamental to most complex:

  • calibration.py: Class to handle automated calibration of the model to data.

  • demographics.py: Classes to transform initial condition input parameters for use in building and utilizing networks.

  • disease.py: Classes to manage infection rate of spread, prevalence, waning effects, and other parameters for specific diseases.

  • distributions.py: Classes that handle statistical distributions used throughout Starsim.

  • interventions.py: The Intervention class, for adding interventions and dynamically modifying parameters, and classes for each of the specific interventions derived from it. The Analyzers class (for performing analyses on the sim while it’s running), and other classes and functions for analyzing simulations.

  • modules.py: Class to handle “module” logic, such as updates (diseases, networks, etc).

  • network.py: Classes for creating simple and dynamic networks of people based on input parameters.

  • parameters.py: Classes for creating the simulation parameters.

  • people.py: The People class, for handling updates of state for each person.

  • products.py: Classes to manage the deployment of vaccines and treatments.

  • results.py: Classes to analyze and save results from simulations.

  • run.py: Classes for running simulations (e.g. parallel runs and the Scenarios and MultiSim classes).

  • samples.py: Class to store data from a large number of simulations.

  • settings.py: User-customizable options for Starsim (e.g. default font size).

  • sim.py: The Sim class, which performs most of the heavy lifting: initializing the model, running, and plotting.

  • states.py: Classes to handle store and update states for people in networks in the simulation including living, mother, child, susceptible, infected, inoculated, recovered, etc.

  • utils.py: Helper functions.

  • version.py: Version, date, and license information.

The diseases folder within the Starsim package contains definitions of different types of diseases, including STIs, Ebola, and cholera.

Contributing

Questions or comments can be directed to info@starsim.org , or on this project’s GitHub page. Full information about Starsim is provided in the documentation.

Disclaimer

The code in this repository was developed by IDM, the Burnet Institute, and other collaborators to support our joint research on flexible agent-based modeling. We’ve made it publicly available under the MIT 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 permitted under the MIT 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

starsim-1.0.3.tar.gz (129.0 kB view details)

Uploaded Source

Built Distribution

starsim-1.0.3-py3-none-any.whl (119.4 kB view details)

Uploaded Python 3

File details

Details for the file starsim-1.0.3.tar.gz.

File metadata

  • Download URL: starsim-1.0.3.tar.gz
  • Upload date:
  • Size: 129.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for starsim-1.0.3.tar.gz
Algorithm Hash digest
SHA256 4dfbc3a68b0bf9b53ef9f96a4f18e4236bae98d13f21e7cc81b4be2d6356a019
MD5 0f5a548c32ac028f4c0a95042d84e9a9
BLAKE2b-256 62591ed73f1bd012a62b74230aed596e20e10aae2c9c87db6a4395aa121744ce

See more details on using hashes here.

Provenance

File details

Details for the file starsim-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: starsim-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 119.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for starsim-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6b8b8bbefc2c424e66d7397bf63e759dcaa1f7be348fda4617509d8ebbea9b
MD5 b8d0f13900f2d818a618d39484895a09
BLAKE2b-256 8e6c2ac2afd00649b50cb0ac73d9eff39b7d8af5a4e6ec4a8f1f4fcae772b8ab

See more details on using hashes here.

Provenance

Supported by

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