Skip to content

Add ER simulation example using Actions API#389

Open
Austin-dev-dot wants to merge 3 commits intomesa:mainfrom
Austin-dev-dot:add-er-simulation-example
Open

Add ER simulation example using Actions API#389
Austin-dev-dot wants to merge 3 commits intomesa:mainfrom
Austin-dev-dot:add-er-simulation-example

Conversation

@Austin-dev-dot
Copy link

Adds an emergency room simulation that demonstrates Mesa's Action system.

Follows up on mesa/mesa#3533, which was closed with the suggestion to submit the example here instead (per @EwoutH).

What it demonstrates:

  • Action subclassing with Triage and Treat actions
  • Interruptible/resumable treatments for priority scheduling
  • Stochastic patient arrivals via schedule_event
  • Priority queue where critical patients bump moderate treatments

Files added:

  • er_simulation/agents.py - Patient, Doctor agents and Triage, Treat actions
  • er_simulation/model.py - ERModel with event-driven arrivals
  • tests.py - smoke tests for patient processing, doctor utilization, wait times
  • README.md, requirements.txt

Austin-dev-dot and others added 2 commits March 16, 2026 00:26
Emergency room simulation demonstrating Mesa's Action system:
- Triage and Treat actions with lifecycle hooks
- Interruptible/resumable treatments for priority scheduling
- Stochastic patient arrivals via schedule_event

Follows up on mesa/mesa#3533, moved here per maintainer guidance.
@EwoutH
Copy link
Member

EwoutH commented Mar 15, 2026

Thanks for the PR, ER is probably a good use case for this!

Could you:

  • Add a screenshot or gif of the visualisation to the PR description
  • Request a peer-review (and maybe do one or two yourself)

Copy link
Contributor

@ShreyasN707 ShreyasN707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me.

One suggestion: in _on_arrival() the variable nurse refers to a doctor returned by _get_free_doctor(). Renaming it to doctor might improve clarity.

@Austin-dev-dot
Copy link
Author

Thanks for the review.Ya ur right renaming the variable would make the intent clear

This PR looks good to me.

One suggestion: in _on_arrival() the variable nurse refers to a doctor returned by _get_free_doctor(). Renaming it to doctor might improve clarity.

Thanks for the review.Ya ur right renaming the variable would make the intent clear

@Austin-dev-dot
Copy link
Author

Thanks for the PR, ER is probably a good use case for this!

Could you:

  • Add a screenshot or gif of the visualisation to the PR description
  • Request a peer-review (and maybe do one or two yourself)

Thank you for reviewing this.I'll update the PR description very soon with a screenshot visualisation
Also yes I’ll also request a peer review and review a couple of other PRs from my side

@EwoutH
Copy link
Member

EwoutH commented Mar 16, 2026

Thanks both for your initial efforts. You’re on the right track.

A review should take place on a deeper level. Basically:

  • run the model, play with it, explore interesting behavior. Ask question about that, discuss it and write it down as pointers that users can observe and play with.
  • I expect some code-level questions/comments.

The former is more important than the latter.

@ShreyasN707
Copy link
Contributor

@EwoutH sure ! Once I get back I will take a deeper look into the PRs . Thankyou for the guidance.

@Austin-dev-dot
Copy link
Author

Thanks both for your initial efforts. You’re on the right track.

A review should take place on a deeper level. Basically:

  • run the model, play with it, explore interesting behavior. Ask question about that, discuss it and write it down as pointers that users can observe and play with.

  • I expect some code-level questions/comments.

The former is more important than the latter.

definitely I'll
look into it

@ShreyasN707
Copy link
Contributor

I ran the model localy and it works well :
Screenshot from 2026-03-16 18-47-52
I also tested it with different parameters and it worked well!

@Austin-dev-dot can you improve the Readme.md so that it can be more readable and the startup of the model can be understood easily by other contributors.

@Austin-dev-dot
Copy link
Author

Austin-dev-dot commented Mar 16, 2026

image heres a ss for visualisation and yes I'll update ther readme file as well

Expanded the README to provide a detailed explanation of the emergency room simulation model, including its features, running instructions, project structure, and parameters for experimentation.
@Harshini2411
Copy link

Hey, great work on this! A few things to fix:

  • nurse in _on_arrival() still needs to be renamed to doctor
  • model.triage_queue_length, model.treatment_queue_length, model.total_interruptions don't exist in model.py that quick start snippet will crash.
  • render_visuals.py is referenced in the README but not included in the PR.
  • There's no app.py / SolaraViz visualization, most examples in the repo have one. Would be good to add so users can actually interact with the model in a browser.

Overall solid though, especially the README!

@Austin-dev-dot
Copy link
Author

Hey, great work on this! A few things to fix:

  • nurse in _on_arrival() still needs to be renamed to doctor
  • model.triage_queue_length, model.treatment_queue_length, model.total_interruptions don't exist in model.py that quick start snippet will crash.
  • render_visuals.py is referenced in the README but not included in the PR.
  • There's no app.py / SolaraViz visualization, most examples in the repo have one. Would be good to add so users can actually interact with the model in a browser.

Overall solid though, especially the README!

Thank you so much for the time given to review this
will definitely work on the issues u stated

@Harshini2411
Copy link

Happy to help, good luck with it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants