Killing agents but they slow down the run, maybe?

29 views
Skip to first unread message

Andreas Pape

unread,
Sep 30, 2020, 8:12:13 PM9/30/20
to proje...@googlegroups.com
Hi mesaheads. I have a model which visually implements a genetic algorithm, with different agents being different genes. I kill them off and replace them. But the model slows down a lot as the generations proceed, which shouldn’t be the case (I think) unless the “dead” agents are hanging around in memory. I remove the agents from the schedule and I remove them from any other place, like the grid and my list of agents self.agents. Is there a way to get python/mesa to delete them from memory? Like force “garbage collection” or whatever?

Has anyone else encountered this?

I can also post code but it’s a lot of code.

Thanks!

—Andreas

Economics, Binghamton University


Message has been deleted

Corvince

unread,
Oct 3, 2020, 6:20:35 AM10/3/20
to ProjectMesa
Hmm, without code it is a lot of guessworking, but: Yes in order to delete an object (well, at least to allow deletion of an object) you have to remove all references. Another possibility would be if you collect some data about your agents and it is just the datacollector that increases in size!?
Would be best if you could share some code (e.g. as a github gist)

Andreas D Pape

unread,
Oct 6, 2020, 1:08:21 PM10/6/20
to ProjectMesa
Hello. I just wanted to share the solution. It was, in fact, data collection; and it wasn't just the self.datacollector.collect() statement, but the instantiation of the datacollector object in the first place. Presumably it retains references to agents after I remove them from the schedule? In any case, once I removed that, there was absolutely no slowdown.

Thanks everyone.

Jacqueline Kazil

unread,
Oct 6, 2020, 1:49:21 PM10/6/20
to Andreas D Pape, ProjectMesa
Thank you sharing!

--
Project repos: github.com/projectmesa
---
You received this message because you are subscribed to the Google Groups "ProjectMesa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectmesa...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectmesa/50210eec-e019-452c-a019-21a1b160c583n%40googlegroups.com.
--
Jacqueline Kazil | @jackiekazil 

Reply all
Reply to author
Forward
0 new messages