Get startedGet started for free

Manage taxi company: run model

Now that you have successfully randomized events in the previous exercise, let's apply these new concepts in the context of a discrete-event model.

A taxi company with ten taxis wants to optimize their business to maximize profit.

You know that taxis usually:

  1. Wait between one to ten minutes for new customer calls, and
  2. Take between one and ten minutes to arrive at the customer pick-up location (random duration between the given interval).

The average ride takes 20 minutes with a standard deviation of five minutes. Let's build a discrete-event model and run it for an eight-hour shift.

The time in the model is in minutes.

This exercise is part of the course

Discrete Event Simulation in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

def taxi_ride(env, order, taxis):
    with taxis.request() as taxi_request:
        taxi_request_time = env.now
        yield taxi_request
        wait_time = env.now - taxi_request_time
        waiting_taxi_dispatch.append(wait_time)
        
        # Clock-in time between taxi dispatch and passenger boarding
        yield env.timeout(____)

        wait_time = env.now - taxi_request_time
        waiting_passsenger_pickup.append(wait_time)

        # Clock-in riding time from pick-up to drop-off
        yield env.timeout(____)
Edit and Run Code