Skip to content

Commit f41b0de

Browse files
authored
Merge pull request #2 from pythonhealthdatascience/amy
Updates from Amy
2 parents ee40b7a + 4c7415f commit f41b0de

18 files changed

+967
-735
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Dates formatted as YYYY-MM-DD as per [ISO standard](https://www.iso.org/iso-8601-date-and-time-format.html).
7+
8+
## Unreleased - Date - DOI
9+
10+
🌱 Initial release of tutorial materials.
11+
12+
### Added
13+
14+
* TBC

CITATION.cff

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Visit https://bit.ly/cffinit to generate yours today!
33

44
cff-version: 1.2.0
5-
title: Simpy JupyterLite Template
5+
title: An introduction to Discrete-Event Simulation using Free and Open Source Software
66
message: >-
77
If you use this software, please cite it using the
88
metadata from this file.
@@ -16,8 +16,15 @@ authors:
1616
family-names: Harper
1717
affiliation: University of Exeter
1818
orcid: 'https://orcid.org/0000-0001-5274-5037'
19+
- given-names: Amy
20+
family-names: Heather
21+
affiliation: University of Exeter
22+
orcid: 'https://orcid.org/0000-0002-6596-3479'
1923
repository-code: >-
20-
https://github.com/pythonhealthdatascience/stars-simpy-jupterlite
24+
https://github.com/pythonhealthdatascience/intro-open-sim
25+
abstract: >-
26+
This is a STARS project being prepared for the Operational Research Society
27+
12th Simulation Workshop in 2025 (SW25).
2128
keywords:
2229
- simpy
2330
- jupyterlite

README.md

Lines changed: 35 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,60 @@
1-
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://pythonhealthdatascience.github.io/stars-simpy-jupterlite/notebooks/?path=01_urgent_care_model.ipynb)
1+
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://pythonhealthdatascience.github.io/intro-open-sim/lab/index.html)
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10987817.svg)](https://doi.org/10.5281/zenodo.10987817)
4-
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/)
5-
[![License: MIT](https://img.shields.io/badge/ORCID-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037)
6-
[![License: MIT](https://img.shields.io/badge/ORCID-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
3+
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/release/python-3100/)
4+
[![ORCID: Alison Harper](https://img.shields.io/badge/ORCID:_Alison_Harper-0000--0001--5274--5037-brightgreen)](https://orcid.org/0000-0001-5274-5037)
5+
[![ORCID: Tom Monks](https://img.shields.io/badge/ORCID:_Tom_Monks-0000--0003--2631--4481-brightgreen)](https://orcid.org/0000-0003-2631-4481)
6+
[![ORCID: Amy Heather](https://img.shields.io/badge/ORCID:_Amy_Heather-0000--0002--6596--3479-brightgreen)](https://orcid.org/0000-0002-6596-3479)
77

8-
# An introduction to Discrete-Event Simulation using Free and Open Source Software.
8+
# An introduction to Discrete-Event Simulation (DES) using Free and Open Source Software
99

10-
> Work in progress. This is a STARS project being prepared for [SW25](https://www.theorsociety.com/ORS/ORS/Events/2025/Simulation-Workshop/SW25.aspx)
10+
> Work in progress. This is a STARS project being prepared for the [Operational Research Society 12th Simulation Workshop in 2025 (SW25)](https://www.theorsociety.com/ORS/ORS/Events/2025/Simulation-Workshop/SW25.aspx). It has been adapted from our [template repository](https://github.com/pythonhealthdatascience/stars-simpy-jupterlite) for sharing `simpy` models with JupyterLite.
1111
12-
## 1. Overview
12+
## 🧑‍💻 1. Tutorial
1313

14-
The materials and methods in this repository support work towards developing the S.T.A.R.S healthcare framework version 1.5 (**S**haring **T**ools and **A**rtifacts for **R**eproducible **S**imulations in healthcare). The code and written materials here are a work in progress to demonstrate the application of S.T.A.R.S' version to sharing a `simpy` discrete-event simuilation model and associated research artifacts.
14+
We being with two notebooks that introduce some basic concepts for creating DES in python:
1515

16-
The model will run on a users browser without the need to install any components. This is achieved using Web Assembly technology i.e. [JupterLite](https://github.com/jupyterlite/jupyterlite) and [xeus-python](https://github.com/jupyter-xeus/xeus-python). A model notebook is downloaded to the users local machine and all dependencies are pre-installed via conda-forge. The model then lives in the browsers cache. The user can make changes to the model or create new files and these are persisted (until the browser cache is cleared).
16+
* `01_sampling.ipynb`: Sampling from statistical distributions using `numpy`
17+
* `02_basic_simpy.ipynb`: Creating simple `simpy` DES models that make use of `numpy` sampling
1718

18-
> Try it in your browser now: https://pythonhealthdatascience.github.io/stars-simpy-jupterlite
19+
Your understanding of these is then tested in:
1920

20-
### 1.1. Use case
21+
* `03a_exercise1.ipynb`: Exercise to testing understanding of the basics of `simpy` and `numpy`
22+
* `03b_exercise1_solutions.ipynb`: Example solutions for the exercise
2123

22-
* A researcher wishes to share a runnable version of a simulation model with their publication (e.g. written in `simpy`). The code allows others to replicate the simulation results, tables and charts in a paper and allows others to reuse the model.
23-
* The researcher wants the model to be immediately usable. Users should not need to install python, `simpy` or any dependencies.
24-
* The researcher either wants to reduce load on online open science compute infrastructure (e.g. mybinder.org) or does not want to rely on it.
25-
* Users may want to use a version of their own data due to governance, ethics or other reasons **cannot upload the data to a remote instance of the model.**
26-
* Loading the model is as simple as clicking a URL.
24+
We then move on to some more advanced concepts, and create a full process model:
2725

28-
### 1.2. Credits ✨
26+
* `04_111_model.ipynb`: Full `simpy` process model, creating a model for a 111 call centre
27+
* `05_basic_results.ipynb`: Collecting results from a single run by storing process metrics during a run and performing calculations at the end
2928

30-
> We would like to thank the [JupterLite](https://github.com/jupyterlite/jupyterlite) and [xeus-python](https://github.com/jupyter-xeus/xeus-python) developers for making this work possible. This discrete-event simulation focussed repository was based on the learning materials and template provided by [Jupyterlite xeus-python demo](https://github.com/jupyterlite/xeus-python-demo) and [tutorial given at PyData 2023](https://www.youtube.com/watch?v=WXRslU9D3bo) by Jeremy Tuloup.
29+
## 🔧 2. Set-up
3130

32-
### 1.3. Citation
31+
To run the notebooks in this tutorial, you can either run via your browser or locally...
3332

34-
If you use the template in your work we would greatly appreciate a citation when you publish your work.
33+
### 2.1 Running notebooks within your browser
3534

36-
> Monks, T., & Harper, A. (2024). Simpy JupyterLite Template (v0.1.0). Zenodo. https://doi.org/10.5281/zenodo.10987817
35+
This tutorial has been set up to run on your browser without the need to install any components. This is achieved using Web Assembly technology i.e. [JupterLite](https://github.com/jupyterlite/jupyterlite) and [xeus-python](https://github.com/jupyter-xeus/xeus-python). A model notebook is downloaded to your local machine and all dependencies are pre-installed via conda-forge. The model then lives in the browsers cache. You can make changes to the model or create new files and these are persisted (until the browser cache is cleared).
3736

38-
```
39-
@software{monks_harper_jupyterlite_template,
40-
author = {Monks, Thomas and
41-
Harper, Alison},
42-
title = {Simpy JupyterLite Template},
43-
month = apr,
44-
year = 2024,
45-
publisher = {Zenodo},
46-
version = {v0.1.0},
47-
doi = {10.5281/zenodo.10987817},
48-
url = {https://doi.org/10.5281/zenodo.10987817}
49-
}
50-
```
51-
52-
53-
## 2. The example model included
54-
55-
The `simpy` model is adapted from [Monks and Harper (2023)](https://github.com/pythonhealthdatascience/stars-simpy-example-docs)
56-
57-
> 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
58-
59-
Full documentation of this model is available in our [JupyterBook](https://pythonhealthdatascience.github.io/stars-simpy-example-docs)
60-
61-
In summary, we adapt a textbook example from Nelson (2013): a terminating discrete-event simulation model of a U.S based treatment centren summary the model. The example is based on exercise 13 from Nelson (2013) page 170.
62-
63-
> *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.*
64-
65-
## 3. Try the example DES in your browser
66-
67-
* Jupyterlab: https://pythonhealthdatascience.github.io/stars-simpy-jupterlite
68-
* Classic notebook: https://pythonhealthdatascience.github.io/stars-simpy-jupterlite/notebooks/?path=01_urgent_care_model.ipynb
37+
> **To access this tutorial in your browser:** <https://pythonhealthdatascience.github.io/intro-open-sim/>.
6938
70-
## 4. Using the template to create a new repo.
39+
### 2.2 Running notebooks locally on your machine
7140

72-
> There are three steps: i.) create a new repo form the template; ii.) modify you repo settings so that GitHub pages are built from Actions. iii.) Commit changes and trigger the GitHub Action and deployment. We recommend reading all instructions first.
41+
You can also run the notebooks in `content/` locally on your machine. You'll need to install the provided conda environment `environment.yml`.
7342

74-
Let's assume you wanted to create a new discrete-event simulation model of cancer services.
75-
76-
1. The first step is to copy the template. Click on the green "use this template" button in the top right and select "create a new repository"
77-
2. You will be prompted to enter a name of the repository - e.g. `cancer_model` - and a short description
78-
3. Click on "Create Repository"
79-
80-
![Deploy your own](img/use_template_1.gif)
81-
82-
The JuypterLite interactive website is built from GitHub actions. **In the newly created repo for your model** do the following
83-
84-
4. Navigate to "Settings->Pages"
85-
5. Under "Build and Deployment" set the "Source" to "GitHub actions".
86-
87-
![Deploy your own](img/actions.gif)
88-
89-
By default the build is trigged on any commit to the `main` branch. Push a small commit and it will trigger the build. This will take a few minutes. Your site will be published under https://{USERNAME}.github.io/{DEMO_REPO_NAME}
43+
```
44+
conda env create --name xeus-python-kernel --file environment.yml
45+
conda activate xeus-python-kernel
46+
```
9047

91-
## 5. How to install extra packages supporting your DES model. 📦
48+
## 📝 3. Citation
9249

93-
The repo contains two environment files. To install more dependencies for your DES model and analysis you need to edit the ``environment.yml`` file.
50+
TBC.
9451

95-
The template ``environment.yml`` is as follows:
52+
## 🤝 4. Acknowledgements
9653

54+
<!--TODO: Is this just relevant to the template repository, or likewise to this one?-->
9755

98-
```yml
99-
name: xeus-python-kernel
100-
channels:
101-
- https://repo.mamba.pm/emscripten-forge
102-
- conda-forge
103-
dependencies:
104-
- xeus-python
105-
- ipycanvas
106-
- simpy=4.1.1
107-
- numpy
108-
- pandas
109-
- matplotlib
110-
```
56+
We would like to thank the [JupterLite](https://github.com/jupyterlite/jupyterlite) and [xeus-python](https://github.com/jupyter-xeus/xeus-python) developers for making this work possible. This discrete-event simulation focussed tutorial was based on the learning materials and template provided by [Jupyterlite xeus-python demo](https://github.com/jupyterlite/xeus-python-demo) and [tutorial given at PyData 2023](https://www.youtube.com/watch?v=WXRslU9D3bo) by Jeremy Tuloup.
11157

112-
**Key points:**
113-
114-
* There are two channels in use.
115-
* `encription-forge` contains specific versions of the packages for web assembly These include `numpy` `pandas`, and `matplotlib`. Other popular packages include `scipy`, `scikit-learn` and `pytest`.
116-
* `conda-forge` for other installs you can use conda-forge. Only ``no-arch`` packages from ``conda-forge`` can be installed (simpy qualifies)
117-
* Note that `numpy`, `pandas` and `matplotlib` have specific versions available on `enscription-forge`. For this reason we recommend not including the package version number.
118-
* `simpy` is installed from `conda-forge` we were therefore able to freeze the version to 4.1.1 to aid reproducibility.
119-
* At the time of writing the xeus-python kernal will use python 3.11.3
120-
121-
As an example modification assume that you wanted to add two new packages: `plotly` and `scipy`. The first `plotly` is available ``no-arch`` from conda-forge so it is safe to include and if you wanted to you could try to include a version number. There is a specific version of `scipy` is available on `encription-forge`
122-
123-
Our modified environment looks like:
124-
125-
```yml
126-
name: xeus-python-kernel
127-
channels:
128-
- https://repo.mamba.pm/emscripten-forge
129-
- conda-forge
130-
dependencies:
131-
- xeus-python
132-
- ipycanvas
133-
- simpy=4.1.1
134-
- numpy
135-
- pandas
136-
- matplotlib
137-
- plotly
138-
- scipy
139-
```
58+
## 💰 5. Funding
14059

141-
If you wanted to use an alternative simulation package to `simpy` this would need to be available on `conda-forge` and be ``no-arch``. An example package is `salabim`. A modification of the enviroment is:
142-
143-
144-
```yml
145-
name: xeus-python-kernel
146-
channels:
147-
- https://repo.mamba.pm/emscripten-forge
148-
- conda-forge
149-
dependencies:
150-
- xeus-python
151-
- ipycanvas
152-
- salabim
153-
- numpy
154-
- pandas
155-
- matplotlib
156-
- plotly
157-
- scipy
158-
```
60+
STARS is supported by the Medical Research Council [grant number [MR/Z503915/1](https://gtr.ukri.org/projects?ref=MR%2FZ503915%2F1)].

content/01_sampling.ipynb

Lines changed: 24 additions & 20 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)