Skip to main content

A free and open implementation of the Treatment Centre Model from Nelson (2013)

Project description

Binder License: MIT Python 3.8+ DOI PyPI version fury.io

Towards Sharing Tools, and Artifacts, for Reusable Simulation: a minimal model example

Overview

The materials and methods in this repository support work towards developing the S.T.A.R.S healthcare framework (Sharing Tools and Artifacts for Reusable Simulations in healthcare). The code and written materials here demonstrate the application of S.T.A.R.S' version 1 to sharing a SimPy discrete-event simulation model and associated research artifacts.

  • All artifacts in this repository are linked to study researchers via ORCIDs;
  • Model code is made available under an MIT license;
  • Python dependencies are managed through conda;
  • Documentation of the model is enhanced using a Jupyter notebook.
  • The python code itself can be viewed and executed in Jupyter notebooks via Binder;
  • The materials are deposited and made citable using Zenodo;
  • The model is sharable with other researchers and the NHS without the need to install software.

Author ORCIDs

ORCID: Harper ORCID: Monks

Funding

This code is part of independent research supported by the National Institute for Health Research Applied Research Collaboration South West Peninsula. The views expressed in this publication are those of the author(s) and not necessarily those of the National Institute for Health Research or the Department of Health and Social Care.

Instructions to run the model

Online Notebooks via Binder

The python code for the model has been setup to run online in Jupyter notebooks via binder Binder

mybinder.org is a free tier service. If it has not been used in a while Binder will need to re-containerise the code repository, and push to BinderHub. This will take several minutes. After that the online environment will be quick to load.

To download code and run locally

Downloading the code

Either clone the repository using git or click on the green "code" button and select "Download Zip".

git clone https://github.com/pythonhealthdatascience/stars-treat-sim

Installing dependencies

Python 3.8+

All dependencies can be found in binder/environment.yml and are pulled from conda-forge. To run the code locally, we recommend install mini-conda; navigating your terminal (or cmd prompt) to the directory containing the repo and issuing the following command:

conda env create -f binder/environment.yml

Activate the conda environment using the following command:

conda activate stars_treat_sim

Running the model

To run 50 multiple replications across a number of example experiments, use the following code:

from treat_sim.model import (get_scenarios, run_scenario_analysis,
                             scenario_summary_frame, 
                             DEFAULT_RESULTS_COLLECTION_PERIOD)

if __name__ == '__main__':

    results = run_scenario_analysis(get_scenarios(), 
                                    DEFAULT_RESULTS_COLLECTION_PERIOD,
                                    n_reps=50)

    results_summary = scenario_summary_frame(results)
    print(results_summary)

Alternative you can design and execute individual experiments by creating a Scenario object:

from treat_sim.model import Scenario, multiple_replications

if __name__ == '__main__':

    # use all default parameter values
    base_case = Scenario()

    results = multiple_replications(base_case).describe().round(2).T
    print(results)

Repo overview

.
├── binder
│   └── environment.yml
├── CHANGES.md
├── CITATION.cff
├── LICENSE
├── MANIFEST.in
├── notebooks
│   └── test_package.ipynb
├── README.md
├── requirements.txt
├── setup.py
└── treat_sim
    ├── data
    │   └── ed_arrivals.csv
    ├── distributions.py
    ├── __init__.py
    └── model.py
  • binder/ - contains the environment.yml file (sim) and all dependencies managed via conda, used to set-up the notebooks on Binder.
  • CHANGES.md - changelog with record of notable changes to project between versions.
  • CITATION.cff - citation information for the package.
  • LICENSE - details of the MIT permissive license of this work.
  • MANIFEST.in - files to include in the package.
  • notebooks/ - contains a notebook to run the model and provides basic enhanced model documentation.
  • README.md - what you are reading now!
  • requirements.txt - list of packages and minimum versions required.
  • setup.py - used to build and distribute package.
  • treat_sim/ - contains packaged version of the model.
    • data/ - directory containing data file used by package.
    • distributions.py - distribution classes.
    • __init__.py - required as part of package - contains author and version.
    • model.py - example SimPy model.

Citation

If you use the materials within this repository we would appreciate a citation.

Monks, T., Harper, A., & Heather, A. (2024). Towards Sharing Tools, and Artifacts, for Reusable Simulation: a minimal model example (v1.2.0). Zenodo. https://doi.org/10.5281//zenodo.10026326
@software{stars_treat_sim,
  author       = {Thomas Monks, Alison Harper and Amy Heather},
  title        = {{Towards Sharing Tools, and Artifacts, for Reusable 
                   Simulation: a minimal model example}},
  month        = May,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {v1.2.0},
  doi          = {10.5281//zenodo.10026326.},
  url          = {https://doi.org/10.5281//zenodo.10026326}
}

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

treat_sim-1.2.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

treat_sim-1.2.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file treat_sim-1.2.0.tar.gz.

File metadata

  • Download URL: treat_sim-1.2.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for treat_sim-1.2.0.tar.gz
Algorithm Hash digest
SHA256 1cf076f0d00f042f46ee1b16a1718ffe63117ee8a26a3c4370b96d1181611292
MD5 b548da1bfc4e7ef32d97c6c16bd74157
BLAKE2b-256 602856587e5d922400a52027e0790ce144b14b3a0694e55fe5047a6c309c4277

See more details on using hashes here.

File details

Details for the file treat_sim-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: treat_sim-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for treat_sim-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02785191e1a3b924ffb76346a4bd3d26c8a77f7ac641e5d97cbe27a142f7fd84
MD5 8beae5e34d398fd0192a61ab19afcb97
BLAKE2b-256 7a4845a42ef2138026d713527468969ff38fc6b1865991a6d8a18275c7f5884a

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