[Math] Queuing theory : how to predict waiting time for desks providing different services

algorithmsqueueing-theory

This is a real-life problem that I have to solve for a piece of software that I am writing. I hope the question is appropriate for this site (I usually post on StackOverflow).

I am not a mathematician so please be patient with my approximate terminology.

Let us say that we have a bank office. It provides different types services. There are several desks inside.

Since the clerks do not all have the same capacities or skills, not all desks provide all services, and not all services are provided by the same number of desks.

Customers come in, specify which service they require and are attributed a ticket with a number. They then wait to be called to a desk that provides the service they require.

Once a desk finishes serving a customer, it looks up the next ticket in the queue that is for a service the desk provides, and call this ticket.

We know (from statistics) the average duration of each service.

How to predict the waiting time of a ticket that is in the waiting line ?

Concrete example :

We have 3 types of services :

+---+--------------------+----------+
|   |      Service       | Duration |
+---+--------------------+----------+
| A | Make a deposit     | 2 min    |
| B | Cash a check       | 5 min    |
| C | Open a new account | 10 min   |
+---+--------------------+----------+

We have 4 desks :

+------+-------------------+
| Desk | Provided services |
+------+-------------------+
|    1 | A                 |
|    2 | B                 |
|    3 | A, B              |
|    4 | B, C              |
+------+-------------------+

We have, at an instant t, the following tickets in the line :

+------------+------------------+
| Ticket num | Service required |
+------------+------------------+
|          1 | A                |
|          2 | B                |
|          3 | A                |
|          4 | C                |
|          5 | C                |
|          6 | B                |
|          7 | A                |
|          8 | A                |
|          9 | B                |
+------------+------------------+

How to calculate the predicted (mean) waiting time for each ticket in the line ?

So far I could not come up with a simple formula, so I perform "simulations" in code. But I am sure it is possible to do better.

NB: This is about calculating the concrete waiting times of the customers, based on a snapshot of the situation at a given time, not about calculating mean waiting time given a certain rate of incoming customers etc. I do not need to factor in randomness.

The goal is to approximate the waiting time and raise an alarm for the manager if it rises too high (so he can, for example, open an additional desk to speed things up).

Best Answer

Since it seems your system is fairly complicated, the best way to estimate waiting times is likely to be Monte Carlo-based estimation, using simulations as you're doing.

A more principled approach might be to use a Birth–death process (rather, a system of birth-death processes). The complexity is the fact that your desks can handle multiple tasks, so you could not setup multiple separate Markov processes; rather, you would have to set up several interconnected ones.

This second approach might be faster to get estimates from, but possibly less accurate (since the Poisson or exponential distributions may not accurately describe the real distribution).

Related Question