1. Learn
  2. /
  3. Courses
  4. /
  5. Discrete Event Simulation in Python

Connected

Exercise

Managing payment queues

A clothes shop becomes very busy at peak hours when people often queue to pay. Currently, there is only one cashier, and you have been asked to do a cost-benefit analysis to determine how many cashiers would be needed to reduce waiting times as much as possible to increase profitability.

You have decided to build a discrete-event model. You know that:

  • On average, a new customer joins the queue every 15 seconds during peak hours;
  • Customers usually bring several items with them, typically between 1 and 20; and
  • It takes an average of 3 seconds to scan an item in the cashier, and the payment generally takes another 20 seconds.

The argument counter stores the SimPy resource, and the argument customer_num tracks the number of customers.

Let's run the model and calculate how long it takes to serve 30 customers with a different number of cashiers.

Instructions 1/2

undefined XP
    1
    2
  • Complete the statement that requests a counter.
  • Clock-in the time spent at the cashier (scanning items and paying).
  • Create the resource named counter with a capacity of 1 (which means 1 counter).