Skip to content

Commit 0bb2be7

Browse files
authored
Revert PR #161: Replace schedulers with AgentSet functionality (#170)
This commit reverts PR #161 projectmesa/mesa-examples#161 That PR assumed that time advancement would be done automatically, like proposed in #2223 We encountered some underlying issues with time, which we couldn't resolve in time.
1 parent 95e9d2c commit 0bb2be7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

boltzmann_wealth_model/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def compute_gini(model):
5-
agent_wealths = [agent.wealth for agent in model.agents]
5+
agent_wealths = [agent.wealth for agent in model.schedule.agents]
66
x = sorted(agent_wealths)
77
N = model.num_agents
88
B = sum(xi * (N - i) for i, xi in enumerate(x)) / (N * sum(x))
@@ -21,14 +21,14 @@ def __init__(self, N=100, width=10, height=10):
2121
super().__init__()
2222
self.num_agents = N
2323
self.grid = mesa.space.MultiGrid(width, height, True)
24-
24+
self.schedule = mesa.time.RandomActivation(self)
2525
self.datacollector = mesa.DataCollector(
2626
model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
2727
)
2828
# Create agents
2929
for i in range(self.num_agents):
3030
a = MoneyAgent(i, self)
31-
31+
self.schedule.add(a)
3232
# Add the agent to a random grid cell
3333
x = self.random.randrange(self.grid.width)
3434
y = self.random.randrange(self.grid.height)
@@ -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.schedule.step()
4242
# collect data
4343
self.datacollector.collect(self)
4444

0 commit comments

Comments
 (0)