НачатьНачать бесплатно

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.

Это упражнение является частью курса

Discrete Event Simulation in Python

Посмотреть курс

Инструкции к упражнению

  • 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"].

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

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
Редактировать и запускать код