Transportation model: defining process methods
Now that you have defined the model inputs, you are ready to create the model engine, which consists of the methods that will characterize your processes.
Two processes affect the time a given driver takes to travel a certain distance, which are: (1) actual driving time to travel the desired distance respecting the speed limit and the (2) waiting time at traffic lights.
Diese Übung ist Teil des Kurses
Discrete Event Simulation in Python
Anleitung zur Übung
- Use the Gaussian distribution to pseudo-randomly generate values for
random_generated["Distance"]
. - Update
distance_total
by adding the new distance calculated. - Generate integer random values for
random_generated["WaitTime"]
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
def road_travel(inputs, distance_total):
# Use the Gaussian method to generate distance values
distance = ____.____(inputs['Dist_between_intersections_m'][0], inputs['Dist_between_intersections_m'][1])
# Update the total distance
distance_total += ____
return distance, distance_total
def wait_traffic_light(inputs, distance_total):
# Generate random (integer) waiting times
waitTime_traffic_light_sec = ____.____(0, inputs['Max_waitTime_traffic_lights_sec'])
return waitTime_traffic_light_sec