Skip to content

Commit 3543a42

Browse files
authored
Merge pull request #3 from AliHarp/dev
Bug fix for treat_sim + merge updates from main
2 parents 9ecad89 + 7d927a9 commit 3543a42

File tree

11 files changed

+854
-647
lines changed

11 files changed

+854
-647
lines changed

CITATION.cff

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This CITATION.cff file was generated with cffinit.
2+
# Visit https://bit.ly/cffinit to generate yours today!
3+
4+
cff-version: 1.2.0
5+
title: >-
6+
Towards Sharing Tools and Artifacts for Reusable
7+
Simulation: example enhanced documentation for a `simpy`
8+
model.
9+
message: >-
10+
If you use this software, please cite it using the
11+
metadata from this file.
12+
type: software
13+
authors:
14+
- given-names: Thomas
15+
family-names: Monks
16+
affiliation: University of Exeter
17+
orcid: 'https://orcid.org/0000-0003-2631-4481'
18+
- given-names: Alison
19+
family-names: Harper
20+
affiliation: University of Exeter
21+
orcid: 'https://orcid.org/0000-0001-5274-5037'
22+
repository-code: >-
23+
https://github.com/pythonhealthdatascience/stars-simpy-example-docs
24+
url: >-
25+
https://pythonhealthdatascience.github.io/stars-simpy-example-docs
26+
keywords:
27+
- Discrete-event simulation
28+
- Open Science
29+
- Reproducibility
30+
- Documentation
31+
- Model reuse
32+
license: MIT

README.md

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,111 @@
1-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TomMonks/treatment-centre-sim/HEAD)
1+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/pythonhealthdatascience/stars-simpy-example-docs/HEAD)
2+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10054063.svg)](https://doi.org/10.5281/zenodo.10054063)
23
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-360+/)
4-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6497477.svg)](https://doi.org/10.5281/zenodo.6497477)
5+
[![Read the Docs](https://readthedocs.org/projects/pip/badge/?version=latest)](https://pythonhealthdatascience.github.io/stars-simpy-example-docs)
6+
[![License: MIT](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037)
7+
[![License: MIT](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
58
[<img src="https://img.shields.io/static/v1?label=dockerhub&message=images&color=important?style=for-the-badge&logo=docker">](https://hub.docker.com/r/tommonks01/treat_sim)
69

10+
# Towards Sharing Tools and Artifacts for Reusable Simulation: example enhanced documentation for a `simpy` model.
711

8-
# An open treatment centre simulation model.
12+
## Overview
913

10-
This work occompanies Monks et al (2022).
14+
The materials and methods in this repository support work towards developing the S.T.A.R.S healthcare framework (**S**haring **T**ools and **A**rtifacts for **R**eusable **S**imulations 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 simuilation model and associated research artifacts.
1115

12-
The repo contains an free and open implementation of the Treatment Centre Model from Nelson (2013). It is published under a permissive MIT license.
16+
* All artifacts in this repository are linked to study researchers via ORCIDs;
17+
* Model code is made available under a MIT license;
18+
* Python dependencies are managed through `conda`;`
19+
* The python code itself can be viewed and executed in Jupyter notebooks via [Binder](https://mybinder.org);
20+
* The model is documented and explained in a [Jupyter book website](https://pythonhealthdatascience.github.io/stars-simpy-example-docs) served up by GitHub pages;
21+
* The materials are deposited and made citatable using Zenodo;
22+
* The models are sharable with other researchers and the NHS without the need to install software.
1323

14-
## References
24+
## Author ORCIDs
1525

16-
1. *Monks.T, Harper.A, Anagnoustou. A, Allen.M, Taylor.S. (2022) Open Science for Computer Simulation*
17-
2. *Nelson. B.L. (2013). [Foundations and methods of stochastic simulation](https://www.amazon.co.uk/Foundations-Methods-Stochastic-Simulation-International/dp/1461461596/ref=sr_1_1?dchild=1&keywords=foundations+and+methods+of+stochastic+simulation&qid=1617050801&sr=8-1). Springer.*
26+
[![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037)
27+
[![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
28+
29+
## Citation
30+
31+
> Monks, T., & Harper, A. (2023). Towards Sharing Tools and Artifacts for Reusable Simulation: example enhanced documentation for a `simpy` model. (v1.1.0). Zenodo. https://doi.org/10.5281/zenodo.10054063
32+
33+
```bibtex
34+
@software{stars_example_docs,
35+
author = {Monks, Thomas and
36+
Harper, Alison},
37+
title = {{Towards Sharing Tools and Artifacts for Reusable
38+
Simulation: example enhanced documentation for a
39+
`simpy` model.}},
40+
month = oct,
41+
year = 2023,
42+
publisher = {Zenodo},
43+
version = {v1.1.0},
44+
doi = {10.5281/zenodo.10054063},
45+
url = {https://doi.org/10.5281/zenodo.10054063},
46+
}
47+
```
48+
49+
## Funding
50+
51+
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.
52+
53+
## Case study model
54+
55+
**This example is based on exercise 13 from Nelson (2013) page 170.**
56+
57+
> *Nelson. B.L. (2013). [Foundations and methods of stochastic simulation](https://www.amazon.co.uk/Foundations-Methods-Stochastic-Simulation-International/dp/1461461596/ref=sr_1_1?dchild=1&keywords=foundations+and+methods+of+stochastic+simulation&qid=1617050801&sr=8-1). Springer.*
58+
59+
We adapt a textbook example from Nelson (2013): a terminating discrete-event simulation model of a U.S based treatment centre. In the model, patients arrive to the health centre between 6am and 12am following a non-stationary Poisson process. On arrival, all patients sign-in and are triaged into two classes: trauma and non-trauma. Trauma patients include impact injuries, broken bones, strains or cuts etc. Non-trauma include acute sickness, pain, and general feelings of being unwell etc. Trauma patients must first be stabilised in a trauma room. These patients then undergo treatment in a cubicle before being discharged. Non-trauma patients go through registration and examination activities. A proportion of non-trauma patients require treatment in a cubicle before being discharged. The model predicts waiting time and resource utilisation statistics for the treatment centre. The model allows managers to ask question about the physical design and layout of the treatment centre, the order in which patients are seen, the diagnostic equipment needed by patients, and the speed of treatments. For example: “what if we converted a doctors examination room into a room where nurses assess the urgency of the patients needs.”; or “what if the number of patients we treat in the afternoon doubled”
60+
61+
## Online Notebooks via Binder
62+
63+
The python code for the model has been setup to run online in Jupyter notebooks via binder [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/pythonhealthdatascience/stars-ciw-example/HEAD)
64+
65+
> Binder is a free 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.
66+
67+
## Online documentation produced by Jupyter-book
68+
69+
[![Read the Docs](https://readthedocs.org/projects/pip/badge/?version=latest)](https://pythonhealthdatascience.github.io/stars-simpy-example-docs)
70+
71+
* The documentation can be access at [https://pythonhealthdatascience.github.io/stars-simpy-example-docs](https://pythonhealthdatascience.github.io/stars-simpy-example-docs)
72+
73+
## How to create the website locally
74+
75+
Alternatively you may wish to create the website on your local machine.
76+
77+
### Downloading the code
78+
79+
Either clone the repository using git or click on the green "code" button and select "Download Zip".
80+
81+
```bash
82+
git clone https://github.com/pythonhealthdatascience/stars-simpy-examplar-docs
83+
```
84+
85+
### Installing dependencies
86+
87+
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-360+/)
88+
89+
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](https://docs.conda.io/en/latest/miniconda.html); navigating your terminal (or cmd prompt) to the directory containing the repo and issuing the following command:
90+
91+
```bash
92+
conda env create -f binder/environment.yml
93+
```
94+
95+
To activate the environment issue the following command:
96+
97+
```bash
98+
conda activate stars_docs`
99+
```
100+
101+
### Building the book
102+
103+
In the directory (folder) containing the code issue the following command via the terminal (or cmd prompt/powershell on windows)
104+
105+
```bash
106+
jb build .
107+
```
108+
109+
> The configutation of the book has been setup to re-run all of the notebooks. It may take a few minutes to execute on your local machine.
110+
111+
When the build is complete Jupyter book will display a hyper-link to the book that has been built on your machine. Click on the link (or copy paste into a browser) to run it.

binder/environment.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: treatment_sim
1+
name: stars_docs
22
channels:
33
- conda-forge
44
dependencies:
@@ -11,4 +11,6 @@ dependencies:
1111
- python=3.8.12
1212
- scipy=1.6.1
1313
- simpy=4.0.1
14+
- pip:
15+
- jupyter-book==0.15.1
1416

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Citation
22

3-
Please cite this online book using:
3+
If you use or adapt the materials in this book please cite the artifacts as follows:
4+
5+
> Monks, T., & Harper, A. (2023). Towards Sharing Tools and Artifacts for Reusable Simulation: example enhanced documentation for a `simpy` model. (v1.1.0). Zenodo. https://doi.org/10.5281/zenodo.10054063
46
57
```bibtex
6-
@software{monks_thomas_2022_6772475,
8+
@software{stars_example_docs,
79
author = {Monks, Thomas and
8-
Harper, Alison and
9-
Taylor, J.E, Simon and
10-
Anagnostou, Anastasia},
11-
title = {TomMonks/treatment-centre-sim: v0.4.0},
12-
month = jun,
13-
year = 2022,
10+
Harper, Alison},
11+
title = {{Towards Sharing Tools and Artifacts for Reusable
12+
Simulation: example enhanced documentation for a
13+
`simpy` model.}},
14+
month = oct,
15+
year = 2023,
1416
publisher = {Zenodo},
15-
version = {v0.4.0},
16-
doi = {10.5281/zenodo.6772475},
17-
url = {https://doi.org/10.5281/zenodo.6772475}
17+
version = {v1.1.0},
18+
doi = {10.5281/zenodo.10054063},
19+
url = {https://doi.org/10.5281/zenodo.10054063},
1820
}
1921
```

content/01_introduction/04_openworking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This project has taken the following steps to ensure the work is discoverable, u
44

55
| | **Level** | **Achieved via** |
66
|---|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7-
| 1 | Open Access | A preprint to accompany and document this pilot work is available via the Open Science Framework [https://doi.org/10.31219/osf.io/zpxtm](https://doi.org/10.31219/osf.io/zpxtm) |
8-
| 2 | Open Artefacts | <ul><li>All research artefacts including this website are archived permanently at [Zenodo](https://doi.org/10.5281/zenodo.6497477)</li><li>Production code is available from [GitHub](https://github.com/TomMonks/treatment-centre-sim)</li></ul> |
7+
| 1 | Open Access | A conference paper of this work was presented at the OR Society Simulation Workshop 2023 [https://www.theorsociety.com/media/7313/doiorg1036819sw23030.pdf](https://www.theorsociety.com/media/7313/doiorg1036819sw23030.pdf) |
8+
| 2 | Open Artifacts | <ul><li>All research artifacts including this website are archived permanently at [Zenodo](https://zenodo.org/records/10054063)</li><li>Production code is available from [GitHub](https://github.com/pythonhealthdatascience/stars-simpy-example-docs)</li></ul> |
99
| 3 | Open Model | <ul><li>The model has been developed using Free and open simulation software;</li> <li>All mode code is reusable and adaptable under the permissive MIT license model;</li><li>The model is documented in detail within a online Jupyter Book;</li><li>Additional documentation organised by the [STRESS-DES checklist](../03_stress/01_objectives.md) within the Jupyter Book.</li></ul> |
1010
| 4 | Open Environment | A [docker image is available via dockerhub](https://hub.docker.com/r/tommonks01/treat_sim) to enable replication of the OS and software environment and model execution on a local machine. |
1111
| 5 | Open Infrastucture | The model can be run online using BinderHub or Thebe |

content/02_model_code/04_model.ipynb

Lines changed: 307 additions & 309 deletions
Large diffs are not rendered by default.

content/02_model_code/output/table_3.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
\toprule
77
Mean waiting time (mins) & base & triage+1 & exam+1 & treat+1 & triage+exam \\
88
\midrule
9-
Triage & 28.86 & 1.09 & 36.46 & 39.36 & 1.14 \\
10-
Registation & 113.56 & 138.79 & 106.27 & 108.46 & 140.14 \\
11-
Examination & 24.57 & 24.15 & 0.13 & 23.03 & 0.15 \\
12-
Non-trauma treatment & 137.72 & 139.98 & 151.82 & 2.26 & 152.09 \\
13-
Trauma stabilisation & 144.46 & 154.00 & 132.94 & 146.09 & 165.43 \\
14-
Trauma treatment & 168.27 & 209.12 & 195.16 & 150.37 & 193.69 \\
9+
Triage & 29.52 & 1.17 & 29.47 & 23.99 & 1.21 \\
10+
Registation & 101.88 & 128.14 & 101.09 & 109.70 & 125.47 \\
11+
Examination & 25.34 & 24.93 & 0.16 & 24.03 & 0.14 \\
12+
Non-trauma treatment & 134.19 & 134.80 & 148.81 & 2.10 & 150.61 \\
13+
Trauma stabilisation & 171.44 & 182.96 & 139.42 & 166.51 & 178.34 \\
14+
Trauma treatment & 20.26 & 22.65 & 19.40 & 16.96 & 19.48 \\
1515
\bottomrule
1616
\end{tabular}
1717
\end{table}

content/03_stress/05_implementation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 5 Implementation
1+
# 5. Implementation
22

33
## 5.1 Software or programming language
44

@@ -22,9 +22,9 @@ A [conda virtual environment](https://github.com/TomMonks/treatment-centre-sim/b
2222

2323
## 5.2 Random sampling
2424

25-
All sampling uses [`numpy.random.Generator`](https://numpy.org/doc/stable/reference/random/generator.html). A `numpy` generator object implements the Permuted Congruential Generator 64-bit (PCG64; period = $2^{128}$).
25+
All sampling uses [`numpy.random.Generator`](https://numpy.org/doc/stable/reference/random/generator.html). A `numpy` generator object implements the Permuted Congruential Generator 64-bit (PCG64; period = $2^{128}$; maximum number of streams = $2^{63}$).
2626

27-
Common random number streams are used in the model. These are created by through seed vectors (one seed for each activity in each replication).
27+
Repeatable experiments and common random number streams are used in the model. Non overlapping streams are creating using a `numpy.random.SeedSequence`. One seed - the replication number - is passed to a `SeedSequence` and $n$ child seeds are spawned that are then used to create the $n$ streams. The seeds spawned by `SeedSequence` ensure that these streams are "very likely" non-overlapping.
2828

2929
## 5.3 Model execution
3030

content/03_stress/06_code_access.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 6 Code access
1+
# 6. Code access
22

33
* Simulation model code is available from the main branch of Githib repo: https://github.com/TomMonks/treatment-centre-sim
44
* All simulation model code is contained within a Jupyter notebook: https://github.com/TomMonks/treatment-centre-sim/blob/main/src/model.ipynb

content/front_page.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6497477.svg)](https://doi.org/10.5281/zenodo.6497477)
44

5-
This book contains example documentation and open working for a computer simulation model. The model is a based on the treatment centre example in Nelson [1]. The model is implemented in `python` and `simpy`.
5+
This book contains example enhanced documentation and open working for a discrete-event simulation model. The model is a based on the treatment centre example in Nelson [1]. The model is implemented in `python` and `simpy`.
66

7-
The book covers the following aspects of open working for simulation:
7+
## Towards Sharing Tools and Artifacts for Reusable Simulation: example enhanced documentation for a `simpy` model.
88

9-
* Sharing your model code and parameters with other researchers and simulation modellers.
10-
* An example of documenting your model using the STRESS reporting checklist (for DES).
11-
* Providing a simple executable version of your model for other to verify results.
9+
The materials and methods in this repository support work towards developing the S.T.A.R.S healthcare framework (**S**haring **T**ools and **A**rtifacts for **R**eusable **S**imulations 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 simuilation model and associated research artifacts.
1210

13-
## Contributors
11+
* All artifacts in this repository are linked to study researchers via ORCIDs;
12+
* Model code is made available under a MIT license;
13+
* Python dependencies are managed through `conda`;`
14+
* The python code itself can be viewed and executed in Jupyter notebooks via [Binder](https://mybinder.org);
15+
* The model is documented and explained in a [Jupyter book website](https://pythonhealthdatascience.github.io/stars-simpy-example-docs) served up by GitHub pages;
16+
* The materials are deposited and made citatable using Zenodo;
17+
* The models are sharable with other researchers and the NHS without the need to install software.
1418

15-
* Thomas Monks, University of Exeter
16-
* Alison Harper, University of Exeter
17-
* Simon Taylor, Brunel University London
18-
* Anastasia Anagnostou, Brunel University London
19+
## Author ORCIDs
1920

20-
## References
21-
22-
1. *Nelson. B.L. (2013). [Foundations and methods of stochastic simulation: A first course](https://www.amazon.co.uk/Foundations-Methods-Stochastic-Simulation-International/dp/1461461596/ref=sr_1_1?dchild=1&keywords=foundations+and+methods+of+stochastic+simulation&qid=1617050801&sr=8-1). Springer.*
21+
[![ORCID: Harper](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037)
22+
[![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)

0 commit comments

Comments
 (0)