A Machine Learning Approach To Waiting Time Prediction in Queueing Scenarios
A Machine Learning Approach To Waiting Time Prediction in Queueing Scenarios
Abstract—Physically queueing is a reality on many industries Queueing optimization techniques are used in several in-
that provide services or sell goods. Waiting in a queue can be dustries to improve customer service. In the healthcare sector,
stressful and exhausting for the clients because of the enforced queueing models are used to improve resource utilization in
idle time, and may lead to decreased customer satisfaction.
Queueing theory has been widely used to assess client waiting hospitals [5], and to handle the tradeoffs that will improve
times, to optimize staff schedules, and to increase the robustness the efficiency and the quality of the provided services of
of a queueing system against a variable demand for service. healthcare systems [4]. In pharmacies with high workloads
In this paper, we are exploring how multiple industries that or multiple points of service, queueing models can assess
require queues can benefit from machine learning to predict service and waiting times [6]. In airports, queue planning
the clients’ waiting times. We begin by predicting waiting times
on bank queues, and then we propose how the procedure can is necessary for security controls and the check-in process
be generalized to more industries and automatized. A publicly [7]. Queueing lines can also be observed in everyday life
available dataset containing entries of people queueing in banks activities, such as paying at groceries, waiting for a table at a
is initially utilized, and after training a fully connected neural restaurant, or waiting to order at a fast-food restaurant. While
network, a mean absolute error of 3.35 minutes in predicting research has shown that longer waiting times may sometimes
client waiting times was achieved. We are then presenting a
web application that is managing queues of different scenarios lead to higher consumption in some cases [8], most queueing
and industries. The queues may have unique parameters, and scenarios would benefit from queue management to reduce
the system can adapt to each queue as it creates a per queue the cost on the used resources, in terms of personnel cost and
optimally trained neural network for waiting time prediction. consumer waiting times.
The use and the capabilities of the system are validated with the Queueing theory attempts to study the waiting lines through
use of a simulator. Machine learning, therefore, proves to be a
viable alternative to queueing theory for predicting waiting time. mathematical analysis. The earliest studied problems in this
domain concerned the congestion of telephone traffic and were
Keywords—Machine learning, pattern recognition, queue sys- investigated by the mathematician A. K. Erlang [9]. A queue
tem, queueing analysis, web application. can be modeled as a First-In First-Out (FIFO) node in which
clients arrive, possibly wait for some time, and take some
time to be processed by the server before they depart from
I. I NTRODUCTION AND R ELATED W ORK the queue [10]. The Kendall’s notation [11] is typically used
to describe a queueing node in the form of A/S/c, where A is
Queueing problems exist when multiple people need access the probability distribution of durations between each arrival
to a resource, and the service cannot match the level of to the queue, S the probability distribution of service times and
demand. On the one hand, queueing is a necessary evil when c the number of servers at the node. Using queueing theory,
accessing valuable resources like health-related ones, as the queue managers aim to balance a queueing system’s service
idle time of those resources is expensive [1]. On the other to customers by keeping the queues short and thus the waiting
hand, queues may get unnecessary big even for this purpose times low (that might mean an increased number of servers),
and may lead to long idle times for the customers. Time is and the economic upkeep of the system (that would mean to
a valuable resource, and consumers have to make decisions keep the number of servers low). By constructing a queueing
regarding the use of it when purchasing services or goods [2]. model, the waiting time for any client, and the queue length
The idea that ”time is money” has a long history, and the at any time can be predicted.
earliest recorded version has been attributed to Antiphon of Machine learning techniques and simulation models can
ancient Greece (ca. 430 BC) [3]. There is also a link between also be of use to deal with queueing problems. An im-
long waiting times and customer dissatisfaction [4], and thus, provement to the prediction of the overall waiting time for
industries should strive for better resource allocation that will daily radiation treatment appointments, when compared to
optimize waiting queues. the rough estimates that are typically given to patients, was
achieved by a regression model used in an oncology de-
This work was co-financed by Innosuisse. partment [12]. Machine learning was also used in another
18
Fig. 2. Histogram of the people waiting in the queue.
being produced.
4) Results: We have trained a fully connected neural net-
work with 2 hidden layers, the first with 12 neurons and the
second with 8 ones. We have used the Rectified Linear Unit
(ReLU) [16] as the activation function of all hidden layers,
and the Adam optimization algorithm [17] for the iterative Fig. 3. Views of the QueueforMe web application when (a) the creator is
update of the network weights based on the training data. An creating a new queue, (b) the client has just joined a queue, (c) the creator is
serving a new client, and (d) the client is being served by the creator.
exhaustive tuning of all related hyperparameters is out of the
scope of this paper, and commonly used default values for the
architecture of the neural network were used. for a queue by queue name or by the creator’s name, and
After 500 epochs of training, a mean absolute error of 3.35 can finally join the queue. After joining the queue, the client
minutes was achieved on the test set. To have an estimation is getting information about the queue including the position
of the predictive capability of the trained model, we are in the queue along with an estimated waiting time predicted
comparing against the naive mean and the naive median by a neural network trained for the specific queue using past
model; these are the models that always predict the mean queue data. The creator can operate the queue by asking for
and the median waiting time of the training set. The naive the next available client in the queue, and the corresponding
mean model had a mean absolute error of 4.71 minutes on client is getting a notification to be served. Screenshots of the
the test set, and the naive median an error of 4.59 minutes. QueueForMe web application can be seen in Fig. 3.
Our model has, therefore, achieved an improvement of 28.9% 2) Additional Queue Parameters: In a future version of
over the naive mean model and 27% over the naive median QueueForMe, the creator of a queue will have the option
one. Unfortunately, since there is no information regarding to define a set of queue specific parameters along with the
the deployed servers, we can not compare the predictive restricted set of responses for each parameter. Clients joining
performance of our model with one produced by queueing the queue will have to give a response to each of the defined
theory. parameters. These additional parameters set our solution apart
In order to make our research reproducible, we are sharing since such customizable additional parameters do not exist
the code that we used for the tests of the current study here in queueing theory, in a manner that can be automatically
(https://doi.org/10.5281/zenodo.3378407). The dataset used in exploitable. The corresponding neural network of each specific
this analysis is available here (https://doi.org/10.1016/j.dib. queue will be able to extract more valuable information and
2018.05.101). detect patterns among those parameters.
3) Simulator: To verify the learning capabilities of each
III. P ROPOSING A G ENERIC Q UEUEING S YSTEM neural network that is created with every queue, we have
1) QueueForMe: We are proposing QueueForMe, a web developed a simulator with which we can simulate customers
application that allows everyone to create a virtual queue joining a queue over a specific period of time. In our tool,
allowing clients around to join. QueueForMe includes two we can select the distribution at which new clients join the
types of users, the creators, and the clients. The creators are queue, the number of available lines and the distribution of
the ones that need to log in to our platform in order to create a the service time. A queue specific neural network is then
queue by providing a queue name and a description. A client retrained learning from the provided simulated customers that
does not need any credentials for the platform, can search have passed from the queue. The trained model is also saving
statistics regarding its predictive performance. Screenshots of
19
(a) (b) (c) (d)
Fig. 4. Views of the simulator web application (a) setting global queue parameters with the customer arrival distribution, (b) setting the number of open
lines and the service time distribution, (c) displaying the average statistics for the simulated dataset and starting a simulation, and (d) getting the error of the
corresponding neural network.
the simulator can be seen in Fig. 4. neural network of each queue, and different distributions of
4) Industry Specific Queue Simulation: In a future version each parameter response can be simulated using the simulator.
of the simulator we will also include the queue specific addi-
tional parameters as described above. Each queue will have a
R EFERENCES
predefined set of parameters, and each parameter will have a
set of valid responses. Using the simulator, the operator will [1] D. Worthington, “Queueing models for hospital waiting lists,” Journal
be able to simulate different distributions for each response to of the Operational Research Society, vol. 38, no. 5, pp. 413–422, 1987.
each parameter. New features fed to the neural network will [2] C. Mogilner, H. E. Hershfield, and J. Aaker, “Rethinking time: Implica-
be engineered by aggregating the parameter responses of all tions for well-being,” Consumer Psychology Review, vol. 1, no. 1, pp.
41–53, 2018.
previous queuers in relation to a current queuer. [3] B. Perrin, Plutarch’s Lives, ser. Loeb classical library. W. Heinemann,
1920, no. v. 9. [Online]. Available: https://books.google.ch/books?id=
IV. C ONCLUSION bSJgAAAAMAAJ
[4] A. Komashie, A. Mousavi, P. J. Clarkson, and T. Young, “An integrated
In this paper, we have explored how machine learning can model of patient and staff satisfaction using queuing theory,” IEEE
be used for predicting the waiting time of people queueing in journal of translational engineering in health and medicine, vol. 3, pp.
1–10, 2015.
lines. We have started by using a publicly available dataset [5] S. Belciug and F. Gorunescu, “Improving hospital bed occupancy
of queues in banks, and by training a neural network, we and resource utilization through queuing modeling and evolutionary
achieved a mean absolute error of 3.35 minutes, improving computation,” Journal of biomedical informatics, vol. 53, pp. 261–269,
2015.
over the performances of naive models. Unfortunately, we
[6] R. A. Nosek Jr and J. P. Wilson, “Queuing theory and customer satis-
could not directly compare against queueing theory because faction: a review of terminology, trends, and applications to pharmacy
the dataset lacked information about the deployed servers. practice,” Hospital pharmacy, vol. 36, no. 3, pp. 275–279, 2001.
After presenting a specific case on how machine learning can [7] R. De Neufville, L. Budd, and S. Ison, “Airport systems planning
and design,” Air transport management: An international perspective,
be used to predict waiting times in queueing scenarios, we vol. 61, 2016.
are generalizing on more industries. We presented our work [8] S. Ülkü, C. Hydock, and S. Cui, “Making the wait worthwhile: Experi-
on QueueForMe, a web application that allows everyone to ments on the effect of queueing on consumption,” Management Science,
2019.
create a virtual queue, and everyone around to join. Using a [9] A. K. Erlang, “The theory of probabilities and telephone conversations,”
simulator, we can verify the predictive capabilities of the queue Nyt. Tidsskr. Mat. Ser. B, vol. 20, pp. 33–39, 1909.
specific neural networks. As future work, we will include the [10] J. F. Shortle, J. M. Thompson, D. Gross, and C. M. Harris, Fundamentals
ability to add queue specific parameters at the queue creation of queueing theory. John Wiley & Sons, 2018, vol. 399.
[11] D. G. Kendall, “Stochastic processes occurring in the theory of queues
phase with predefined responses. This additional information and their analysis by the method of the imbedded markov chain,” The
will be exploited by the underlying waiting time-predicting Annals of Mathematical Statistics, pp. 338–354, 1953.
20
[12] A. Joseph, T. Hijal, J. Kildea, L. Hendren, and D. Herrera, “Predicting hospital pharmacy performance,” Iranian Red Crescent Medical Journal,
waiting times in radiation oncology using machine learning,” in 2017 vol. 16, no. 3, 2014.
16th IEEE International Conference on Machine Learning and Appli- [15] S. A. Bishop, H. I. Okagbue, P. E. Oguntunde, A. A. Opanuga, and
cations (ICMLA). IEEE, 2017, pp. 1024–1029. O. Odetunmibi, “Survey dataset on analysis of queues in some selected
[13] C. Curtis, C. Liu, T. J. Bollerman, and O. S. Pianykh, “Machine learning banks in ogun state, nigeria,” Data in brief, vol. 19, pp. 835–841, 2018.
for predicting patient wait times and appointment delays,” Journal of the [16] A. F. Agarap, “Deep learning using rectified linear units (relu),” arXiv
American College of Radiology, vol. 15, no. 9, pp. 1310–1316, 2018. preprint arXiv:1803.08375, 2018.
[14] M. Bahadori, S. M. Mohammadnejhad, R. Ravangard, and E. Tey- [17] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,”
mourzadeh, “Using queuing theory and simulation model to optimize arXiv preprint arXiv:1412.6980, 2014.
21