-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support for Multi-Level and Overlapping Meta-Agents #3171
Copy link
Copy link
Closed
Description
Description
The current experimental MetaAgent implementation is limited to a single-parent hierarchy. When an agent joins a meta-agent, the relationship is stored as a scalar reference (agent.meta_agent = self), meaning an agent cannot belong to multiple groups at once (e.g., a person belonging to both a "Household" and a "Workplace").
Furthermore, the existing implementation includes redundant calls to model.register_agent and model.deregister_agent within MetaAgent methods. Since agents in Mesa are automatically registered with the model upon instantiation, these extra calls lead to KeyError crashes when an agent attempts to leave a group or join multiple overlapping hierarchies.
Proposed Solution
- Transition to Set-Based Membership: Refactor the relationship from
agent.meta_agentto a set calledagent.meta_agents. This allows for truly overlapping and multi-level simulation architectures. - Backward Compatibility: Maintain
agent.meta_agentas a property or dynamic attribute that updates based on the contents of themeta_agentsset to avoid breaking existing prototypes. - Refine Group Creation: Update the
create_meta_agenthelper to only merge agents into existing groups if the class name matches the requested type. This enables the creation of independent, overlapping organizational structures. - Fix Registration Lifecycle: Remove redundant model registration/deregistration calls from its lifecycle to ensure stability across group membership changes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels