Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mesa/batchrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def _model_run_func(
Return model_data, agent_data from the reporters
"""
run_id, iteration, kwargs = run

# Handle seed uniqueness across iterations
if "seed" in kwargs and kwargs["seed"] is not None and iteration > 0:
seed_value = kwargs["seed"]
if isinstance(seed_value, (int, float)) and not isinstance(seed_value, bool):
kwargs = kwargs.copy()
kwargs["seed"] = int(seed_value) + iteration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kwargs["seed"] = int(seed_value) + iteration
kwargs["seed"] = seed_value + time.time()

This is all that is needed to ensure a much better spread of seeding values and thus better randomness.


model = model_cls(**kwargs)
while model.running and model.steps <= max_steps:
model.step()
Expand Down