add: LLM Epidemic (SIR) model using Chain-of-Thought reasoning#372
Open
abhinavk0220 wants to merge 5 commits intomesa:mainfrom
Open
add: LLM Epidemic (SIR) model using Chain-of-Thought reasoning#372abhinavk0220 wants to merge 5 commits intomesa:mainfrom
abhinavk0220 wants to merge 5 commits intomesa:mainfrom
Conversation
…classic SIR epidemic simulation where agents use LLMChain-of-Thought reasoning to decide their behavior during anoutbreak, instead of fixed stochastic transition probabilities.Agents choose between:- isolate: stay home, reduce infection risk- move_freely: normal activity, higher transmission risk- seek_treatment: if infected, accelerate recoveryThe model demonstrates how LLM-driven behavioral reasoningproduces emergent epidemic curves that reflect nuanced humandecision-making during crises, contrasting with classicalfixed-rule SIR dynamics.Includes .env.example for API key configuration (supportsGemini, OpenAI, Anthropic, and Ollama).Visualization includes spatial grid (color-coded by healthstate) and real-time SIR plot tracking population counts.Reference: Kermack & McKendrick (1927)
for more information, see https://pre-commit.ci
…220/mesa-examples into add/llm-epidemic-model
for more information, see https://pre-commit.ci
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.
Summary
Adds a classic SIR (Susceptible-Infected-Recovered) epidemic simulation
where agents use LLM Chain-of-Thought reasoning to decide their
behavior during an outbreak, instead of fixed stochastic transition
probabilities.
How this differs from similar epidemic models (e.g. #359)
PR #359 adds a deterministic pathogen model with fixed quarantine
and compliance rules agents follow predefined behavioral rules
based on parameters.
This model takes a fundamentally different approach: agents have
no fixed rules. Instead they use LLM Chain-of-Thought reasoning
to decide whether to isolate, move freely, or seek treatment at
each step based on what they observe around them.
The distinction matters because:
that fixed parameters cannot capture
Both approaches are valid — they answer different research questions.
What makes this different from a classical SIR model
In a standard SIR model, infection and recovery are governed by fixed
probabilities (β and γ). Here, agents reason about their situation
at each step observing neighbor health states, weighing personal risk
against community responsibility and choose an action:
isolate: Stay home, reduce infection risk, slower social lifemove_freely: Normal activity, higher transmission riskseek_treatment: If infected, accelerate recoveryThis produces epidemic curves shaped by emergent behavioral responses
rather than fixed parameters, demonstrating how LLM-powered agents can
model nuanced human decision-making during crises.
Visualization
How to Run
cp .env.example .env # fill in your API key pip install -r requirements.txt solara run app.pySupported LLM Providers
Gemini, OpenAI, Anthropic, Ollama (local) configured via
.env.A
.env.exampleis included for easy setup.Reference
Kermack, W. O., & McKendrick, A. G. (1927). A contribution to the
mathematical theory of epidemics. Proceedings of the Royal Society
of London. Series A, 115(772), 700–721.