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

examples/wolf_sheep: Don't allow dumb moves #2503

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Nov 13, 2024

Agents now move completely random in WolfSheep. That makes no sense whatsoever, so this PR makes them move a little bit less dumb.

  • Wolf moves to random cell with sheep on them, if available (otherwise completely random)
  • Sheep move to a random cell without a wolf (if available), and preferably with grass.

This enables sheep to actually "search" for grass, wolfs to search for sheep and sheep to not move to a cell with wolves.

More importantly, it shows of some nice selection mechanics with the cell space.

I expect the WolfSheep model to be slower, but curious by how much.

Depends on #2502.

Edit: Dynamics are quite interesting, I had this epic run where one single sheep survived endlessly until all the wolves where finally dead.

image

@EwoutH EwoutH added the example Changes the examples or adds to them. label Nov 13, 2024
Agents now move completely random in WolfSheep. That makes no sense whatsoever, so this PR makes them move a little bit less dump.

- Wolf moves to random cell with sheep on them, if available (otherwise completely random)
- Sheep move to a random cell without a wolf (if available), and preferably with grass.

This enables sheep to actually "search" for grass, wolfs to search for sheep and sheep to not move to a cell with wolves.

More importantly, it shows of some nice selection mechanics with the cell space.
@EwoutH EwoutH added trigger-benchmarks Special label that triggers the benchmarking CI and removed trigger-benchmarks Special label that triggers the benchmarking CI labels Nov 13, 2024
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -5.5% [-7.0%, -3.9%] 🔵 -1.3% [-1.5%, -1.1%]
BoltzmannWealth large 🔵 -1.7% [-2.4%, -0.9%] 🟢 -7.8% [-8.8%, -7.1%]
Schelling small 🔵 -1.3% [-1.5%, -1.0%] 🔵 -1.0% [-1.3%, -0.8%]
Schelling large 🔵 -0.9% [-1.6%, -0.1%] 🔵 -3.1% [-4.3%, -1.8%]
WolfSheep small 🔵 -1.5% [-1.9%, -1.1%] 🔴 +82.2% [+74.6%, +89.0%]
WolfSheep large 🔵 -1.6% [-2.2%, -0.9%] 🔴 +104.6% [+101.7%, +108.4%]
BoidFlockers small 🔵 +0.2% [-0.2%, +0.7%] 🔵 +2.2% [+1.2%, +3.4%]
BoidFlockers large 🔵 -0.1% [-0.7%, +0.4%] 🔵 +1.8% [+1.3%, +2.4%]

@EwoutH
Copy link
Member Author

EwoutH commented Nov 13, 2024

Double the runtime is quite an increase. But that's good, that means we now have a meaningful step which can be profiled and optimized.

@Corvince
Copy link
Contributor

Oof, yes that's quite an increase and invites to further investigate! And this seems to be a way more interesting model dynamic

@quaquel
Copy link
Member

quaquel commented Nov 14, 2024

I have an overarching question. This model is used in the ABM Framework comparison. We, therefore, use it in our own internal benchmarks. Clearly, with the examples back in the main repo, we should not duplicate code between benchmarks and examples. This change, however, breaks the link with the ABM Framework comparison, so do we want that, and what does this imply for our own benchmark models?

Oof, yes that's quite an increase and invites to further investigate! And this seems to be a way more interesting model dynamic

It highlights a point we both have made before, no matter how fast we would make the core of mesa (e.g., via rust or cython), often the real bottleneck is user code.

As an aside, and more for my own understanding, how does the benchmarking now work with examples back in the main repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example Changes the examples or adds to them.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants