examples: add SIR epidemic model with Mesa 4.0 discrete space API#435
Open
examples: add SIR epidemic model with Mesa 4.0 discrete space API#435
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: add SIR epidemic model with Mesa 4.0 discrete space API`
Summary
Adds a new SIR (Susceptible-Infected-Recovered) epidemic model demonstrating disease spread on a 2D grid using Mesa 4.0's discrete space API.
Files
model.py: SIR model usingOrthogonalMooreGridandCellAgentapp.py: SolaraViz visualization with adjustable parametersReadme.md: Background, model description, parameters, how to run, resultsmetadata.toml: Structured metadata for discoverabilityWhat this demonstrates
CellAgentfor grid-based agents with state transitionsOrthogonalMooreGridwith Moore neighborhood for spatial interactionDataCollectorfor tracking population-level metricsGSoC contributor checklist
Context & motivation: I built this model as part of my GSoC preparation for the Behavioral Modeling Framework project. The SIR model is a natural fit for mesa-examples because it demonstrates state-based agent behavior — agents transition between states based on local interactions, which is a pattern common to many behavioral models.
What I learned: Building this model taught me Mesa 4.0's discrete space system — how
CellAgentreplaces the oldmesa.Agent+ manual grid placement pattern, howcell.neighborhoodreplacesget_neighborhood(), and how agent movement works through cell assignment rather thanmove_agent(). The biggest difference from Mesa 3.x is that agents "live in" cells rather than being "placed on" a grid.Learning repo: https://github.com/B2prakash/GSoC-learning-space
Readiness checks:
python model.py