Skip to content

Commit 68c48e6

Browse files
jonahaagtpike3
authored andcommitted
Rename i_steps -> data_collection_period and add docstring
1 parent 0ae8410 commit 68c48e6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mesa/batchrunner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def batch_run(
3636
parameters: Mapping[str, Union[Any, Iterable[Any]]],
3737
nr_processes: Optional[int] = None,
3838
iterations: int = 1,
39-
i_steps: int = -1,
39+
data_collection_period: int = -1,
4040
max_steps: int = 1000,
4141
display_progress: bool = True,
4242
) -> List[Dict[str, Any]]:
@@ -52,6 +52,8 @@ def batch_run(
5252
Number of processes used. Set to None (default) to use all available processors
5353
iterations : int, optional
5454
Number of iterations for each parameter combination, by default 1
55+
data_collection_period : int, optional
56+
Number of steps after which data gets collected, by default -1 (end of episode)
5557
max_steps : int, optional
5658
Maximum number of model steps after which the model halts, by default 1000
5759
display_progress : bool, optional
@@ -68,7 +70,7 @@ def batch_run(
6870
_model_run_func,
6971
model_cls,
7072
max_steps=max_steps,
71-
i_steps=i_steps,
73+
data_collection_period=data_collection_period,
7274
)
7375

7476
total_iterations = len(kwargs_list) * iterations
@@ -139,7 +141,7 @@ def _model_run_func(
139141
model_cls: Type[Model],
140142
kwargs: Dict[str, Any],
141143
max_steps: int,
142-
i_steps: int,
144+
data_collection_period: int,
143145
) -> Tuple[Tuple[Any, ...], List[Dict[str, Any]]]:
144146
"""Run a single model run and collect model and agent data.
145147
@@ -151,8 +153,8 @@ def _model_run_func(
151153
model kwargs used for this run
152154
max_steps : int
153155
Maximum number of model steps after which the model halts, by default 1000
154-
i_steps : int
155-
Collect data every ith step
156+
data_collection_period : int
157+
Number of steps after which data gets collected
156158
157159
Returns
158160
-------
@@ -165,7 +167,7 @@ def _model_run_func(
165167

166168
data = []
167169

168-
steps = list(range(0, model.schedule.steps, i_steps))
170+
steps = list(range(0, model.schedule.steps, data_collection_period))
169171
if not steps or steps[-1] != model.schedule.steps - 1:
170172
steps.append(model.schedule.steps - 1)
171173

0 commit comments

Comments
 (0)