-
Notifications
You must be signed in to change notification settings - Fork 928
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
replace model with random in AgentSet init #2350
Conversation
for more information, see https://pre-commit.ci
Performance benchmarks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this change. Thanks especially for the extensive motivation, that’s really appreciated.
Another argument against this change is that we might potentially expand in the future AgentSet to use other model attributes.
This was the first thing I was thinking about. However, the AgentSet has been with us since 2.2, is very actively integrated and developed and so far we never needed it. So a few months back I might give this argument a lot of weight, but now I think we will perfectly manage without it.
Since this is technically a breaking change, I would like a second maintainer to approve, but from my perspective, good to go!
Having access to the model everywhere is arguably also coherent and easy to use. So it could go either way.
It's because the use cases (the "experimental evidences") are limited to the existing mesa-examples, and we haven't received feedback from advanced users yet. This is in contrast to the datacollector where we received lots of requests for multi-agent data collection. But I'm fine with this PR. It can always be changed back in the future when needed. The added bonus with this PR is that I have observed that AgentSet's utility may extend beyond ABM, as an arbitrary object DataFrame, and so tying it to an ABM model might actually be limiting it. |
Apparently this broke our docs build: https://readthedocs.org/projects/mesa/builds/25927550/ |
@quaquel could you check what's going wrong in the tutorial? |
The tutorial is still using a scheduler, so the tutorial needs a bigger overhaul. I have no idea what causes the error and I can't seem to replicate it locally. |
Okay, @tpike3 is working on a tutorial update, let's first wait if he already has fixed the issue (feel free to open a draft PR with your current progress, Tom). |
should I split the fix in time.py into a seperate PR then? |
As pionted out in by @EwoutH, #2350 broke the tutorial. This is due to not updating the schedulers to pass model.random. This fixes that bug (and does a few minor updates to the tutorial). The tutorial needs a complete update to remove schedulers and use (in my view) the new grid spaces. I am not going to do that in this PR.
This PR replaces the model argument in
AgentSet.__init__
withrandom
as a keyword argument as argued in #2323.Motivation:
model
serves no other function and there is no other use case for having model in the agentset.CellCollection.agents
to returning an agentset because CellCollection does not have a reference to model even though it does have access to its random number generator.Some have argued that this change creates extra load on the user. I disagree. First, In none of the examples in mesa-examples is the user creating an AgentSet object themselves. This highlights that it will be rare for users to create AgentSet themselves directly in all but the most advanced use cases. It also implies that this change is almost excusively confined to the inner workings of mesa. Second, this API is identical to the new gridspaces were we pass random explicitly instead of passing model only to get access to the central random number generator. So, this PR in fact makes the code base internally more coherent and therefore easier to use.
Another argument against this change is that we might potentially expand in the future AgentSet to use other model attributes. Again, I am not convinced by this unless clear examples of useful AgentSet functionality are given that require access to Model. We have had AgentSet for almost a year. No example has come up, I cannot come up with a convincing example, and None have not been offered.