File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 1010
1111
1212def compute_delay (interval ):
13+ """Compute action delay using exponential distribution"""
1314 return int (random .expovariate (1 / interval )) + 1
1415
1516
1617def taxi_process (ident , trips ):
18+ """Yield to simulator issuing event at each state change"""
1719 trip_ends = 0
1820 for i in range (trips ):
1921 prowling_ends = trip_ends + compute_delay (FIND_PASSENGER_INTERVAL )
@@ -33,6 +35,7 @@ def __init__(self, actors):
3335 self .time = 0
3436
3537 def schedule_events (self ):
38+ """Advance each actor to next state, scheduling events"""
3639 for actor in list (self .actors ):
3740 try :
3841 future_event = next (actor )
@@ -42,6 +45,7 @@ def schedule_events(self):
4245 self .events .put (future_event )
4346
4447 def run (self , end_time ):
48+ """Schedule and execute events until time is up"""
4549 while self .time < end_time :
4650 self .schedule_events ()
4751 if self .events .empty ():
@@ -66,6 +70,7 @@ def extract_seed(args):
6670
6771
6872def main (args ):
73+ """Parse command line, build actors and run simulation"""
6974 extract_seed (args )
7075 if args :
7176 end_time = int (args [0 ])
You can’t perform that action at this time.
0 commit comments