Skip to content

Dev #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 3, 2025
Merged

Dev #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ __pycache__
.pytest_cache
.pytype

# Log messages, except the example one generated by logs.ipynb
*.log
!log_example.log

# vscode
.vscode/*
Expand Down
5 changes: 5 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ authors:
email: a.heather2@exeter.ac.uk
affiliation: University of Exeter
orcid: 'https://orcid.org/0000-0002-6596-3479'
- given-names: Thomas
family-names: Monks
email: t.m.w.monks@exeter.ac.uk
affiliation: University of Exeter
orcid: 'https://orcid.org/0000-0003-2631-4481'
repository-code: >-
https://github.com/pythonhealthdatascience/rap_template_python_des
abstract: >-
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ This section describes the purposes of each class in the simulation.

**Model Run Process:**

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

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

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

> Heather, A. (2025). Simple Reproducible Python Discrete-Event Simulation (DES) Template. Zenodo. https://doi.org/10.5281/zenodo.14622466
> Heather, A. Monks, T. (2025). Python DES RAP Template. Zenodo. https://doi.org/10.5281/zenodo.14622466

You can also cite the GitHub repository:

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

Researcher details:

| Contributor | ORCID | GitHub |
| --- | --- | --- |
| 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 |
| Contributor | Role | ORCID | GitHub |
| --- | --- | --- | --- |
| 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 |
| 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 |

<br>

Expand Down
372 changes: 0 additions & 372 deletions docs/time_weighted_averages.ipynb

This file was deleted.

1 change: 1 addition & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- pytest=8.3.4
- pytest-xdist=3.6.1
- python=3.13.1
- rich=13.9.4
- simpy=4.1.1
- pip:
- kaleido==0.2.1
Expand Down
20 changes: 10 additions & 10 deletions images/model_structure.drawio
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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">
<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">
<diagram name="Page-1" id="ynTKS2v_TZv17swCPKiS">
<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">
<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">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
Expand All @@ -25,7 +25,7 @@
<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">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry x="180" y="20" width="90" height="40" as="geometry" />
</mxCell>
<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">
Expand Down Expand Up @@ -219,13 +219,13 @@
<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">
<mxGeometry x="749.5" y="245.5" width="190" height="31" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<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">
<mxGeometry x="496.5" y="160" width="113" height="40" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<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">
Expand All @@ -243,16 +243,16 @@
<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">
<mxGeometry x="-150" y="400" width="110" height="31" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry x="290" y="160" width="180" height="40" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry x="347" y="250" width="66" height="30" as="geometry" />
</mxCell>
<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">
<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">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="335" y="726" as="sourcePoint" />
<mxPoint x="320" y="790" as="targetPoint" />
Expand All @@ -262,7 +262,7 @@
</Array>
</mxGeometry>
</mxCell>
<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">
<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">
<mxGeometry x="280" y="810" width="200" height="40" as="geometry" />
</mxCell>
</root>
Expand Down
Binary file modified images/model_structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ echo "Linting tests..."
pylint ./tests

echo "Linting notebooks..."
nbqa pylint ./notebooks

echo "Linting time-weighted averages notebook..."
nbqa pylint ./docs/time_weighted_averages.ipynb
nbqa pylint ./notebooks
238 changes: 14 additions & 224 deletions notebooks/analysis.ipynb

Large diffs are not rendered by default.

36 changes: 17 additions & 19 deletions notebooks/choosing_parameters.ipynb

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions notebooks/generate_exp_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"import time\n",
"from IPython.display import display\n",
"\n",
"from simulation.model import Defaults, Runner"
"from simulation.model import Param, Runner"
]
},
{
Expand Down Expand Up @@ -104,16 +104,17 @@
"outputs": [],
"source": [
"# Define model parameters\n",
"param = Defaults()\n",
"param.patient_inter = 4\n",
"param.mean_n_consult_time = 10\n",
"param.number_of_nurses = 4\n",
"param.warm_up_period = 500\n",
"param.data_collection_period = 1500\n",
"param.number_of_runs = 5\n",
"param.audit_interval = 50\n",
"param.scenario_name = 0\n",
"param.cores = 1\n",
"param = Param(\n",
" patient_inter=4,\n",
" mean_n_consult_time = 10,\n",
" number_of_nurses = 4,\n",
" warm_up_period = 500,\n",
" data_collection_period = 1500,\n",
" number_of_runs=5,\n",
" audit_interval = 50,\n",
" scenario_name = 0,\n",
" cores = 1\n",
")\n",
"\n",
"# Run the replications\n",
"experiment = Runner(param)\n",
Expand Down
Loading