Skip to content
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

Have a dedicated neighborhood property and a get_neighborhood method on Cell #2309

Merged
merged 10 commits into from
Sep 21, 2024

Conversation

quaquel
Copy link
Member

@quaquel quaquel commented Sep 21, 2024

This picks up on a discussion in #2296. In the current code, we have method named Cell.neighborhood. This is an unfortunate name. So we agreed to split this into a property for the direct neighborhood (i.e. radius = 1) and a get_neighborhood method for larger radii. We had a bit of discussion on the names, but I decided to keep it simple: neighborhood and get_neighborhood. I have updated the docstrings to clearly explain when to use which one.

Copy link
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general design!

Any performance implication on caching? Mostly good probably, right?

mesa/experimental/cell_space/cell.py Outdated Show resolved Hide resolved
@quaquel
Copy link
Member Author

quaquel commented Sep 21, 2024

just a quick observation about cellspaces. A random walk is now a one liner: self.cell.neighborhood.select_random_cell().

@EwoutH
Copy link
Member

EwoutH commented Sep 21, 2024

That’s really nice!

I would appreciate a deprecationwarning for neighborhood()

mesa/experimental/cell_space/cell.py Outdated Show resolved Hide resolved
@quaquel
Copy link
Member Author

quaquel commented Sep 21, 2024

I would appreciate a deprecationwarning for neighborhood()

AFAIK that is not possible because the name clashes with the property.

@EwoutH
Copy link
Member

EwoutH commented Sep 21, 2024

It looks like this does introduce some errors.

@quaquel quaquel added the trigger-benchmarks Special label that triggers the benchmarking CI label Sep 21, 2024
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -15.6% [-16.6%, -14.7%] 🟢 -19.6% [-19.7%, -19.5%]
BoltzmannWealth large 🟢 -22.9% [-23.1%, -22.7%] 🟢 -17.7% [-18.3%, -17.1%]
Schelling small 🔴 +11.3% [+11.0%, +11.7%] 🔵 +1.7% [+1.5%, +1.8%]
Schelling large 🔴 +11.6% [+11.1%, +12.1%] 🔵 +0.4% [-1.0%, +1.7%]
WolfSheep small 🔵 +1.4% [+1.2%, +1.6%] 🔵 +2.2% [+2.0%, +2.5%]
WolfSheep large 🔵 +1.9% [+1.7%, +2.1%] 🔵 +1.4% [+1.0%, +1.8%]
BoidFlockers small 🔴 +10.6% [+9.9%, +11.2%] 🔵 -0.7% [-1.5%, -0.1%]
BoidFlockers large 🔴 +10.1% [+9.6%, +10.6%] 🔵 +0.4% [-0.4%, +1.0%]

@EwoutH
Copy link
Member

EwoutH commented Sep 21, 2024

These benchmark results are exactly opposite of #2308.

So seems to cancel out and are just based on an outdated branch or whatever.

@EwoutH EwoutH added breaking Release notes label and removed trigger-benchmarks Special label that triggers the benchmarking CI labels Sep 21, 2024
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -20.5% [-21.6%, -19.4%] 🟢 -19.2% [-19.3%, -19.1%]
BoltzmannWealth large 🟢 -22.8% [-23.0%, -22.5%] 🟢 -18.1% [-18.9%, -17.4%]
Schelling small 🔴 +10.6% [+10.2%, +11.1%] 🔵 +1.7% [+1.5%, +1.9%]
Schelling large 🔴 +12.2% [+11.6%, +12.8%] 🔴 +8.6% [+6.3%, +10.6%]
WolfSheep small 🔵 +0.4% [+0.3%, +0.6%] 🔵 +1.0% [+0.7%, +1.2%]
WolfSheep large 🔵 +1.7% [+0.7%, +2.8%] 🔴 +5.5% [+3.3%, +7.5%]
BoidFlockers small 🔴 +12.7% [+12.2%, +13.3%] 🔵 +0.9% [+0.2%, +1.5%]
BoidFlockers large 🔴 +12.0% [+11.7%, +12.4%] 🔵 +0.4% [+0.1%, +0.8%]

Copy link
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was starting to type something about API compatibility and deprecation warnings, but then remembered this is all in the experimental space.

Love the experimental space!

@EwoutH EwoutH added experimental Release notes label and removed breaking Release notes label labels Sep 21, 2024
@quaquel quaquel merged commit 1ad2e1f into projectmesa:main Sep 21, 2024
10 of 12 checks passed
EwoutH added a commit that referenced this pull request Sep 21, 2024
@EwoutH
Copy link
Member

EwoutH commented Sep 21, 2024

Thanks, great to have it in!

Please make sure that pre-commit passes before merging. Always a bitch to clean up (done in 7037a32).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Release notes label experimental Release notes label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants