Skip to content

fix(examples): use citizen_vision for Citizen agents in Epstein Civil… - #4141

Merged
quaquel merged 2 commits into
mesa:mainfrom
pojeesahil:fix-epstein-citizen-vision
Nov 20, 2026
Merged

quaquel merged 2 commits into
mesa:mainfrom
pojeesahil:fix-epstein-citizen-vision

Conversation

@pojeesahil

Copy link
Copy Markdown
Contributor

Pre-PR Checklist

  • This PR is a bug fix, not a new feature or enhancement.

Summary

In the Epstein Civil Violence example (mesa/examples/advanced/epstein_civil_violence), Citizen agents ignore the citizen_vision parameter and the Citizen Vision slider in the UI, and always use cop_vision instead.

Bug / Issue

In mesa/examples/advanced/epstein_civil_violence/agents.py, EpsteinAgent.update_neighbors() hardcoded radius=self.scenario.cop_vision (introduced in #3167). Because Citizen inherits update_neighbors() directly from EpsteinAgent, self.scenario.citizen_vision was never read anywhere in the model.

Implementation

Added a vision property to EpsteinAgent (implemented on Citizen to return self.scenario.citizen_vision and on Cop to return self.scenario.cop_vision), and updated EpsteinAgent.update_neighbors() to pass radius=self.vision.

Testing

  • Ran pytest tests/examples/test_examples.py -k epstein and ruff check / ruff format --check all passed.
  • Compared citizen_vision=1 vs. citizen_vision=10 (with cop_vision=7, rng=42, 20 steps):
    • Before the fix: both runs produced identical results.
    • After the fix: citizen_vision=1 resulted in 580 arrested vs. 27 arrested for citizen_vision=10.

@github-actions github-actions Bot added ci Release notes label example Changes the examples or adds to them. labels Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -4.3% [-4.8%, -3.8%] 🔵 -0.1% [-0.3%, +0.1%]
BoltzmannWealth large 🔵 -1.5% [-1.7%, -1.2%] 🟢 -6.4% [-7.2%, -5.6%]
Schelling small 🔵 -2.0% [-2.5%, -1.6%] 🔵 -1.5% [-2.1%, -0.8%]
Schelling large 🔵 -1.8% [-2.2%, -1.3%] 🟢 -4.9% [-5.4%, -4.4%]
WolfSheep small 🔵 -1.1% [-1.4%, -0.7%] 🔵 -1.3% [-3.3%, +0.7%]
WolfSheep large 🔵 -2.1% [-2.7%, -1.4%] 🔵 -2.3% [-3.1%, -1.4%]
SugarscapeG1mt small 🔵 -2.1% [-3.0%, -1.1%] 🔵 -1.4% [-2.8%, +0.0%]
SugarscapeG1mt large 🔵 +0.4% [-1.2%, +1.9%] 🔵 +0.3% [-1.4%, +2.3%]
BoidFlockers small 🔵 -2.0% [-2.7%, -1.3%] 🔵 +0.1% [-0.4%, +0.5%]
BoidFlockers large 🔵 +0.2% [-0.5%, +0.9%] 🔵 -0.0% [-0.8%, +0.5%]
MultiLevelAllianceModel small 🔵 -0.3% [-2.5%, +2.2%] 🔵 -1.5% [-1.9%, -1.1%]
MultiLevelAllianceModel large 🔵 -2.0% [-3.3%, -0.7%] 🟢 -3.6% [-4.3%, -3.2%]

@quaquel
quaquel merged commit b593bee into mesa:main Nov 20, 2026
17 checks passed
EwoutH pushed a commit to EwoutH/mesa that referenced this pull request Nov 22, 2026
mesa#4141)

* fix(examples): use citizen_vision for Citizen agents in Epstein Civil Violence

* refactor(examples): declare vision as type annotation on EpsteinAgent

(cherry picked from commit b593bee)
EwoutH added a commit to EwoutH/mesa that referenced this pull request Nov 22, 2026
Add mesa#3913, mesa#4061, mesa#4072, mesa#4105, mesa#4126, mesa#4136, mesa#4141, mesa#4157, mesa#4161 and the Starlette 1.x support backported from mesa#4007, and move the release date to 2026-11-22.

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Release notes label example Changes the examples or adds to them.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants