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

Switch sugarscape to using property layers #2546

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

quaquel
Copy link
Member

@quaquel quaquel commented Dec 12, 2024

This changes sugarscape to use property layers for sugar and spice instead of a resource agent.

I haven't yet updated the visualization side fully to take advantage of the property layer visualizations in MESA, I can do this in this PR or in a subsequent one, whichever is prefered.

@quaquel quaquel requested a review from tpike3 December 12, 2024 16:46
Copy link

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -1.4% [-4.0%, +1.0%] 🔵 +1.4% [+1.2%, +1.5%]
BoltzmannWealth large 🔵 +0.2% [-0.2%, +0.6%] 🔵 +2.1% [+0.6%, +3.7%]
Schelling small 🔵 -0.1% [-0.4%, +0.3%] 🔵 +1.9% [+1.7%, +2.1%]
Schelling large 🔵 +0.1% [-0.3%, +0.5%] 🔵 +2.6% [+1.8%, +3.6%]
WolfSheep small 🔵 -0.2% [-0.6%, +0.2%] 🔵 -0.2% [-1.5%, +1.0%]
WolfSheep large 🔵 -0.2% [-0.6%, +0.2%] 🔵 +2.0% [+0.9%, +3.2%]
BoidFlockers small 🔴 +4.0% [+3.5%, +4.5%] 🔵 +3.3% [+2.6%, +3.9%]
BoidFlockers large 🔴 +5.0% [+4.1%, +5.9%] 🔵 +3.1% [+2.3%, +3.8%]

@EwoutH EwoutH added the example Changes the examples or adds to them. label Dec 12, 2024
@EwoutH
Copy link
Member

EwoutH commented Dec 12, 2024

It’s really awesome how much this cleans up the code! So much more elegant.

Could you add a screenshot of how the visualization now looks?

@quaquel
Copy link
Member Author

quaquel commented Dec 12, 2024

Yes and there is more to come. For examples, traders do a gradient hill climb based on their neighborhood. This can now be expressed in a fully vectorized way using the masking stuff and some other property layer functionality.

I'll post a comparative visual tomorrow but at the moment I looks basically the same as before.

components=[SpaceDrawer, make_plot_component(["Trader", "Price"])],
components=[
SpaceDrawer,
make_plot_component("#Traders"),
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why "#Traders" and not Just "Traders"

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the name of the reporter so I had to change it here. For me # means "number of".

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

Property layer is super cool; I will leave it you if you want to merge and do another PR for the visual or just merge

Just had one question out of curiosity

@quaquel
Copy link
Member Author

quaquel commented Dec 13, 2024

Before

Screenshot 2024-12-13 at 17 43 21

After
Screenshot 2024-12-13 at 17 42 15

Like I said, at the moment, I haven't updated the visualization code other than to make it work again without the Resource Agent.

@quaquel quaquel merged commit 965eede into projectmesa:main Dec 13, 2024
10 of 11 checks passed
@quaquel quaquel deleted the sugarscape_propertylayer branch December 13, 2024 18:30
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