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

Add Interactive Play Interval Control to Mesa Visualization #2540

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AdamZh0u
Copy link
Contributor

@AdamZh0u AdamZh0u commented Dec 8, 2024

Summary

This PR adds a slider control to dynamically adjust simulation speed in Mesa's visualization interface. #2497

Motive

  • Fixed play interval was limiting user control
  • Need flexible speed control for observing different phenomena

Implementation

  • Added play interval slider (1ms-500ms)
  • Made interval reactive for real-time updates
  • Updated controllers to use dynamic interval

Usage Examples

The play interval slider appears automatically in the Controls panel of any Mesa visualization, no additional configuration needed.

  • Before
  • After

Additional Notes

  • Maintains backward compatibility
  • Safe range limits prevent performance issues

Copy link

github-actions bot commented Dec 8, 2024

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +1.8% [+1.3%, +2.3%] 🔵 +0.7% [+0.6%, +0.8%]
BoltzmannWealth large 🔵 +1.2% [+0.9%, +1.6%] 🔵 +0.3% [-0.2%, +0.7%]
Schelling small 🔵 +1.0% [+0.8%, +1.2%] 🔵 +0.2% [+0.0%, +0.3%]
Schelling large 🔵 +1.2% [+1.0%, +1.5%] 🔵 +0.0% [-0.4%, +0.5%]
WolfSheep small 🔵 +0.6% [+0.4%, +0.8%] 🔵 +0.4% [+0.3%, +0.6%]
WolfSheep large 🔵 +0.5% [+0.2%, +0.7%] 🔵 -0.4% [-1.7%, +0.8%]
BoidFlockers small 🔴 +4.5% [+4.0%, +5.0%] 🔵 +1.7% [+0.8%, +2.7%]
BoidFlockers large 🔴 +4.1% [+3.7%, +4.7%] 🔵 +1.2% [+0.5%, +2.2%]

@quaquel
Copy link
Member

quaquel commented Dec 8, 2024

I like this PR, but I defer to @Corvince's view on it since he has been doing most of the work on the visualization stuff.

@Corvince
Copy link
Contributor

Thanks for tagging me @quaquel, I wasn't looking into mesa a lot the last weeks, so this would have gone unnoticed by me. Nice, focused PR. I approved, but I also left a comment that you could try out @AdamZh0u . But it is also fine as-is.

@AdamZh0u
Copy link
Contributor Author

@Corvince Thanks for the comments! You helped me realize an important point - the play_interval should be passed as a reactive object to controllers. Without maintaining its reactive nature, the controllers won't be able to dynamically update when the interval changes. I've tested the changes and confirmed that we can now adjust the simulation speed in real-time while the model is running.

@AdamZh0u AdamZh0u requested a review from Corvince December 10, 2024 14:49
@quaquel
Copy link
Member

quaquel commented Dec 10, 2024

Thanks a lot for this! I'll give @Corvince time to have another look but it seems ready to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants