Added recovery_rate parameter to Rumor Mill model
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:Persongainsrecovery_rateand ajust_recoveredflag;step()checks for forgetting (probabilityrecovery_rate) before attempting to tell a neighborrumor_mill/model.py:RumorMillModelacceptsrecovery_rate(default0.0, so existing callers see no behavior change), threads it to every agent, and adds aPercentage_Recovered_This_Stepreporterapp.py: newrecovery_rateslider (interactive demo defaults it to0.05)README.md: documents the parameter and the extinction/equilibrium/saturation regimestests.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.
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.