Skip to content

Commit 29fa1c0

Browse files
authored
Merge pull request #23 from pythonhealthdatascience/dev
Dev
2 parents 3f9afdb + c4746ea commit 29fa1c0

22 files changed

+1299
-806
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ __pycache__
33
.pytest_cache
44
.pytype
55

6+
# Log messages, except the example one generated by logs.ipynb
67
*.log
8+
!log_example.log
79

810
# vscode
911
.vscode/*

CITATION.cff

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ authors:
1414
1515
affiliation: University of Exeter
1616
orcid: 'https://orcid.org/0000-0002-6596-3479'
17+
- given-names: Thomas
18+
family-names: Monks
19+
20+
affiliation: University of Exeter
21+
orcid: 'https://orcid.org/0000-0003-2631-4481'
1722
repository-code: >-
1823
https://github.com/pythonhealthdatascience/rap_template_python_des
1924
abstract: >-

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ This section describes the purposes of each class in the simulation.
193193

194194
**Model Run Process:**
195195

196-
1. **Set Parameters:** Create a `Defaults` instance and modify it with desired model parameters.
196+
1. **Set Parameters:** Create a `Param` instance with desired model parameters.
197197
2. **Initialise Model:** Instantiate `Model` using the parameters. During setup, `Model` creates `Exponential` instances for each distribution.
198198
3. **Run Simulation:** Call `model.run()` to execute the simulation within the SimPy environment, running two processes:
199199

@@ -260,17 +260,18 @@ These times were obtained on an Intel Core i7-12700H with 32GB RAM running Ubunt
260260

261261
If you use this template, please cite the archived repository:
262262

263-
> Heather, A. (2025). Simple Reproducible Python Discrete-Event Simulation (DES) Template. Zenodo. https://doi.org/10.5281/zenodo.14622466
263+
> Heather, A. Monks, T. (2025). Python DES RAP Template. Zenodo. https://doi.org/10.5281/zenodo.14622466
264264
265265
You can also cite the GitHub repository:
266266

267-
> Heather, A. (2025). Simple Reproducible Python Discrete-Event Simulation (DES) Template. GitHub. https://github.com/pythonhealthdatascience/rap_template_python_des.
267+
> Heather, A. Monks, T. (2025). Python DES RAP Template. GitHub. https://github.com/pythonhealthdatascience/rap_template_python_des.
268268
269269
Researcher details:
270270

271-
| Contributor | ORCID | GitHub |
272-
| --- | --- | --- |
273-
| Amy Heather | [![ORCID: Heather](https://img.shields.io/badge/ORCID-0000--0002--6596--3479-brightgreen)](https://orcid.org/0000-0002-6596-3479) | https://github.com/amyheather |
271+
| Contributor | Role | ORCID | GitHub |
272+
| --- | --- | --- | --- |
273+
| Amy Heather | Author | [![ORCID: Heather](https://img.shields.io/badge/ORCID-0000--0002--6596--3479-brightgreen)](https://orcid.org/0000-0002-6596-3479) | https://github.com/amyheather |
274+
| Tom Monks | Code review | [![ORCID: Monks](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481) | https://github.com/TomMonks |
274275

275276
<br>
276277

docs/time_weighted_averages.ipynb

Lines changed: 0 additions & 372 deletions
This file was deleted.

environment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies:
1515
- pytest=8.3.4
1616
- pytest-xdist=3.6.1
1717
- python=3.13.1
18+
- rich=13.9.4
1819
- simpy=4.1.1
1920
- pip:
2021
- kaleido==0.2.1

images/model_structure.drawio

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="26.0.9">
1+
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36" version="26.0.10">
22
<diagram name="Page-1" id="ynTKS2v_TZv17swCPKiS">
3-
<mxGraphModel dx="2261" dy="915" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
3+
<mxGraphModel dx="1301" dy="915" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
44
<root>
55
<mxCell id="0" />
66
<mxCell id="1" parent="0" />
@@ -25,7 +25,7 @@
2525
<mxCell id="ltitkqDnKHNBnyyiyaz9-50" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="ltitkqDnKHNBnyyiyaz9-4" target="ltitkqDnKHNBnyyiyaz9-7" edge="1">
2626
<mxGeometry relative="1" as="geometry" />
2727
</mxCell>
28-
<mxCell id="ltitkqDnKHNBnyyiyaz9-4" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;Defaults&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#68A9D4;" parent="1" vertex="1">
28+
<mxCell id="ltitkqDnKHNBnyyiyaz9-4" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;Param&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#68A9D4;" parent="1" vertex="1">
2929
<mxGeometry x="180" y="20" width="90" height="40" as="geometry" />
3030
</mxCell>
3131
<mxCell id="ltitkqDnKHNBnyyiyaz9-62" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="ltitkqDnKHNBnyyiyaz9-5" target="ltitkqDnKHNBnyyiyaz9-8" edge="1">
@@ -219,13 +219,13 @@
219219
<mxCell id="ltitkqDnKHNBnyyiyaz9-100" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;Running the model&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontStyle=1;" parent="1" vertex="1">
220220
<mxGeometry x="749.5" y="245.5" width="190" height="31" as="geometry" />
221221
</mxCell>
222-
<mxCell id="7yZ3_BnLaosynqhN-OXv-4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" edge="1" parent="1" source="vqxNZKrtE7Uk3ozEDKWz-3" target="vqxNZKrtE7Uk3ozEDKWz-6">
222+
<mxCell id="7yZ3_BnLaosynqhN-OXv-4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" parent="1" source="vqxNZKrtE7Uk3ozEDKWz-3" target="vqxNZKrtE7Uk3ozEDKWz-6" edge="1">
223223
<mxGeometry relative="1" as="geometry" />
224224
</mxCell>
225225
<mxCell id="vqxNZKrtE7Uk3ozEDKWz-3" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;SimLogger&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#68A9D4;" parent="1" vertex="1">
226226
<mxGeometry x="496.5" y="160" width="113" height="40" as="geometry" />
227227
</mxCell>
228-
<mxCell id="7yZ3_BnLaosynqhN-OXv-6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" edge="1" parent="1" source="vqxNZKrtE7Uk3ozEDKWz-6" target="vqxNZKrtE7Uk3ozEDKWz-9">
228+
<mxCell id="7yZ3_BnLaosynqhN-OXv-6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" parent="1" source="vqxNZKrtE7Uk3ozEDKWz-6" target="vqxNZKrtE7Uk3ozEDKWz-9" edge="1">
229229
<mxGeometry relative="1" as="geometry" />
230230
</mxCell>
231231
<mxCell id="vqxNZKrtE7Uk3ozEDKWz-6" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;logger&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#A9E4F5;" parent="1" vertex="1">
@@ -243,16 +243,16 @@
243243
<mxCell id="vqxNZKrtE7Uk3ozEDKWz-14" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;Simulation&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontStyle=1;" parent="1" vertex="1">
244244
<mxGeometry x="-150" y="400" width="110" height="31" as="geometry" />
245245
</mxCell>
246-
<mxCell id="7yZ3_BnLaosynqhN-OXv-3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" edge="1" parent="1" source="7yZ3_BnLaosynqhN-OXv-1" target="7yZ3_BnLaosynqhN-OXv-2">
246+
<mxCell id="7yZ3_BnLaosynqhN-OXv-3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;curved=0;" parent="1" source="7yZ3_BnLaosynqhN-OXv-1" target="7yZ3_BnLaosynqhN-OXv-2" edge="1">
247247
<mxGeometry relative="1" as="geometry" />
248248
</mxCell>
249-
<mxCell id="7yZ3_BnLaosynqhN-OXv-1" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;MonitoredResource&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#68A9D4;" vertex="1" parent="1">
249+
<mxCell id="7yZ3_BnLaosynqhN-OXv-1" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;MonitoredResource&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#68A9D4;" parent="1" vertex="1">
250250
<mxGeometry x="290" y="160" width="180" height="40" as="geometry" />
251251
</mxCell>
252-
<mxCell id="7yZ3_BnLaosynqhN-OXv-2" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;nurse&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#A9E4F5;" vertex="1" parent="1">
252+
<mxCell id="7yZ3_BnLaosynqhN-OXv-2" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;nurse&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#A9E4F5;" parent="1" vertex="1">
253253
<mxGeometry x="347" y="250" width="66" height="30" as="geometry" />
254254
</mxCell>
255-
<mxCell id="7yZ3_BnLaosynqhN-OXv-8" value="" style="curved=1;endArrow=classic;html=1;rounded=1;dashed=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="ltitkqDnKHNBnyyiyaz9-22">
255+
<mxCell id="7yZ3_BnLaosynqhN-OXv-8" value="" style="curved=1;endArrow=classic;html=1;rounded=1;dashed=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="ltitkqDnKHNBnyyiyaz9-22" edge="1">
256256
<mxGeometry width="50" height="50" relative="1" as="geometry">
257257
<mxPoint x="335" y="726" as="sourcePoint" />
258258
<mxPoint x="320" y="790" as="targetPoint" />
@@ -262,7 +262,7 @@
262262
</Array>
263263
</mxGeometry>
264264
</mxCell>
265-
<mxCell id="7yZ3_BnLaosynqhN-OXv-11" value="Nurse is a MonitoredResource, so every time it is requested and released, time-weighted monitoring statistics are updated" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;" vertex="1" parent="1">
265+
<mxCell id="7yZ3_BnLaosynqhN-OXv-11" value="Nurse is a MonitoredResource, so every time it is requested and released, time-weighted monitoring statistics are updated" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;" parent="1" vertex="1">
266266
<mxGeometry x="280" y="810" width="200" height="40" as="geometry" />
267267
</mxCell>
268268
</root>

images/model_structure.png

-2.31 KB
Loading

lint.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ echo "Linting tests..."
77
pylint ./tests
88

99
echo "Linting notebooks..."
10-
nbqa pylint ./notebooks
11-
12-
echo "Linting time-weighted averages notebook..."
13-
nbqa pylint ./docs/time_weighted_averages.ipynb
10+
nbqa pylint ./notebooks

notebooks/analysis.ipynb

Lines changed: 14 additions & 224 deletions
Large diffs are not rendered by default.

notebooks/choosing_parameters.ipynb

Lines changed: 17 additions & 19 deletions
Large diffs are not rendered by default.

notebooks/generate_exp_results.ipynb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"import time\n",
5454
"from IPython.display import display\n",
5555
"\n",
56-
"from simulation.model import Defaults, Runner"
56+
"from simulation.model import Param, Runner"
5757
]
5858
},
5959
{
@@ -104,16 +104,17 @@
104104
"outputs": [],
105105
"source": [
106106
"# Define model parameters\n",
107-
"param = Defaults()\n",
108-
"param.patient_inter = 4\n",
109-
"param.mean_n_consult_time = 10\n",
110-
"param.number_of_nurses = 4\n",
111-
"param.warm_up_period = 500\n",
112-
"param.data_collection_period = 1500\n",
113-
"param.number_of_runs = 5\n",
114-
"param.audit_interval = 50\n",
115-
"param.scenario_name = 0\n",
116-
"param.cores = 1\n",
107+
"param = Param(\n",
108+
" patient_inter=4,\n",
109+
" mean_n_consult_time = 10,\n",
110+
" number_of_nurses = 4,\n",
111+
" warm_up_period = 500,\n",
112+
" data_collection_period = 1500,\n",
113+
" number_of_runs=5,\n",
114+
" audit_interval = 50,\n",
115+
" scenario_name = 0,\n",
116+
" cores = 1\n",
117+
")\n",
117118
"\n",
118119
"# Run the replications\n",
119120
"experiment = Runner(param)\n",

0 commit comments

Comments
 (0)