File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ results = mesa.batch_run(
240
240
iterations = 5 ,
241
241
max_steps = 100 ,
242
242
data_collection_period = 1 ,
243
+ number_processes = 1 # Change to use multiple CPU cores for parallel execution
243
244
)
244
245
```
245
246
Original file line number Diff line number Diff line change 3
3
To take advantage of parallel execution of experiments, `batch_run` uses
4
4
multiprocessing if ``number_processes`` is larger than 1. It is strongly advised
5
5
to only run in parallel using a normal python file (so don't try to do it in a
6
- jupyter notebook). Moreover, best practice when using multiprocessing is to
6
+ jupyter notebook). This is because Jupyter notebooks have a different execution
7
+ model that can cause issues with Python's multiprocessing module, especially on
8
+ Windows. The main problems include the lack of a traditional __main__ entry
9
+ point, serialization issues, and potential deadlocks.
10
+
11
+ Moreover, best practice when using multiprocessing is to
7
12
put the code inside an ``if __name__ == '__main__':`` code black as shown below::
8
13
9
14
from mesa.batchrunner import batch_run
21
26
display_progress=True,
22
27
)
23
28
24
-
25
-
26
29
"""
27
30
28
31
import itertools
You can’t perform that action at this time.
0 commit comments