Skip to content

Add Interactive Play Interval Control to Mesa Visualization#2540

Merged
Corvince merged 2 commits intomesa:mainfrom
AdamZh0u:dev
Dec 11, 2024
Merged

Add Interactive Play Interval Control to Mesa Visualization#2540
Corvince merged 2 commits intomesa:mainfrom
AdamZh0u:dev

Conversation

@AdamZh0u
Copy link
Copy Markdown
Contributor

@AdamZh0u AdamZh0u commented Dec 8, 2024

Summary

This PR adds a slider control to dynamically adjust simulation speed in Mesa's visualization interface. Closes #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

@github-actions
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@Corvince Corvince merged commit 71d37f1 into mesa:main Dec 11, 2024
@Corvince
Copy link
Copy Markdown
Contributor

Thanks again @AdamZh0u for this PR! Merged!

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

Labels

feature Release notes label visualisation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SolaraViz: Add Slider controlling play_interval by default

4 participants