mesa-examples icon indicating copy to clipboard operation
mesa-examples copied to clipboard

Added recovery_rate parameter to Rumor Mill model

Open dietcoke-17 opened this issue 4 months ago • 1 comments

Summary

Added a recovery_rate parameter to the Rumor Mill example, letting informed agents forget the rumor and become uninformed again. Closes #472

The model was purely monotonic -- Percentage_Knowing_Rumor could only trend upward, so the only observable outcome was "how fast does it saturate." Recovery/forgetting is a standard ingredient in rumor- and epidemic-spread models (the "R" side of SIR/SIS dynamics), and adding it unlocks three qualitatively different regimes:

  • Extinction -- recovery outpaces spread, the rumor dies out
  • Equilibrium -- spread and recovery balance, producing a fluctuating steady state
  • Saturation -- spread outpaces recovery, near-total adoption

Related to #436 (a separate rumor-spread example that already modeled recovery) and #451 (which proposes a forgetting mechanic plus additional agent types for this same model) -- flagging both for reviewers since there's conceptual overlap. This PR is intentionally scoped to just the recovery-rate piece to keep it small and easy to review.

Changes

  • rumor_mill/agent.py: Person gains recovery_rate and a just_recovered flag; step() checks for forgetting (probability recovery_rate) before attempting to tell a neighbor
  • rumor_mill/model.py: RumorMillModel accepts recovery_rate (default 0.0, so existing callers see no behavior change), threads it to every agent, and adds a Percentage_Recovered_This_Step reporter
  • app.py: new recovery_rate slider (interactive demo defaults it to 0.05)
  • README.md: documents the parameter and the extinction/equilibrium/saturation regimes
  • tests.py: new tests for backward compatibility, the deterministic full-recovery edge case, parameter wiring, and the new reporter

Design Note

Forgetting is implemented as SIS-style: an agent that forgets becomes fully susceptible again and can be told and re-adopt the rumor later, rather than SIR-style permanent immunity. That matches how #436 described its own recovery mechanic. Happy to switch if maintainers prefer immunity instead.

dietcoke-17 avatar Jul 28 '26 21:07 dietcoke-17

Two issues surfaced during review of the recovery_rate addition:

  • New_People_Knowing_Rumor was inflated whenever an agent forgot the rumor and was later re-told it, since newly_learned fired on every adoption rather than just the first. Fixed by adding a permanent has_known_rumor_before flag and only setting newly_learned the first time an agent ever adopts the rumor.
  • Stepping an informed agent with an empty neighborhood (e.g. a 1x1 grid) raised UnboundLocalError, because the times_heard counter updates sat outside the if neighbors: block instead of nested inside it. (FROM SELF REVIEW) -Also added test recovered agents are not double counted as new and test no crash with empty neighborhood to cover both.

dietcoke-17 avatar Jul 30 '26 05:07 dietcoke-17