Closed sivogel closed 6 days ago
I think my problem is similar to the closed issue #361, but somehow different. In my case I found a solution but it is a runtime problem to loop over all agents.
currently there are 3 options by which you can activate a model -- illustrations of those can be found here: https://github.com/projectmesa/mesa/blob/master/examples/pd_grid/analysis.ipynb
The way that you activate can effect your results, so it important that you take that into consideration.
RE: Speed -- there are a few folks that are talking about optimizing various components, but there are few issues around this. If you could submit your model to an issue and let us know what settings that you trying to run against it, which causes the slowness it would help us bench and improve upon this for future users.
I will leave this ticket open for a few days just in case someone else wants to chime in on it.
My current issue is that it takes too much time to remove the agents from the scheduler, because the look-up in the list takes too long (I have a lot of agents which are added and removed all the time). I will share the model with you when I fixed some other bugs. Thanks a lot!
Another path too, is to take one of the example models and put a similar number of agents in it and see if it creates the same problem. Then we can use that as an example.
For now, I am closing this ticket.
But feel free to come back with more details and reopen!
Our mesa plant model was previously set up in Netlogo. There it had 800x800 cells and is initialized with 50% plant agents, each agent produces in mean 10 seed agents each year. The seeds die in average after 10 years and the model runs for 100 years. Plants also have other reasons for death, which reduces the amount of agents over time but at least at the beginning this means a huge amount of seed agents:
800x800 cells x0.5 initial density x10 seeds/plant x10years x1/4 (~plants die due to other reasons) = ~ 8 mio agents.
Our model in mesa already gets very slow with a 80x80 cells (~80,000 agents). Far slower than the Netlogo version with same size. While profiling our model we found out that the bottleneck is the removal of the seed agents from the schedule, because the lookup for the right agent in the list takes very long.
If it helps to improve, I can send you the current version of the model, but we did some modifications on the mesa code (our continuous grid is only pseudo continuous as in your previous mesa version, leading to some follow-up changes).
Hope we can get faster!
@sivogel I would love to see your code. I would also love to see the changes you made to Mesa. Maybe they are things that other users can benefit from as well. Can you share both? And can you let me know what you changed in Mesa (so I don't have to hunt it down).
Dear Jackie Kazil,
great that you want to have a look at it! We added you as contributer
to our github-folder called plamo. In there you will find a src
folder. All settings are done in the plamo.cfg file (in order to
change the resolution change x_max and y_max of the grid properties.
To run the model you have to execute SV_plant_model.py
In the current version there are only few changes to the original mesa
code, but we used an old version where ContinuousSpace is not really
continuous yet. I think the main difference to the original code is
that we changed the default grid width and Grid properties are passed
to the ContinuousSpace class.
Feel free to ask questions,
Simone
Quoting Jackie Kazil notifications@github.com:
@sivogel I would love to see your code. I would also love to see the
changes you made to Mesa. Maybe they are things that other users can
benefit from as well. Can you share both? And can you let me know
what you changed in Mesa (so I don't have to hunt it down).-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/projectmesa/mesa/issues/536#issuecomment-397858702
Dear Jackie Kazil,
have you had a look at our model? I compared our mesa version to the
new one and found out that you changed the list in the BaseScheduler
to a OrderedDictionary. Maybe this is already the speedup we need.
Thank you,
Simone Vogel
Quoting Jackie Kazil notifications@github.com:
@sivogel I would love to see your code. I would also love to see the
changes you made to Mesa. Maybe they are things that other users can
benefit from as well. Can you share both? And can you let me know
what you changed in Mesa (so I don't have to hunt it down).-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/projectmesa/mesa/issues/536#issuecomment-397858702
@sivogel there has been several performance improvements to Mesa's space and time module, and there is now RandomActivationByType
scheduler. With RandomActivationByType
, it uses a dictionary with the agent type as a key, so you don't have to loop through the entire list every time. Is your model publicly accessible?
This has become absolete with the removal of schedulers in mesa 3.
Dear all,
I currently try to rewrite a NetLogo model with Mesa in Python. So far it works quite well but I have issues with the runtime. My Setup: I have to types of agents (seeds and plants). Now I want first to run through all seeds than to runs through all plants and within I want to do some changes on the grid. My current solution: At the moment I do this by StagedActivation, but this means I always have to loop over all agents, which takes a lot of time. My question: Is there any option I overlooked to have several different steps or a stages which do not loop over all agents but only over an agent group?
Thanks for help,
Simone