feat: add LLM Schelling Segregation example using mesa-llm#363
Open
abhinavk0220 wants to merge 2 commits intomesa:mainfrom
Open
feat: add LLM Schelling Segregation example using mesa-llm#363abhinavk0220 wants to merge 2 commits intomesa:mainfrom
abhinavk0220 wants to merge 2 commits intomesa:mainfrom
Conversation
…Schelling's (1971) classic segregation model using LLM agentsinstead of a fixed tolerance threshold.Each agent reasons in natural language about its neighborhood compositionand decides whether to stay ('happy') or relocate ('unhappy'). Thisproduces richer segregation dynamics than the classical threshold rule.Includes:- SchellingAgent extending LLMAgent with CoT reasoning- LLMSchellingModel on OrthogonalMooreGrid with torus=True- Segregation index metric tracked over time- SolaraViz with grid plot, happiness chart, and segregation index- README with comparison table vs classical Schelling modelReference: Schelling, T.C. (1971). Dynamic models of segregation.Journal of Mathematical Sociology, 1(2), 143-186.Related: mesa/mesa-llm#153
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
Implements Schelling's (1971) classic segregation model using LLM agents
instead of a fixed tolerance threshold.
Motivation
The classical Schelling model is the most cited ABM paper ever — but its
decision rule is a hard mathematical threshold. This example shows what
changes when agents reason in natural language about their neighborhood:
the same emergent segregation appears, but driven by genuine reasoning
rather than a fixed number.
This directly fulfills the GSoC 2026 goal of "examples sourced from
scientific papers with comparison to non-LLM agents."
What's included
agent.py—SchellingAgentextendingLLMAgentwith CoT reasoningmodel.py—LLMSchellingModelonOrthogonalMooreGridwith segregation index metricapp.py— SolaraViz with grid plot, happiness chart, and segregation index over timeREADME.md— explanation with comparison table vs classical SchellingReference
Schelling, T.C. (1971). Dynamic models of segregation.
Journal of Mathematical Sociology, 1(2), 143–186.
Related