-
Notifications
You must be signed in to change notification settings - Fork 0
Description
User Story
As a developer, I want to log network rewiring and homophily actions at both the agent and model levels so that I can analyze how frequently agents adapt their social connections and how these dynamics affect collective stress and resilience patterns.
Description
The current model does not track how often agents perform network rewiring (_rewire_to_similar_agent()) or network homophily adaptation (_adapt_network()). These mechanisms play a crucial role in social structure evolution and should be logged systematically for both individual agents and the overall model. The logs should integrate seamlessly into the existing Mesa DataCollector in src/python/model.py, allowing access to both per-agent and aggregate metrics.
Proposed Flow
-
Update
src/python/agent.py:- In the
Personclass:- Add counters for rewiring and homophily actions:
self.rewire_count = 0 self.homophily_count = 0
- Increment
rewire_countinside_rewire_to_similar_agent() - Increment
homophily_countinside_adapt_network()
- Add counters for rewiring and homophily actions:
- Optionally reset or aggregate counts per simulation step depending on analysis needs
- In the
-
Update
src/python/model.py:- Extend Mesa
DataCollectorconfiguration to include:agent_reporters={ "RewireCount": "rewire_count", "HomophilyCount": "homophily_count", ... }, model_reporters={ "TotalRewires": lambda m: sum(a.rewire_count for a in m.schedule.agents), "TotalHomophily": lambda m: sum(a.homophily_count for a in m.schedule.agents), "MeanRewires": lambda m: np.mean([a.rewire_count for a in m.schedule.agents]), "MeanHomophily": lambda m: np.mean([a.homophily_count for a in m.schedule.agents]), ... }
- Ensure the data collector collects this information every simulation step
- Extend Mesa
-
Testing:
- Verify that
rewire_countandhomophily_countincrease when corresponding methods are called - Confirm data collector captures these values at both agent and model levels
- Check consistency of aggregation in model reporters (sum/mean values)
- Verify that
Reference
src/python/agent.py→_rewire_to_similar_agent()and_adapt_network()methods inPersonclasssrc/python/model.py→ MesaDataCollectorconfiguration
Notes:
- Keep logging lightweight to avoid simulation slowdowns.
- Consider resetting per-day counters if daily aggregation is desired.
- Ensure compatibility with existing data collection pipeline and output formats.
- This enhancement enables quantitative analysis of network evolution in response to affect and stress dynamics.