Skip to content

examples: add SIR epidemic model with Mesa 4.0 discrete space API#435

Open
B2prakash wants to merge 2 commits intomesa:mainfrom
B2prakash:add-sir-epidemic-model
Open

examples: add SIR epidemic model with Mesa 4.0 discrete space API#435
B2prakash wants to merge 2 commits intomesa:mainfrom
B2prakash:add-sir-epidemic-model

Conversation

@B2prakash
Copy link

@B2prakash B2prakash commented Mar 22, 2026

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 using OrthogonalMooreGrid and CellAgent
  • app.py: SolaraViz visualization with adjustable parameters
  • Readme.md: Background, model description, parameters, how to run, results
  • metadata.toml: Structured metadata for discoverability

What this demonstrates

  • CellAgent for grid-based agents with state transitions
  • OrthogonalMooreGrid with Moore neighborhood for spatial interaction
  • DataCollector for tracking population-level metrics
  • SolaraViz interactive visualization

GSoC 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 CellAgent replaces the old mesa.Agent + manual grid placement pattern, how cell.neighborhood replaces get_neighborhood(), and how agent movement works through cell assignment rather than move_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:

  • I have read the contributing guide
  • I have performed a self-review
  • Another GSoC contributor has reviewed this PR: @Vanya-kapoor
  • Model runs without errors: python model.py
  • Documentation included (Readme.md)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant