@@ -22,19 +22,21 @@ def get_time(model) -> pd.Timedelta:
2222
2323def get_num_commuters_by_status (model , status : str ) -> int :
2424 commuters = [
25- commuter for commuter in model .schedule .agents if commuter .status == status
25+ commuter
26+ for commuter in model .agents_by_type [Commuter ]
27+ if commuter .status == status
2628 ]
2729 return len (commuters )
2830
2931
3032def get_total_friendships_by_type (model , friendship_type : str ) -> int :
3133 if friendship_type == "home" :
3234 num_friendships = [
33- commuter .num_home_friends for commuter in model .schedule . agents
35+ commuter .num_home_friends for commuter in model .agents_by_type [ Commuter ]
3436 ]
3537 elif friendship_type == "work" :
3638 num_friendships = [
37- commuter .num_work_friends for commuter in model .schedule . agents
39+ commuter .num_work_friends for commuter in model .agents_by_type [ Commuter ]
3840 ]
3941 else :
4042 raise ValueError (
@@ -45,7 +47,6 @@ def get_total_friendships_by_type(model, friendship_type: str) -> int:
4547
4648class AgentsAndNetworks (mesa .Model ):
4749 running : bool
48- schedule : mesa .time .RandomActivation
4950 show_walkway : bool
5051 show_lakes_and_rivers : bool
5152 current_id : int
@@ -82,7 +83,6 @@ def __init__(
8283 show_driveway = False ,
8384 ) -> None :
8485 super ().__init__ ()
85- self .schedule = mesa .time .RandomActivation (self )
8686 self .show_walkway = show_walkway
8787 self .show_lakes_and_rivers = show_lakes_and_rivers
8888 self .data_crs = data_crs
@@ -144,7 +144,6 @@ def _create_commuters(self) -> None:
144144 commuter .set_work (random_work )
145145 commuter .status = "home"
146146 self .space .add_commuter (commuter )
147- self .schedule .add (commuter )
148147
149148 def _load_buildings_from_file (
150149 self , buildings_file : str , crs : str , campus : str
@@ -215,7 +214,7 @@ def _set_building_entrance(self) -> None:
215214
216215 def step (self ) -> None :
217216 self .__update_clock ()
218- self .schedule . step ( )
217+ self .agents . shuffle_do ( "step" )
219218 self .datacollector .collect (self )
220219
221220 def __update_clock (self ) -> None :
0 commit comments