stars-treat-sim

Implementation of python package for Nelson's (2013) treatment centre model

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

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.1%) to scientific vocabulary
Last synced: 4 months ago · JSON representation ·

Repository

Implementation of python package for Nelson's (2013) treatment centre model

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • Open Issues: 4
  • Releases: 0
Created over 2 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Citation

README.md

💫 Towards Sharing Tools, and Artifacts, for Reusable Simulation (STARS): a minimal model example

Binder License: MIT Python DOI PyPI version fury.io

Overview

The materials and methods in this repository support work towards developing the STARShealthcare framework (Sharing Tools and Artifacts for Reusable Simulations in healthcare). The code and written materials here demonstrate the application of STARS 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 mamba;
  • Documentation of the model is enhanced using a simple Jupyter notebook.
  • The python model 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.
  • A full suite of automated tests are provided with the model.

Author ORCIDs

ORCID: Harper ORCID: Monks ORCID: Heather

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

Install from PyPI

If you do not wish to view the code or would like to use the model as part of your own work you can install the model as a python package.

bash pip install treat-sim

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".

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

Installing dependencies

Python

All dependencies can be found in binder/environment.yml and are pulled from conda-forge. To run the code locally, we recommend installing miniforge;

miniforge is FOSS alternative to Anaconda and miniconda that uses conda-forge as the default channel for packages. It installs both conda and mamba (a drop in replacement for conda) package managers. We recommend mamba for faster resolving of dependencies and installation of packages.

navigating your terminal (or cmd prompt) to the directory containing the repo and issuing the following command:

mamba env create -f binder/environment.yml

Activate the mamba environment using the following command:

mamba activate stars_treat_sim

Running the model

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

```python from treatsim.model import (getscenarios, runscenarioanalysis, scenariosummaryframe, DEFAULTRESULTSCOLLECTION_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:

```python from treatsim.model import Scenario, multiplereplications

if name == 'main':

# use all default parameter values
base_case = Scenario()

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

```

The model can be run with different time dependent arrival profiles. By default the model runs with the arrival profile taken from Nelson (2013). The datasets module provides access to an alternative example dataset where arrivals are slightly skewed towards the end of the working day.

```python

from treatsim.model import Scenario, multiplereplications from treatsim.datasets import loadalternative_arrivals

if name == 'main':

# set the arrival profile to later in the day
scenario1 = Scenario(arrival_profile=load_alternative_arrivals())

alternative_results = multiple_replications(scenario1).describe().round(2).T
print(alternative_results)

```

Testing the model

See our online documentation for an overview of testing

To run tests activate the virtual environment and entre the following command:

bash pytest

Alternatively to recieve a test coverage estimate issue the following command

bash pytest --cov=treat_sim tests/

Repo overview

. ├── binder │   └── environment.yml ├── CHANGES.md ├── CITATION.cff ├── LICENSE ├── notebooks │   └── test_package.ipynb ├── pyproject.toml ├── README.md ├── tests │   └── test_datasets.ipynb │   └── test_model.ipynb └── treat_sim ├── data │   └── ed_arrivals.csv │   └── ed_arrivals_scenario1.csv ├── __init__.py ├── datasets.py ├── distributions.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.
  • notebooks/ - contains a notebook to run the model and provides basic enhanced model documentation.
  • pyproject.toml - used to build and distribute python package inc. managing a list of package dependencies.
  • README.md - what you are reading now!
  • tests/ - contains automated testing code
  • treat_sim/ - contains packaged version of the model.
    • data/ - directory containing data file used by package.
    • __init__.py - required as part of package - contains author and version.
    • datasets.py - functions to load example dataset for parameterising the model.
    • distributions.py - distribution classes.
    • 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 (v2.1.0). Zenodo. https://doi.org/10.5281//zenodo.10026326

bibtex @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 = {v2.2.0}, doi = {10.5281//zenodo.10026326.}, url = {https://doi.org/10.5281//zenodo.10026326} }

Owner

  • Name: pythonhealthdatascience
  • Login: pythonhealthdatascience
  • Kind: organization

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: >-
  Towards Sharing Tools, and Artifacts, for Reusable
  Simulation: a minimal model example
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Thomas
    family-names: Monks
    affiliation: University of Exeter
    orcid: 'https://orcid.org/0000-0003-2631-4481'
  - given-names: Alison
    family-names: Harper
    affiliation: University of Exeter
    orcid: 'https://orcid.org/0000-0001-5274-5037'
  - given-names: Amy
    family-names: Heather
    affiliation: University of Exeter
    orcid: 'https://orcid.org/0000-0002-6596-3479'
repository-code: 'https://github.com/pythonhealthdatascience/stars-treat-sim'
identifiers:
  - description: Consistent identifier for archived snapshots of repository (represents all versions, resolves to latest)
    type: doi
    value: '10.5281/zenodo.10026326'
abstract: >

  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 re
  demonstrate the application of S.T.A.R.S' version 1 to
  sharing a `SimPy` discrete-event simulation model and
  associated research artifacts.  
keywords:
  - Free and Open Source Software
  - Model Reuse
  - Discrete-event simulation
  - Open Science
  - SimPy
license: MIT
references:
  - type: article
    title: 'Towards sharing tools and artefacts for reusable simulations in healthcare'
    authors:
      - given-names: Thomas
        family-names: Monks
      - given-names: Alison
        family-names: Harper
      - given-names: Navonil
        family-names: Mustafee
    doi: 10.1080/17477778.2024.2347882
    journal: 'Journal of Simulation'
    publisher:
      name: 'Taylor & Francis'
    month: 5
    year: 2024
  - type: book
    title: 'Foundations and Methods of Stochastic Simulation'
    authors:
      - given-names: Barry L.
        family-names: Nelson
    publisher:
      name: 'Springer New York'
    year: 2013
    doi: 10.1007/978-1-4614-6160-9
    edition: '1st edition'

GitHub Events

Total
  • Watch event: 1
  • Fork event: 1
Last Year
  • Watch event: 1
  • Fork event: 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 7
  • Total pull requests: 16
  • Average time to close issues: 8 days
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.71
  • Average comments per pull request: 0.06
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: 3 days
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • TomMonks (7)
Pull Request Authors
  • TomMonks (19)
  • amyheather (2)
Top Labels
Issue Labels
bug (2) enhancement (2) invalid (2)
Pull Request Labels

Dependencies

binder/environment.yml pypi
  • treat-sim *
requirements.txt pypi
  • matplotlib >=3.3.4
  • numpy >=1.19.2
  • pandas >=1.2.3
  • scipy >=1.6.1
  • simpy >=4.0.1
setup.py pypi