Skip to content

Commit 9a5396f

Browse files
authored
Use performance optimized shuffle_do() method (#201)
Replace shuffle().do() in 18 models with the performance optimized shuffle_do() method.
1 parent 31537d8 commit 9a5396f

File tree

18 files changed

+19
-19
lines changed

18 files changed

+19
-19
lines changed

examples/aco_tsp/aco_tsp/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def step(self):
225225
"""
226226
A model step. Used for activating the agents and collecting data.
227227
"""
228-
self.agents.shuffle().do("step")
228+
self.agents.shuffle_do("step")
229229
self.update_pheromone()
230230

231231
# Check len of cities visited by an agent

examples/bank_reserves/bank_reserves/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(
152152

153153
def step(self):
154154
# tell all the agents in the model to run their step function
155-
self.agents.shuffle().do("step")
155+
self.agents.shuffle_do("step")
156156
# collect data
157157
self.datacollector.collect(self)
158158

examples/bank_reserves/batch_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def step(self):
167167
# collect data
168168
self.datacollector.collect(self)
169169
# tell all the agents in the model to run their step function
170-
self.agents.shuffle().do("step")
170+
self.agents.shuffle_do("step")
171171

172172
def run_model(self):
173173
for i in range(self.run_time):

examples/boid_flockers/boid_flockers/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ def make_agents(self):
143143
self.space.place_agent(boid, pos)
144144

145145
def step(self):
146-
self.agents.shuffle().do("step")
146+
self.agents.shuffle_do("step")

examples/boltzmann_wealth_model/boltzmann_wealth_model/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, N=100, width=10, height=10):
3838
self.datacollector.collect(self)
3939

4040
def step(self):
41-
self.agents.shuffle().do("step")
41+
self.agents.shuffle_do("step")
4242
# collect data
4343
self.datacollector.collect(self)
4444

examples/boltzmann_wealth_model_experimental/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, N=100, width=10, height=10):
3838
self.datacollector.collect(self)
3939

4040
def step(self):
41-
self.agents.shuffle().do("step")
41+
self.agents.shuffle_do("step")
4242
# collect data
4343
self.datacollector.collect(self)
4444

examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, num_agents=7, num_nodes=10):
3838
self.datacollector.collect(self)
3939

4040
def step(self):
41-
self.agents.shuffle().do("step")
41+
self.agents.shuffle_do("step")
4242
# collect data
4343
self.datacollector.collect(self)
4444

examples/caching_and_replay/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def step(self):
9393
Run one step of the model.
9494
"""
9595
self.happy = 0 # Reset counter of happy agents
96-
self.agents.shuffle().do("step")
96+
self.agents.shuffle_do("step")
9797

9898
self.datacollector.collect(self)
9999

examples/charts/charts/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135

136136
def step(self):
137137
# tell all the agents in the model to run their step function
138-
self.agents.shuffle().do("step")
138+
self.agents.shuffle_do("step")
139139
# collect data
140140
self.datacollector.collect(self)
141141

examples/el_farol/el_farol/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def __init__(
3434
def step(self):
3535
self.datacollector.collect(self)
3636
self.attendance = 0
37-
self.agents.shuffle().do("update_attendance")
37+
self.agents.shuffle_do("update_attendance")
3838
# We ensure that the length of history is constant
3939
# after each step.
4040
self.history.pop(0)
4141
self.history.append(self.attendance)
42-
self.agents.shuffle().do("update_strategies")
42+
self.agents.shuffle_do("update_strategies")

0 commit comments

Comments
 (0)