Skip to content

Removing all agents in the model #2393

@quaquel

Description

@quaquel

I am currently updating my teaching materials to MESA 3. One of my assignments is an evolutionary version of Axelrod's emergence of collaboration. However, this requires removing the entire population of agents at each tick, and creating the next generation. (I know it can also be implemented differently...). At the moment, there is no convenience method for removing all agents from the model. Since model.agents returns a weakref agentset, doing operations on this won't work. It seems we need a model level method like model.clear_agents(), which would call agent.remove on each agent. It needs to run through agent.remove rather than just rebuild the model._agents datastructures to ensure that agents are also removed from the experimental cell spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions