Work in progress. This is a STARS project being prepared for the Operational Research Society 12th Simulation Workshop in 2025 (SW25). It has been adapted from our template repository for sharing
simpy
models with JupyterLite.
We being with two notebooks that introduce some basic concepts for creating DES in python:
01_sampling.ipynb
: Sampling from statistical distributions usingnumpy
02_basic_simpy.ipynb
: Creating simplesimpy
DES models that make use ofnumpy
sampling
Your understanding of these is then tested in:
03a_exercise1.ipynb
: Exercise to testing understanding of the basics ofsimpy
andnumpy
03b_exercise1_solutions.ipynb
: Example solutions for the exercise
We then move on to some more advanced concepts, and create a full process model:
04_111_model.ipynb
: Fullsimpy
process model, creating a model for a 111 call centre05_basic_results.ipynb
: Collecting results from a single run by storing process metrics during a run and performing calculations at the end
To run the notebooks in this tutorial, you can either run via your browser or locally...
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 and 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).
✨ To access this tutorial in your browser: https://pythonhealthdatascience.github.io/intro-open-sim/.
Either clone the repository using git or click on the green "code" button and select "Download Zip".
git clone https://github.com/pythonhealthdatascience/intro-open-sim.git
All dependencies can be found in binder/environment.yml
and are pulled from conda-forge. To run the code locally, we recommend installing miniforge;
miniforge is FOSS alternative to Anaconda and miniconda that uses conda-forge as the default channel for packages. It installs both conda and mamba (a drop in replacement for conda) package managers. We recommend mamba for faster resolving of dependencies and installation of packages.
navigating your terminal (or cmd prompt) to the directory containing the repo and issuing the following command:
mamba env create -f binder/environment.yml
Activate the mamba environment using the following command:
mamba activate simpy_tutorial
You can then run the notebooks in content/
locally on your machine using JupyterLab. Issue the following command and JupyterLab will open in your browser. Notebooks are in the content/
directory.
jupyter-lab
TBC.
We would like to thank the JupterLite and 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 and tutorial given at PyData 2023 by Jeremy Tuloup.
STARS is supported by the Medical Research Council [grant number MR/Z503915/1].