-
Notifications
You must be signed in to change notification settings - Fork 863
Network displayed in visualization has correct nodes but wrong edges #2134
Replies: 1 comment · 5 replies
-
This might be your problem? #1433. Otherwise, I recommend using the Solara-based new visualization, which will become the default in the upcoming Mesa release, 3.0. |
Beta Was this translation helpful? Give feedback.
All reactions
-
See https://github.com/projectmesa/mesa-examples/blob/main/examples/virus_on_network/app.py. To run it, |
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for this, but when I try to run it, I get the following: PS C:\Users\malaw\Documents\MSDS\ship\model\virus_on_network\virus_on_network> solara run app.py
Solara is installed: PS C:\Users\malaw\Documents\MSDS\ship\model\virus_on_network\virus_on_network> pip show solara
Location: c:\users\malaw\anaconda3\envs\sir\lib\site-packages I am running in a conda environment SIR. There is no executable for solara in the script directory: C:\Users\malaw\anaconda3\envs\SIR\Scripts Here is the mesa version: PS C:\Users\malaw\Documents\MSDS\ship\model\virus_on_network\virus_on_network> pip show mesa |
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't have access to a Windows machine and so can't debug. @projectmesa/maintainers have you encountered this issue? |
Beta Was this translation helpful? Give feedback.
All reactions
-
I posted the above question on solara github and recieved this reply. __**"Hey @malawleyGH! Did you upgrade from an older version of solara, or install in a fresh environment from scratch? We recently (see "Version 1.31.0" here) split the package to different subpackages. This could result in the solara command being removed, and would be fixed by reinstalling solara-server."** This in fact is exactly what happened, I upgrade solara and the command "solara run app.py" would then not work. So, when I saw this, I uninstalled mesa and solara, then reinstalled. It seems I had to do this a couple of times. Then I started having other problems that I was able to resolve and eventually, the command "solara run app.py" worked and a browser opened, plotted the network, the sliders for input parameters, and a reactive chart. The "Reset", "Step", and "Reseed" buttons all seem to work. But, the network itself is only drawn at the beginning. I need it to be redrawn on every step, since the nodes change state and thus nodes and edges change color. I think this is some of the appropriate code from jupyter_viz.py, with the very last else having the function drawing the network. Sorry, it will be hard to read since this editor removes all the indention. def Card(model, measures, agent_portrayal, space_drawer, dependencies, color, layout_type):
@solara.component
My jupyterViz in app.py is below. I am just not seeing anything that would make me think the network visualization is being updated as the model steps. How would I the network to redraw on every step? Thanks so very much. page = JupyterViz( |
Beta Was this translation helpful? Give feedback.
All reactions
-
There is not enough information from the code snippet you have provided. Have you tried the app.py in https://github.com/projectmesa/mesa-examples/tree/main/examples/virus_on_network verbatim? |
Beta Was this translation helpful? Give feedback.
-
I am working on an ABM similar to the example virus on a network. The model itself is good, but the visualization is not working. The browser opens fine, a network is displayed, the nodes are correct, but the edges are all wrong. The portrayal method is creating the correct network configuration. I have traced the journey of the portrayal to the method "write_message" in websocket.py. My understanding is that this method converts the portrayal dictionary to json format and sends to the websocket. Here is a bit of the code:
def write_message(
self, message: Union[bytes, str, Dict[str, Any]], binary: bool = False
) -> "Future[None]":
"""Sends the given message to the client of this Web Socket.
Notice that I inserted a print statement (near the bottom) that prints the message before it is sent. I checked the printed message carefully, it is the correct graph configuration, correct nodes and edges, correct node and edge colors, etc., and the json format of the message checks out when I tested it in python.
When the network is displayed, the nodes are the correct color, but the edges are all wrong. I tried this in both Edge and Chrome and got the same result, so I don't think it is the browser. I am at a loss of what to do now. Any suggestions would be greatly appreciated, I will be happy to provide more information if needed. Thanks
Beta Was this translation helpful? Give feedback.
All reactions