-
Notifications
You must be signed in to change notification settings - Fork 929
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
model.get_agents_of_type() still contains agents that have been removed both from the grid and the scheduler #2019
Comments
I am not familiar with the inner details of Sugarscape. So, I don't fully understand what is happening. Both the code you linked to and the shown code take a set of agents and shuffle them. Neither calls another method. The key difference is that the current code takes the agents from the scheduler, while the new code takes the agents from the model.
|
I'd say, |
The other alternative that I didn't say, but would make sense given the trade off, is to sacrifice the feature of having multiple schedulers by doing |
I am not sure whether I agree with this. I think conceptually it is fine to say |
I am also not sure what exactly the problem is here, but from the title I don't see how this wouldn't be expected behavior. Why should agents be removed from model.agents if they are removed from schedule and grid? This just represents passive agents, so there is even a use case for this behavior. Think of a board game where playing pieces are taken of the board, but might reappear later. The inverse could be expected: Removing an agent from model.agents should also remove it from the scheduler and the grid. So in the example above, taken completely out of the game. And I think thats also the intention of using weakrefs. |
Exactly. The reason for using weakrefs in AgentSet was to make it easy to remove agents from everywhere by just calling And, of course, we are discovering various performance drawbacks of weakrefs, which we then try to work around to maintain performance. |
Once again,
Please see it from the user perspective. It may be obvious to Mesa developers because you implemented the feature and the cause of the examples tests failing had been debugged during #1942. But the user who using the new method |
I agree with you on this point which is why we need to carefully check the documentation to make clear what the behavior is of these different forms of removing agents. |
Now we have updated to direct acces to an |
Describe the bug
I was trying to replace the lines in the Sugarscape G1MT example https://github.com/projectmesa/mesa-examples/blob/34e92d2c29a99e950bc17f7cac860c5b13156b21/examples/sugarscape_g1mt/sugarscape_g1mt/model.py#L146-L149
with
This failed the tests, because when an agent dies, it only removes itself from the grid and the scheduler.
Expected behavior
The users would expect the 2 methods to give the same outcome, but will be tripped by the new requirement of
agent.remove()
.The text was updated successfully, but these errors were encountered: