Skip to content

Removing all agents in the model #2393

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
quaquel opened this issue Oct 21, 2024 · 0 comments · Fixed by #2394
Closed

Removing all agents in the model #2393

quaquel opened this issue Oct 21, 2024 · 0 comments · Fixed by #2394

Comments

@quaquel
Copy link
Member

quaquel commented Oct 21, 2024

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant