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.
This exercise is part of the course
Discrete Event Simulation in Python
Exercise instructions
- 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"]
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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