diff --git a/mesa/batchrunner.py b/mesa/batchrunner.py index 83bc79061b6..6dd93e4eae8 100644 --- a/mesa/batchrunner.py +++ b/mesa/batchrunner.py @@ -173,6 +173,11 @@ def _model_run_func( model = model_cls(**kwargs) while model.running and model.steps <= max_steps: model.step() + # Fix for Issue #2514: collect final step's data + + +if self.collect_data and hasattr(model, "datacollector"): + model.datacollector.collect(model) data = []