projectmesa / mesa

Mesa is an open-source Python library for agent-based modeling, ideal for simulating complex systems and exploring emergent behaviors.
https://mesa.readthedocs.io
Apache License 2.0
2.43k stars 874 forks source link

batch_run makes no progress #2320

Open peihsunhsieh opened 1 month ago

peihsunhsieh commented 1 month ago

Describe the bug

Version: mesa 2.3.4

I encountered an issue where the model runs much slower when using batch_run compared to running the same model manually.

When running the model manually for 100 steps, it completed in just 2 minutes:

test_model = Societies_G2_LTX(N=1000,g1_learning_type='PB',g2_learning_type='CB', group2_prop=0.1, g1_init='r')
for _ in range(100):
    test_model.step()

However, when I used batch_runwith the same parameters, the model kept running for over 10 minutes, even for only ten steps:

params = {'N':1000, 'g1_learning_type':'PB','g2_learning_type':'CB', 'group2_prop':0.45,'g1_init':'r'}
Societies_G2_LTX_test = mesa.batch_run(
    Societies_G2_LTX,
    parameters=params,
    iterations=1,
    max_steps=10,
    number_processes=1,
    data_collection_period=1,
    display_progress=True,
)

Is there any known issue when using batch_run, or am I missing something in the configuration that could be causing this significant slowdown? Is it related to the issue in #2135 ?

EwoutH commented 1 month ago

Thanks for reporting this potential issue. Could you share the full model? Then I will try to reproduce it.