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

setting up online changes to model parameters #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mesa_viz_tornado/ModularVisualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def on_message(self, message):
if param in self.application.user_params:
if is_user_param(self.application.model_kwargs[param]):
self.application.model_kwargs[param].value = value
if self.application.dynamic:
setattr(self.application.model, param, value)
else:
self.application.model_kwargs[param] = value

Expand All @@ -262,6 +264,7 @@ def __init__(
name="Mesa Model",
model_params=None,
port=None,
dynamic=False,
):
"""
Args:
Expand All @@ -275,11 +278,14 @@ def __init__(
3. Environment var PORT
4. Default value (8521)
model_params: A dict of model parameters
dynamic: Whether to allow model parameters to update in real-time or not
"""

self.verbose = True
self.max_steps = 100000

self.dynamic = dynamic

if port is not None:
self.port = port
else:
Expand Down