-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scheduler keeps track of agents in dict #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@csmaxwell if you run this line in your dev environment, it will provide you a list of all the pep8 issues, so you don't have to wait on travis to be mean. :-)
Let us know when this is read for review. |
|
@jackiekazil Thanks for the tip on flake8! I think it's ready for review. Also, thanks for giving me the heads up on possible review delays. They won't affect my research or deadlines, so no worries from my end. |
|
(I commented initially on the issue but I think this is probably a better place)
I think this raises interesting questions, though: why do Agents have unique_id at all? As far as I can tell, it's only currently used for logging. Is it useful to be able to specify the id, or should that be managed for the user? |
|
I am going to try to do a review of this over the weekend. |
|
(sorry for the delay of my chime in... I have one more component to my Ph.D exam that wraps up today --- I will catch up after that.) |
|
Maybe I am missing something here and if so I apologize in advance, but in order to avoid iteration over a list that is being modified, wouldn't it suffice to iterate over a COPY of the agents list in the schedule step method, instead of the original ? Something like this I don't expect any significant overhead from the copy operation The dict implementation could still be a better idea ( I have to check performance-wise), but the impact of iterating over a copy would be minimum and I think it could fix the bug |
|
In any case, even if there was no bug in the list implementation, I think dicts would be a better approach. Removing an agent from a list would be at least an order of magnitude slower than from a dict. Therefore, for models with some few thousand limited life-span agents , dicts would really make a difference |
|
Memory consumption is reduced in the dict version, since the list version loops |
|
I have a local branch which uses @csmaxwell's PR. To speed up the process of this being merged, if it is okay, I have re-organized the commits + cleaned + reworded + rebased. |
|
This was refactored into #386 |
@jackiekazil
Hello! I think this would resolve #302 . I've changed the scheduler to handle a dict rather than a list. I added a
next_id()method to Model to dispenseunique_ids for agents. I've made WolfSheep and the tests compatible with the change, and added a test for whether the lifespan of agents with a finite life is what they should be. I haven't messed with the docs or other examples, but I could work on that if y'all'd like.Since this is my first pull request, please let me know if I've messed anything up!
best,
Colin