27  Example Models from Other Modellers

Looking at the model code written by other people - even if it does not exactly match the kind of system you are trying to create - can be hugely beneficial for seeing new approaches. In this section are links to a range of additional SimPy models that you might wish to read through and adapt.

Note

The majority of these models do not use the HSMA structure of g, Patient, Model and Trial.

You may find it a helpful exercise to try and convert some of the models linked to the structure we have used in this book so far. This will help you really understand what is going on in the model, and help you to start develop your own preferred structure.

When working through these models, consider:

  • What do you prefer about the HSMA structure?
  • What do you prefer about the structure the other modeller uses?
  • Have they chosen to use a single entity class or multiple entity classes? Can you understand their reasoning for their decision?
  • Have they chosen to use a single generator or multiple generators for their patients? Can you see benefits or problems with their chosen approach?

27.1 HSMA clinic model diagram

To aid understanding of different code structures, diagrams have been provided for each example. For comparison, we have generated a diagram of the code structure for the model from Chapter 13. In this model, patients see a patient, nurse and doctor.

Code structure:

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

27.2 A queueing model

A SimPy model of a queueing model for a nurse consultation.

Amy Heather ORCID ID Tom Monks ORCID ID (2025) Python DES RAP Template. https://github.com/pythonhealthdatascience/rap_template_python_des.

The repository includes a document docs/hsma_changes.md which explains how the model differs from those in this book, and why those changes were made.

Code structure:

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

27.3 An urgent care call centre model

A SimPy model of an urgent care call centre where patients speak to an operator, are triaged, and some required callback from a nurse.

Tom Monks ORCID ID Alison Harper ORCID ID Amy Heather ORCID ID (2025) An introduction to Discrete-Event Simulation using Free and Open Source Software. https://github.com/pythonhealthdatascience/intro-open-sim.

Structure as of 10th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

Structure as of 10th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

27.4 A trauma centre model

A SimPy model of an urgent treatment centre with trauma and non-trauma arrivals.

Tom Monks ORCID ID Alison Harper ORCID ID Amy Heather ORCID ID (2024) Towards Sharing Tools, and Artifacts, for Reusable Simulation: a minimal model example (v2.2.0). Zenodo. https://doi.org/10.5281//zenodo.10026326

Code structure:

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

Structure as of 7th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

27.5 An orthopaedic ward

A SimPy model used for orthopaedic elective planning, from the Hospital Efficiency Project (HEP).

Alison Harper ORCID ID Tom Monks ORCID ID (2023) Efficiency Project Orthopaedic Planning Model Discrete-Event Simulation. https://github.com/AliHarp/HEP.

Structure as of 10th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.

Structure as of 10th February 2025. May not include every function/method, but tries to provide a general guide to how things interact. Click image to enlarge. Diagram created using draw.io.