Skip to content

Wolf-sheep to use create_agent #2543

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 7 commits into from
Dec 11, 2024
Merged

Wolf-sheep to use create_agent #2543

merged 7 commits into from
Dec 11, 2024

Conversation

quaquel
Copy link
Member

@quaquel quaquel commented Dec 10, 2024

This updates the wolf sheep example to use create_agents for wolves and sheep. It also showcases how we can easily sample cells from a cell collection.

I have deliberately not touched grass patched. It is possible to rewrite this to use create_agent, but to make this nice and clean requires a few more changes. Moreover, ideally, this should be rewritten to use a property layer for grass anyway.

@EwoutH
Copy link
Member

EwoutH commented Dec 10, 2024

Looks good! Could you use keyword arguments for clarity?

@quaquel
Copy link
Member Author

quaquel commented Dec 11, 2024

Looks good! Could you use keyword arguments for clarity?

see the update and let me know which you prefer

@EwoutH
Copy link
Member

EwoutH commented Dec 11, 2024

Thanks, I think this helps.

Do you know why the tests fail?

FAILED tests/test_examples.py::test_wolf_sheep - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@quaquel
Copy link
Member Author

quaquel commented Dec 11, 2024

Do you know why the tests fail?

I have a hunch, but will be tonight most likely before I have time again. I'll get it fixed then

@EwoutH EwoutH added example Changes the examples or adds to them. trigger-benchmarks Special label that triggers the benchmarking CI and removed trigger-benchmarks Special label that triggers the benchmarking CI labels Dec 11, 2024
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -4.8% [-6.4%, -3.3%] 🔵 +1.2% [+1.1%, +1.4%]
BoltzmannWealth large 🔵 +0.5% [+0.0%, +0.9%] 🔵 +0.8% [-0.1%, +1.6%]
Schelling small 🔵 +1.1% [+0.7%, +1.4%] 🔵 +0.5% [+0.4%, +0.7%]
Schelling large 🔵 +1.2% [+0.9%, +1.5%] 🔵 -0.4% [-1.4%, +0.7%]
WolfSheep small 🔴 +3.8% [+3.3%, +4.2%] 🔵 -2.3% [-4.0%, -0.7%]
WolfSheep large 🔵 +1.4% [+0.8%, +2.0%] 🔵 +0.6% [-0.1%, +1.2%]
BoidFlockers small 🔵 +1.7% [+1.1%, +2.2%] 🔵 -0.3% [-0.9%, +0.3%]
BoidFlockers large 🔵 +2.3% [+0.9%, +4.0%] 🔵 -0.7% [-1.2%, -0.3%]

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.

Thanks!

@quaquel quaquel merged commit e8042f0 into projectmesa:main Dec 11, 2024
8 of 9 checks passed
@quaquel quaquel deleted the wolf_sheep branch December 11, 2024 12:58
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
example Changes the examples or adds to them.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants