Introducing mesa-interactive #1834
Replies: 2 comments 6 replies
-
Thanks a lot for this effort. Being able to really inspect how the environment influences agent behaviour is extremely useful! Will there be a tutorial or getting started guide in the docs somewhere? I would really love to share this with our students! I will try to explore Mesa interactive early next week, and if your find it useful, deliver some feedback. CC @omarkamouh and @igornikolic: This looks like a tremendous new capability to explore ABM models and behaviour, with serious educational value. Might be close following closely! |
Beta Was this translation helpful? Give feedback.
-
@rlskoeser Do you think this package might be of interest to you? What features would you wish for? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm excited to introduce a new frontend package for Mesa—Mesa-Interactive. Designed for both developers and researchers, this package enables interactive exploration of Mesa models for various purposes, such as demonstration, in-depth analysis, and even debugging.
screen-capture.4.webm
Features
Basic Setup Example
To set up the visualization, you can use the following code:
In the frontend, all model parameters are configurable by default. You have multiple options for how these configurations appear:
For greater control, you can use the utility function
slide
. This function operates similarly to Python'srange
, but it offers additional customization by allowing you to set a default value and step size.Visualization Components
Here's how you can create visualization components like a GridView:
The color parameter is used to define which agent variable to use to differentiate the agents. In this case its type. This GridView component can be interactively called in a notebook session using
GridView(model)
.Interactivity
Add click handlers to make your model interactive:
On a click the function is called with the current model state and the (x,y) coordinates. We can use that to get the correct agent and change its type (in the example the type is either 0 or 1).
Now, redefine your grid with
GridView = create_grid("type", on_click=switch_agent_type)
.We can also create charts with the following function
That is we call the function with a set or list of variables, which are model attributes and they are displayed as a line chart. Again this could be used standalone via
HappyChart(model)
We can also add any model dependent text via
In principal we can pass any solara component to our visualization and those components will be called with
model
as their only component. If you want to display components independent of the model state, e.g. static text you can wrap it in a static utility functionThat means you can use your own solara components or for example matplotlib graphs wrapped in solaras
FigureMatplotlib
Installation
Mesa-interactive is available as a normal python package and installable via
You can have a look at the repo and provided additional ideas here in this thread or as dedicated issues. I hope some people will find this useful and use it for there models.
Deployment
By the end of the year some changes are coming to solara that should make it easier to deploy your own models on the internet and this will be reflected in mesa-interactive, but until then you can look at official solara documentation
Beta Was this translation helpful? Give feedback.
All reactions