You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple template for creating DES models in Python, within a **reproducible analytical pipeline (RAP)** <br>
10
+
<br>A template for creating **discrete-event simulation (DES)** models in Python<br>
11
+
within a **reproducible analytical pipeline (RAP)**. <br><br>
11
12
Click on <kbd>Use this template</kbd> to initialise new repository.<br>
12
13
A `README` template is provided at the **end of this file**.
13
14
@@ -41,9 +42,9 @@ This repository provides a template for building discrete-event simulation (DES)
41
42
♻️ **Reproducible:** This template is designed to function as a RAP. It adheres to reproducibility recommendations from:
42
43
43
44
*["Levels of RAP" framework](https://nhsdigital.github.io/rap-community-of-practice/introduction_to_RAP/levels_of_RAP/) from the NHS RAP Community of Practice (`docs/nhs_rap.md`).
44
-
* Recommendations from [Heather et al. 2025](TODO:ADDLINK) "*On the reproducibility of discrete-event simulation studies in health research: an empirical study using open models*" (`docs/heather_2025.md`).
45
+
* Recommendations from [Heather et al. 2025](https://doi.org/10.48550/arXiv.2501.13137) "*On the reproducibility of discrete-event simulation studies in health research: an empirical study using open models*" (`docs/heather_2025.md`).
45
46
46
-
🚀 **Extendable:** This template adapts from and complements material from Sammi Rosser and Dan Chalk (2024) ["HSMA - the little book of DES"](https://github.com/hsma-programme/hsma6_des_book). The book includes additional advanced features that can be used to extend the model in this template, including:
47
+
🚀 **Extendable:** This template adapts from Sammi Rosser and Dan Chalk (2024) ["HSMA - the little book of DES"](https://github.com/hsma-programme/hsma6_des_book). The book includes additional advanced features that can be used to extend the model in this template, including:
47
48
48
49
* Multiple activities
49
50
* Branching paths
@@ -149,6 +150,12 @@ To run tests, ensure environment is active and located in main directory (i.e. p
149
150
pytest
150
151
```
151
152
153
+
To run tests in parallel -
154
+
155
+
```
156
+
pytest -n auto
157
+
```
158
+
152
159
The repository contains a GitHub action `tests.yaml` which will automatically run tests with new commits to GitHub. This is continuous integration, helping to catch bugs early and keep the code stable. It will run the tests on three operating systems: Ubuntu, Windows and Mac.
153
160
154
161
If you have changed the model behaviour, you may wish to amend, remove or write new tests.
@@ -184,10 +191,12 @@ This section describes the purposes of each class in the simulation.
184
191
*`generate_patient_arrivals()` to handle patient creation, then sending them on to `attend_clinic()`.
185
192
*`interval_audit()` to record utilisation and wait times at specified intervals during the simulation.
186
193
187
-
**Trial Class Usage:**
194
+
**Runner Class Usage:**
195
+
196
+
Having set up `experiment = Runner()`...
188
197
189
-
***Single Run:** Use `trial.run_single()` to execute a single model run.
190
-
***Multiple Runs:** Use `trial.run_trial()` to perform multiple replications of the model.
198
+
***Single Run:** Use `experiment.run_single()` to execute a single model run.
199
+
***Multiple Runs:** Use `experiment.run_reps()` to perform multiple replications of the model.
191
200
192
201
<br>
193
202
@@ -210,6 +219,7 @@ repo/
210
219
├── simulation/ # Local package containing code for the DES model
211
220
├── tests/ # Unit and back testing of the DES model
212
221
├── .gitignore # Untracked files
222
+
├── .pylintrc # Pylint settings
213
223
├── CHANGELOG.md # Describes changes between releases
214
224
├── CITATION.cff # How to cite the repository
215
225
├── CONTRIBUTING.md # Contribution instructions
@@ -230,6 +240,8 @@ The overall run time will vary depending on how the template model is used. A fe
230
240
*`choosing_parameters.ipynb` - 22s
231
241
*`generate_exp_results.ipynb` - 0s
232
242
243
+
<!--TODO: Add test times -->
244
+
233
245
These times were obtained on an Intel Core i7-12700H with 32GB RAM running Ubuntu 24.04.1 Linux.
Copy file name to clipboardExpand all lines: docs/heather_2025.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Reproducibility recommendations from Heather et al. 2025
2
2
3
-
As part of the project STARS (Sharing Tools and Artefacts for Reproducible Simulations), a series of computational reproducibility assessments were conducted by Heather et al. 2025 (**TODO: add DOI of pre-print**). From these, several recommendations were shared to support reproducibility of healthcare discrete-event simulation (DES) models. These are copied below. Those marked with a star (⭐) were identified as having the greatest impact in Heather et al. 2025.
3
+
As part of the project STARS (Sharing Tools and Artefacts for Reproducible Simulations), a series of computational reproducibility assessments were conducted by [Heather et al. 2025](https://doi.org/10.48550/arXiv.2501.13137). From these, several recommendations were shared to support reproducibility of healthcare discrete-event simulation (DES) models. These are copied below. Those marked with a star (⭐) were identified as having the greatest impact in Heather et al. 2025.
Copy file name to clipboardExpand all lines: docs/hsma_changes.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -132,9 +132,9 @@ param.patient_inter = 10
132
132
model = Model(param)
133
133
```
134
134
135
-
## Saving trial results
135
+
## Saving replication results
136
136
137
-
To save trial-level results in the HSMA models, an empty dataframe is initialised during the __init__ method of the `Trial` class.
137
+
To save results from each run in the HSMA models, an empty dataframe is initialised during the __init__ method of the `Trial` class (equivalent to the `Runner` class in this template).
138
138
139
139
```
140
140
self.df_trial_results = pd.DataFrame()
@@ -164,7 +164,7 @@ In the template, results are instead saved as a dictionary into a list as the ru
164
164
Also, some of the calculations have been performed directly during the `run_single()` method, instead of from a seperate method `calculate_run_results()`. This is to help simplify the code, as it makes clear how each metric was calculated in one place, rather than needing to refer elsewhere.
| Data produced by code in an open-source language (e.g., Python, R, SQL). | ✅ | Python |
16
16
| Code is version controlled (see [Git basics](https://nhsdigital.github.io/rap-community-of-practice/training_resources/git/introduction-to-git/) and [using Git collaboratively](https://nhsdigital.github.io/rap-community-of-practice/training_resources/git/using-git-collaboratively/) guides). | ✅ |[GitHub](https://github.com/pythonhealthdatascience/rap_template_python_des/)|
17
17
| Repository includes a README.md file (or equivalent) that clearly details steps a user must follow to reproduce the code (use [NHS Open Source Policy section on Readmes](https://github.com/nhsx/open-source-policy/blob/main/open-source-policy.md#b-readmes) as a guide). | ✅ | - |
18
-
| Code has been [peer reviewed](https://nhsdigital.github.io/rap-community-of-practice/implementing_RAP/workflow/code-review/). |❌|**TODO: Have code peer reviewed, record on GitHub - this would typically be through working on branches and then reviewing code in a pull request before it is merged into the already approved code. Could create empty branch.**|
18
+
| Code has been [peer reviewed](https://nhsdigital.github.io/rap-community-of-practice/implementing_RAP/workflow/code-review/). |✅|Peer reviewed by Tom Monks|
19
19
| Code is [published in the open](https://nhsdigital.github.io/rap-community-of-practice/implementing_RAP/publishing_code/how-to-publish-your-code-in-the-open/) and linked to & from accompanying publication (if relevant). | ✅ & N/A | Shared openly. No publication. |
0 commit comments