Skip to content

Use performance optimized shuffle_do() method #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples/aco_tsp/aco_tsp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def step(self):
"""
A model step. Used for activating the agents and collecting data.
"""
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
self.update_pheromone()

# Check len of cities visited by an agent
Expand Down
2 changes: 1 addition & 1 deletion examples/bank_reserves/bank_reserves/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(

def step(self):
# tell all the agents in the model to run their step function
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/bank_reserves/batch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def step(self):
# collect data
self.datacollector.collect(self)
# tell all the agents in the model to run their step function
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")

def run_model(self):
for i in range(self.run_time):
Expand Down
2 changes: 1 addition & 1 deletion examples/boid_flockers/boid_flockers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ def make_agents(self):
self.space.place_agent(boid, pos)

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, N=100, width=10, height=10):
self.datacollector.collect(self)

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/boltzmann_wealth_model_experimental/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, N=100, width=10, height=10):
self.datacollector.collect(self)

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, num_agents=7, num_nodes=10):
self.datacollector.collect(self)

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/caching_and_replay/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def step(self):
Run one step of the model.
"""
self.happy = 0 # Reset counter of happy agents
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")

self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/charts/charts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(

def step(self):
# tell all the agents in the model to run their step function
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
4 changes: 2 additions & 2 deletions examples/el_farol/el_farol/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def __init__(
def step(self):
self.datacollector.collect(self)
self.attendance = 0
self.agents.shuffle().do("update_attendance")
self.agents.shuffle_do("update_attendance")
# We ensure that the length of history is constant
# after each step.
self.history.pop(0)
self.history.append(self.attendance)
self.agents.shuffle().do("update_strategies")
self.agents.shuffle_do("update_strategies")
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def step(self):
"""
Advance the model by one step and collect data.
"""
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)
self.iteration += 1
Expand Down
2 changes: 1 addition & 1 deletion examples/forest_fire/Forest Fire Model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
" \"\"\"\n",
" Advance the model by one step.\n",
" \"\"\"\n",
" self.agents.shuffle().do(\"step\")\n",
" self.agents.shuffle_do(\"step\")\n",
" self.dc.collect(self)\n",
" # Halt if no more fire\n",
" if self.count_type(self, \"On Fire\") == 0:\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/forest_fire/forest_fire/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def step(self):
"""
Advance the model by one step.
"""
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/hotelling_law/hotelling_law/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def step(self):
# Collect data for the current step.
self.datacollector.collect(self)
# Activate all agents in random order
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# Update market dynamics based on the latest actions
self.recalculate_market_share()

Expand Down
2 changes: 1 addition & 1 deletion examples/schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def step(self):
Run one step of the model.
"""
self.happy = 0 # Reset counter of happy agents
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")

self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/schelling_experimental/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def step(self):
Run one step of the model. If All agents are happy, halt the model.
"""
self.happy = 0 # Reset counter of happy agents
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/shape_example/shape_example/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def make_walker_agents(self):
unique_id += 1

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
2 changes: 1 addition & 1 deletion examples/virus_on_network/virus_on_network/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def resistant_susceptible_ratio(self):
return math.inf

def step(self):
self.agents.shuffle().do("step")
self.agents.shuffle_do("step")
# collect data
self.datacollector.collect(self)

Expand Down
Loading