-
-
Notifications
You must be signed in to change notification settings - Fork 212
Open
Description
Issues with Bank Reserves Example: Crashes, Deprecations, and State Mismatches
Description
The bank_reserves example exhibits multiple issues preventing stable execution, proper visualization, and batch processing.
Detailed Issues
-
Crash (Race Condition)
Running the example withsolara run app.pyoften results in a crash.- Error:
ValueError: Length of values does not match length of index. - Cause: This appears to be a race condition in
mesa.DataCollectorwhere the Solara visualization thread reads data while the model thread is simultaneously writing to it.
- Error:
-
Deprecation Warnings
The terminal displays warnings indicating the example uses an outdated visualization API.- Warning:
FutureWarning: Returning a dict from agent_portrayal is deprecated.
- Warning:
-
Initialization Mismatch
The visualization loads with UI sliders set to default values (e.g., 25 "People"), but the model initializes with mismatching internal defaults (e.g., 2 "People").- Result: A confusing initial state where the UI indicates a high agent count, but only 2 dots are visible.
-
Batch Run Failure
Executingbatch_run.pyfails.- Cause:
BankReservesModeldoes not acceptseedorrngarguments, which are automatically passed by the batch runner.
- Cause:
Steps to Reproduce
- Navigate to the directory:
examples/bank_reserves. - Run the application:
solara run app.py
- Observe the following:
- A
ValueErrorappears in the terminal.
- A
- Check the terminal for the
FutureWarningregardingagent_portrayal. - Observe the visualization canvas: note that only 2 agents are shown despite the "People" slider indicating 25.
- Attempt to run the batch script:
python batch_run.py
Error Output
Below are the raw tracebacks and warnings observed during execution:
FutureWarning: Returning a dict from agent_portrayal is deprecated. Please return an AgentPortrayalStyle instance instead.
UserWarning: The following keys from the returned dict were ignored: Shape, r, Layer, Filled
ERROR: Component ... PlotMatplotlib raised exception ValueError('Length of values (180) does not match length of index (179)')
Traceback (most recent call last):
File ".../reacton/core.py", line 1702, in _render
root_element = el.component.f(*el.args, **el.kwargs)
File ".../mesa/visualization/components/matplotlib_components.py", line 156, in PlotMatplotlib
df = model.datacollector.get_model_vars_dataframe()
...
ValueError: Length of values (180) does not match length of index (179)
ERROR: ... ValueError('Length of values (3296) does not match length of index (3269)')
[... second traceback ...]
Expected Behavior
- Stability: The application should run stably without crashing due to race conditions.
- Clean Output: No deprecation warnings should appear in the terminal.
- Consistency: The initial visualization state (number of agents rendered) should match the initial UI slider values.
- Batch Processing:
batch_run.pyshould execute successfully without argument errors.
System Info
- OS: Windows/Linux/macOS
- Python Version: 3.x
- Mesa Version: (Current Main)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels