From b6956f8078486b0377fadd8b61bde625487d9cc2 Mon Sep 17 00:00:00 2001 From: Jan Kwakkel Date: Sat, 21 Sep 2024 10:33:48 +0200 Subject: [PATCH 1/2] remove schedulers from benchmark models. --- benchmarks/BoltzmannWealth/boltzmann_wealth.py | 1 - benchmarks/Flocking/flocking.py | 5 +---- benchmarks/Schelling/schelling.py | 4 +--- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/benchmarks/BoltzmannWealth/boltzmann_wealth.py b/benchmarks/BoltzmannWealth/boltzmann_wealth.py index 93d4da14aec..5423eb82164 100644 --- a/benchmarks/BoltzmannWealth/boltzmann_wealth.py +++ b/benchmarks/BoltzmannWealth/boltzmann_wealth.py @@ -43,7 +43,6 @@ def __init__(self, seed=None, n=100, width=10, height=10): super().__init__(seed) self.num_agents = n self.grid = mesa.space.MultiGrid(width, height, True) - self.schedule = mesa.time.RandomActivation(self) self.datacollector = mesa.DataCollector( model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"} ) diff --git a/benchmarks/Flocking/flocking.py b/benchmarks/Flocking/flocking.py index 9678f34bb62..a3f6af3fd44 100644 --- a/benchmarks/Flocking/flocking.py +++ b/benchmarks/Flocking/flocking.py @@ -116,7 +116,6 @@ def __init__( self.height = height self.simulator = simulator - self.schedule = mesa.time.RandomActivation(self) self.space = mesa.space.ContinuousSpace(self.width, self.height, True) self.factors = { "cohere": cohere, @@ -138,12 +137,10 @@ def __init__( **self.factors, ) self.space.place_agent(boid, pos) - self.schedule.add(boid) def step(self): """Run the model for one step.""" - self.schedule.step() - + self.agents.shuffle_do("step") if __name__ == "__main__": import time diff --git a/benchmarks/Schelling/schelling.py b/benchmarks/Schelling/schelling.py index 47bf521e057..0f66548c1be 100644 --- a/benchmarks/Schelling/schelling.py +++ b/benchmarks/Schelling/schelling.py @@ -67,7 +67,6 @@ def __init__( self.minority_pc = minority_pc self.simulator = simulator - self.schedule = RandomActivation(self) self.grid = OrthogonalMooreGrid( [height, width], torus=True, @@ -84,12 +83,11 @@ def __init__( agent_type = 1 if self.random.random() < self.minority_pc else 0 agent = SchellingAgent(self, agent_type, radius, homophily) agent.move_to(cell) - self.schedule.add(agent) def step(self): """Run one step of the model.""" self.happy = 0 # Reset counter of happy agents - self.schedule.step() + self.agents.shuffle_do("step") if __name__ == "__main__": From 35067d680dea2820819662a3ad4e37d44528b375 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:34:35 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- benchmarks/Flocking/flocking.py | 1 + benchmarks/Schelling/schelling.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/Flocking/flocking.py b/benchmarks/Flocking/flocking.py index a3f6af3fd44..d2d23b1ac79 100644 --- a/benchmarks/Flocking/flocking.py +++ b/benchmarks/Flocking/flocking.py @@ -142,6 +142,7 @@ def step(self): """Run the model for one step.""" self.agents.shuffle_do("step") + if __name__ == "__main__": import time diff --git a/benchmarks/Schelling/schelling.py b/benchmarks/Schelling/schelling.py index 0f66548c1be..73ddeaba4e2 100644 --- a/benchmarks/Schelling/schelling.py +++ b/benchmarks/Schelling/schelling.py @@ -2,7 +2,6 @@ from mesa import Model from mesa.experimental.cell_space import CellAgent, OrthogonalMooreGrid -from mesa.time import RandomActivation class SchellingAgent(CellAgent):