mesa icon indicating copy to clipboard operation
mesa copied to clipboard

[ENH] Support overlapping hierarchies by allowing agents to belong to multiple MetaAgents

Open Nithurshen opened this issue 11 months ago • 4 comments

What's the problem this feature will solve?

Currently, the MetaAgent implementation uses a single reference: agent.meta_agent = self. This creates a 1-to-1 relationship between a constituent agent and its meta-agent. The current implementation overwrites previous meta-agent references, making overlapping hierarchies impossible to model.

Describe the solution you'd like

I would like to transition agent.meta_agent from a single object reference to a set.

  1. In MetaAgent.__init__ and add_constituting_agents, the logic should append the meta agent to this set.
  2. The remove_constituting_agents method should use discard on the set.
  3. This ensures that an agent can be tracked by multiple higher-level entities without losing references.

Additional context

This addresses the # TODO: Make a set for meta_agents found in mesa/meta.py.

Nithurshen avatar Dec 26 '25 03:12 Nithurshen

@EwoutH @quaquel I would like to work on this. Am I good to go?

Nithurshen avatar Dec 26 '25 03:12 Nithurshen

@tpike3 is the designer of meta agents.

EwoutH avatar Dec 26 '25 06:12 EwoutH

@EwoutH, we will wait for their say on this.

Nithurshen avatar Dec 26 '25 06:12 Nithurshen

Hi — I’ve been looking into MetaAgent and the TODO in mesa/meta.py.

Supporting overlapping hierarchies via agent.meta_agents: set makes sense conceptually. Before starting, I just want to confirm whether there are any existing assumptions in activation/scheduling that rely on a strict 1-to-1 relationship.

If the intended direction is to allow true multi-membership, I’d be happy to take this on and include tests to ensure no regressions.

sakshi-thigale avatar Mar 01 '26 18:03 sakshi-thigale