-
Notifications
You must be signed in to change notification settings - Fork 947
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
feat: Display model seed & allow user to specify it in JupyterViz #2069
Conversation
Performance benchmarks:
|
Sounds useful, thanks! I will leave the formal review to Corvince. One thought: Maybe we can have separate buttons for requesting a new seed and resetting the simulation to it's initial state. |
@@ -71,6 +71,7 @@ def JupyterViz( | |||
simulations with no space to visualize should | |||
specify `space_drawer=False` | |||
play_interval: play interval (default: 150) | |||
seed: the random seed used to initialize the model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explicitly pass in the random model seed so it is obvious to the user where the seed is coming form and what they are changing is they pass in their own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already an explicit argument. Specified by adding a "seed" entry to the model_params
dictionary: https://github.com/projectmesa/mesa-examples/blob/main/examples/schelling_experimental/app.py#L21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to remove that line from the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rht I am sorry I don't mean to belabor this, but I feel like I am missing something here. So please bear with me, my understanding is below.
Scenario 1: User does not specify the seed so we want the UI to show the seed that was selected. Shouldn't the display of the random seed reference obj._seed
Scenario 2: User specifies the seed* then it would display the "seed" parameter or still reference obj._seed
Thank you for bearing with me, I know we have had issues with the seed in the past and just want to make doubly sure we have one solid pointer to the model seed.
Let me know what you think
*Apologies my earlier comment was very confusing. seed should come from model_params
and be explicitly displayed not explicitly passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scenario 1: User does not specify the seed so we want the UI to show the seed that was selected. Shouldn't the display of the random seed reference obj._seed
The direction of the cause and effect should flow from the controls you see on the screen, and then the model properties. It can't be the obj._seed
to have a value before the control.
If you notice, the seed value is displayed twice. The one below the information card is model._seed
, displayed for debugging purpose. I will remove this once you agree to merge.
Update:
To test this PR, you need to modify your model.py, def __init__(self, width=20, height=20, density=0.8, minority_pc=0.2, homophily=3, seed=0):
super().__init__(seed=seed) |
10f2d57
to
1ee4276
Compare
Hm, does that mean all the models need to accept a |
|
Update: with 34a1853, no modification on existing models is necessary anymore. It works out of the box. |
LGTM - This is very cool, the model seed is one of those critical details that have burned many a modeler and I think making it explicit is an excellent idea. To merge it is (1) fixing the tests and (2) removing the seed below the information card. Thanks @rht |
This is because the unittest version is not sufficient to handle patching the `__new__` method.
for more information, see https://pre-commit.ci
@tpike3 sorry for the slow response, still recovering. I fixed the test by using
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I also like the change to the current_step
as a parameter, at least for me much more intuitive.
Fixes: #1812. The motivation can be found in that issue. It looks like this

The current behavior is that the seed is not changed even when you press the reset button. After all, it is now a user input param. However, if you force refresh the browser, the seed is still not changed. A more sustainable solution (so that user doesn't accidentally lose the seed) is to add a button to generate a new seed.