#NEWLINE# def compute_duration( previous_action ) : #NEWLINE# #INDENT# 'Compute action duration using exponential distribution' #NEWLINE# if ( previous_action in [ 'leave garage' , 'drop off passenger' ] ) : #NEWLINE# #INDENT# interval = SEARCH_DURATION #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( previous_action == 'pick up passenger' ) : #NEWLINE# #INDENT# interval = TRIP_DURATION #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( interval == 'going home' ) : #NEWLINE# #INDENT# interval = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Unknown previous_action: %s' % previous_action ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( int ( random . expovariate ( ( 1 / interval ) ) ) + 1 )