Skip to content

Commit eae3f0b

Browse files
authored
Replace the remaining schedulers with AgentSet functionality (#202)
This PR completes the migration from schedulers to AgentSet functionality across the mesa-examples repository for all regular (non-`gis`/-`rl`) examples. Key changes include: - Replaced `RandomActivation`, `SimultaneousActivation`, and `RandomActivationByType` schedulers with appropriate AgentSet methods - Updated `Model.step()` implementations to use AgentSet activation - Removed references to `schedule.steps`, `schedule.agents`, and `schedule.agents_by_type` - Updated agent addition/removal logic to work with AgentSets - Adjusted data collection and visualization code to use `Model.steps` and `Model.agents` For more details on migrating from schedulers to AgentSets, see the migration guide: https://mesa.readthedocs.io/en/latest/migration_guide.html#time-and-schedulers
1 parent 4e76eff commit eae3f0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/basic/schelling/analysis.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
}
6666
],
6767
"source": [
68-
"while model.running and model.schedule.steps < 100:\n",
68+
"while model.running and model.steps < 100:\n",
6969
" model.step()\n",
70-
"print(model.schedule.steps) # Show how many steps have actually run"
70+
"print(model.steps) # Show how many steps have actually run"
7171
]
7272
},
7373
{
@@ -328,15 +328,15 @@
328328
" Find the % of agents that only have neighbors of their same type.\n",
329329
" \"\"\"\n",
330330
" segregated_agents = 0\n",
331-
" for agent in model.schedule.agents:\n",
331+
" for agent in model.agents:\n",
332332
" segregated = True\n",
333333
" for neighbor in model.grid.iter_neighbors(agent.pos, True):\n",
334334
" if neighbor.type != agent.type:\n",
335335
" segregated = False\n",
336336
" break\n",
337337
" if segregated:\n",
338338
" segregated_agents += 1\n",
339-
" return segregated_agents / model.schedule.get_agent_count()"
339+
" return segregated_agents / len(model.agents)"
340340
]
341341
},
342342
{

0 commit comments

Comments
 (0)