queueing : A Package For Analysis Of Queueing Networks and Models in R by

queueing is a package that solves and provides the main performance measures for both basic Markovian queueing models and single and multiclass product-form queueing networks. It can be used both in education and for professional purposes. It provides an intuitive, straightforward way to build queueing models using S3 methods. The package solves Markovian models of the form M/M/c/K/M/FCFS, open and closed single class Jackson networks, open and closed multiclass networks and mixed networks. Markovian models are used when both the customer inter-arrival time and the server processing time are exponentially distributed. Queueing network solvers are useful for modelling situations in which more than one station must be visited.


Introduction
Queueing theory is a mathematical branch of operations research.A pioneering work in this field was The Theory of Probabilities and Telephone Conversations by A. K. Erlang (Erlang, Agner K., 1909).
Queueing exists when the demand for a service exceeds the available supply (Donald Gross and Carl M. Harris, 1974).Although the common image of queues is that of people waiting in line, for example at the supermarket checkout (Terry Green, 2012), queueing models are also used to analyse computer performance (I.Mitrani, 1987Mitrani, , 1998;;E. Gelembe and I. Mitrani, 1980;Mor Harchol-Balter, 2013;Ramón Puigjaner et al., 1995;Edward D. Lazowska et al., 1984;Leonard Kleinrock, 1976), traffic jams (Tom Vanderbilt, 2009) and in many other areas of activity.
Although there are computer programs that are applicable to queueing theory, to date the statistical computing environment R has lacked specific packages for this purpose.
In 2015 and 2016 respectively, simmer (Iñaki Ucar and Bart Smeets, 2015) and queuecomputer (Anthony Ebert, 2016) were included at CRAN.Both apply simulation techniques to queueing models.Simulation techniques have the great advantage of flexibility, enabling a system to be represented at the level of detail desired.The disadvantages are the greater costs incurred, because many parameters must be defined, a large and complex program developed (and debugged) and significant computational resources deployed in order to obtain narrow confidence intervals (Edward D. Lazowska et al., 1984).queueing is a queueing model solver, which has the advantage of achieving a favourable balance between accuracy and efficiency (Edward D. Lazowska et al., 1984).
queueing provides R users with the most widely-used models: Markovian models, queueing networks and calculators.Although Markovian models or queueing network models may be viewed as very simple models with strong assumptions, they have actually been used to accurately model many real situations, because the accuracy of queueing models is robust with respect to deviations from prior assumptions (Edward D. Lazowska et al., 1984).
Markovian models include the familiar queues observed in real life at supermarket and airport checkouts, restaurant queues, etc.The performance of computer systems can be modelled in a similar way by assuming that the customers are operating system processes, database transactions, etc.With queueing networks, several classes of customers can be considered, and therefore sizing, capacity planning and what-if scenarios can be addressed with robust assumptions (Edward D. Lazowska et al., 1984).For example, queueing networks can be observed at airports, where various stages, such as check-in, passport control and security checks must be completed in turn before passengers enter the aeroplane.
Finally, calculators are utilities that are used to obtain probabilities, such as that of a supermarket customer being obstructed, of a passenger being rejected after arrival, or of a caller being transferred to hear the operator voice message stating that all phone lines are busy.
These features of the queueing package make it a very valuable tool for the applied study of queuing theory, in diverse fields of application, including the following: • In education, to facilitate the presentation of class content, for learning and practice; • In research, to achieve a deeper understanding of the models and their principles, using this as a basis for designing more advanced models.• In health centres, to determine the appropriate size for waiting areas and the average time that patients must wait.• In database administration, to discover bottlenecks at database servers and to accomodate user load.
The R Journal Vol.9/2, December 2017 ISSN 2073-4859 • In the design of inbound call-centres, to calculate the optimal number of agents required to maintain a given level of service.

Nomenclature
To take into account different forms of queue organisation (limited or unlimited space, limited or unlimited population, etc.), a nomenclature of six positions describing the characteristics of the model is usually used (D.G. Kendall, 1953).Its structure is A/B/C/K/M/Z, where: • A describes the inter-arrival time probability distribution, • B describes the service time probability distribution, • C is the number of servers or channels, • K is the space limit of the service facility in the sense that no more than K customers can be in the system (C in service and K -C waiting in queue), • M is the size of the customer population, • Z is the queue discipline, i.e how the next customer is chosen from the queue when the server completes a service.
When Z is FCFS, M = ∞, and K = ∞, the last three positions are omitted.
Thus, M/M/1/∞/∞/FCFS, abbreviated to M/M/1, describes a model in which the inter-arrival and service times are both exponential (M is obtained from the Markovian property of the exponential distribution); there is a single server in a facility that does not impose any restriction on the number of customers; customers arrive from a population that is considered infinite in the sense that the arrival of an individual does not modify the probability of the next arrival; and FCFS (First Come, First Served) is the most frequent way in which the next customer to be served is chosen from the queue.

Package contents
The package built provides a solution for two families of models, and three commonly-used calculators: • Markovian models: in which inter-arrival and service times are both distributed exponentially (Pazos Arias et al., 2003;Sixto Ríos Insúa et al., 2004;Donald Gross and Carl M. Harris, 1974;Leonard Kleinrock, 1975): • Calculators: The R Journal Vol.9/2, December 2017 ISSN 2073-4859

Structure of queueing package
The queueing package was developed taking into account the S3 special class of functions in R. With this type of function, different queueuing models can be created in the same way, thus providing the user with a uniform and easy way to create the models.The model is created using the following steps: 1. Create the inputs for the model with the NewInput function; 2. Optionally check the inputs with the CheckInput function.
3. Create the model by calling QueueingModel 4. Print a summary of the model using print, or a specific model performance measure such as W.
Although step 2 is optional (as it is applied when the QueueingModel function is called), it is recommended that the inputs should always be checked, as this makes it easier to understand the data and, thus to correctly build the model.
The following code is an example of a model using queueing.It can be thought of as cars arriving at a petrol station, following an exponential distribution at the rate λ = 2.The cars are served exponentially distributed at the rate µ = 3.
This situation is modelled in queueing using a single node in which the customer inter-arrival time and service time both follow an exponential distribution, at the rates λ = 2 and µ = 3 respectively, as shown in Figure 1.The output of the model also includes components, as the functions F W q (t) and F W (t), which can be used to view the cumulative probability distribution of the random variables w q (time waiting) and w (time in the system: time in queue + time being served), assuming FIFO (Fist In, First Out) or FCFS(Fist Come, First Served) as the queue discipline.Accordingly, F W q (t) is the probability of a customer waiting for a time less than or equal to t for service (Donald Gross and Carl M. Harris, 1974).
As can be seen in Figure 2, the probability of a customer having to wait for at least 4 units of time is 1, and this coincides with the probability of a customer having to spend 4 total units of time in the system.
• Sometimes it is useful to compare different models, for example to measure the impact of duplicating the number of servers or of restricting the queue area.queueing includes a useful function to compare different queueing models, so that the tradeoff between performace measures can be seen at a glance.

Queueing Network Models
In addition to the basic Markovian models, queueing also offers several routines with which to build different queueing networks.
Although simple queueing models have been used to correctly model different situations (Allan L. Scherr, 1967), a queueing network must be used when several stages or places need to be visited in order to obtain full service.There are some "special" queueing networks in the simple models: thus, M/M/c/K (J.Medhi, 2003;Hisashi Kobayashi, 1978)  The steps taken to create a queueing network are the same as those for a single queueing model: the first is to apply the corresponding NewInput function; then, optionally, the CheckInput function is called, to help with the input parameters of the model, and finally the model is built with the QueueingModel function.
The difference between this and the single node model is that there exist several different functions with which to create the inputs of the network.For example, for a single-class closed Jackson network, there are three ways to create the input, as long as the problem has a probability route or the problem has been defined as operational (Peter J. Denning and Jeffrey P. Buzen, 1978).
For example, imagine the urgent-treatment box of a hospital.Patients arrive at the rate of 10 patients/hour.A doctor examines each patient and may provide treatment and then send the patient home, or derive the patient to a specialist (orthopaedist, cardiologist, etc.), who in turn may request tests (blood analysis, radiography, etc.), and then send the patient home or recommend hospitalisation.In the latter case(assuming there are beds available), treatment will be provided, more checks and tests may be required and, eventually, the patient will leave (not always to go home).
In this case, the model used is a single-class Open Jackson network, with five nodes: general doctor, orthopaedist, cardiologist, checks and tests box (composed of 15 technicians) and hospitalised (with space for any number of patients).Except for visiting the general physician, in no case is a patient allowed to directly enter another node.
queueing also allows multiple classes of patients to be created, although currently only in the operational way (Peter J. Denning and Jeffrey P. Buzen, 1978).
At the hospital, the patients arriving at the urgent-treatment box are usually one of two types: high priority or normal priority.
• classes: number of classes of patients; • vLambda: arrival rate of each class, setting high priority first; • nodes: number of nodes; • vType: except nodes like hospital (no limit to number of beds available), which is "D", the rest are "Q"; • vHigh: average number of visits by each high priority patient to nodes; • vNorm: average number of visits by each normal priority patient to nodes; • vVisit: recall that order consistency must be preserved; • sHigh: average service time in each node for high priority patients; • sNorm: average service time in each node for normal priority patients.
As before, the CheckInput function should be used before building the model with QueueingModel.In this case, the output has more detailed information than in the previous model, as the class performance measures are also included.

Queueing Calculators
The calculators included in queueing are frequently used for sizing call centres, telecomunications systems, etc.
1. Erlang-B.This function is derived from a M/M/c/c model when the c+1 customer arrives when there are c already in the system.2. Erlang-C.This function is frequently used in call centres to correctly set the number of agents.
It denotes the probability of a customer having to queue because all the servers are busy in a M/M/c.3. Engset.When the population is finite, that is, when each new arrival changes the probability of the next arrival, the Engset function gives the probability of an arrival having to return to the source merely because there is no room availabl.This situation is modelled by M/M/c/c/N with c < N.
queueing has been developed to make it easy to learn how the NewInput, CheckInputs and Queue-ingModel models are built.Both basic Markovian models and queueing networks can be built using the same process.
More queue disciplines, together with intermediate and advanced models, will be included progressively in the package to make it even more versatile.
mainly in modelling computer performance, see Edward D. Lazowska et al. (1984)): a.Multiple channel open Jackson networks b.Multiple channel closed Jackson networks c.Single channel multiple class open networks d.Single channel multiple class closed networks e. Single channel multiple class mixed networks

Figure 1 :
Figure 1: M/M/1 Infinite population, single server.Example applicable to service provided at a petrol station

Figure 2 :
Figure 2: Distribution of random variables w and wq.As can be seen, from t=4, both variables has probability of 1

Figure 3 :
Figure3: Evolution of the number of customers in system (L), in queue (Lq) and in queue knowing that queue exists (Lqq).The three functions exhibit a dramatic increase in the number of customers as rho tends to 1. Observe that in general, Lqq > L > Lq

Figure 4 :
Figure 4: Evolution of the mean time in queue and in the system according to lambda and c increase equally.Observe that the time tends to zero as the number of servers increase and M/M/c/K/m are two examples of closed queueing models.For models with more than two stations or with different classes of customers, queueing offers single and multiple channel open and closed Jackson networks, single channel open and closed multiple classes of customers and single channel mixed networks.

Figure 5 :
Figure 5: Probability of not finding an available server as the number of servers increase