DynamicQueueingNetworks: Simulation,EstimationandPrediction · 2020. 2. 21. ·...

162
Dynamic Queueing Networks: Simulation, Estimation and Prediction Submitted in fulfilment of the requirements for the degree of Doctor of Philosophy Anthony Ebert BEng, MPhil, BSc, BSc (Hons) School of Mathematical Sciences Science and Engineering Faculty Queensland University of Technology 2020

Transcript of DynamicQueueingNetworks: Simulation,EstimationandPrediction · 2020. 2. 21. ·...

  • Dynamic Queueing Networks:Simulation, Estimation and Prediction

    Submitted in fulfilment of the requirements for the degree ofDoctor of Philosophy

    Anthony EbertBEng, MPhil, BSc, BSc (Hons)

    School of Mathematical SciencesScience and Engineering Faculty

    Queensland University of Technology2020

  • ii

    © Copyright 2019 by Anthony Ebert. All rights reserved.

    The work contained in this thesis has not been previously submitted to meetrequirements for an award at this or any other higher education institution. Tothe best of my knowledge and belief, the thesis contains no material previouslypublished or written by another person except where due reference is made.

    Signature:

    Date:

    Git commit: 48a08401842c55276880fbcbe2505e7e3a031b55

    20/02/2020

    QUT Verified Signature

  • Abstract

    This thesis develops statistical tools for simulation, estimation and predictionfor dynamic queueing networks (DQN). DQNs constitute the basis of modelsfor critical systems such as airport terminals, the motivation for this research.Specifically, we consider the problem of modelling passenger flow through theairport terminal. DQNs are currently computationally expensive to simulatefrom and have intractable likelihoods. For these reasons existing tools fordecision support cannot communicate uncertainty associated with predictions;this leads users to distrust these tools. In this thesis, we develop a frameworkwhich makes the simulation, estimation, and, ultimately, prediction of DQNscomputationally feasible.

    The first contribution is the development of a computationally efficient algorithmfor DQN simulation. We developed the queue departure computation (QDC)algorithm for this purpose. This algorithm, as implemented by our R packagequeuecomputer, provides computational speed-ups for queueing simulationof over two orders of magnitude. QDC can simulate any infinite capacityfirst-come-first-serve queue.

    The second contribution pertains to estimation and is enabled by our firstcontribution. DQNs, complex enough to model an airport system, have in-tractable likelihoods. We adopt a likelihood-free method, approximate Bayesiancomputation (ABC), to perform simulation-based parameter inference, basedon real data from an airport terminal. Inference based on ABC requires manymodel realisations, and DQNs have been computationally inefficient to simulatemaking such an approach infeasible, we use the QDC algorithm to overcomethis challenge. This is the first example of DQN parameter inference. ABC usesa distance on the sample space, rather than a likelihood, to assess proposedparameters. The distance we use is maximum mean discrepancy, a metric onprobability measures, which we repurpose as a distance on functional data.

    The third contribution arises from noticing that observations of DQNs frequentlytake the form of functional data. Functional data are often misaligned with oneanother, yet likelihood-free inference techniques which take this misalignmentinto account are not yet developed. We develop the first technique to alignfunctional data, as part of a likelihood-free inference algorithm.

    iii

  • iv

    The methods we develop for parameter inference assume that the parameters arefixed (but unknown). However, some of the parameters governing the behaviourof an airport terminal are likely to change with time. Our final contributionis the development of a likelihood-free algorithm for combined state spaceand fixed parameter inference. Unlike other likelihood-free algorithms forcombined inference, this algorithm automatically calibrates time-indexed tuningparameters, so that inference can be performed with a minimal amount ofcalibration.

  • Keywords

    airports, applied statistics, approximate Bayesian computation, Bayesian statis-tics, curve registration, decision support, discrete event simulation, dynamicqueueing networks, maximum mean discrepancy, passenger facilitation, queueing,queueing network, state space models, statistics, transport hub

    v

  • vi

  • Acknowledgements

    This work was funded through the ARC Linkage Project Scholarship “ImprovingProductivity and Efficiency of Australian Airports - A Real Time Analyticsand Statistical Approach” (LP140100282).

    Thank you to my supervisors: Kerrie Mengersen, Paul Wu and Fabrizio Ruggeri.They have been amazing to work with; this work would not be possible withoutthem.

    Thank you to Antonietta Mira for hosting me at the Università della Svizzeraitaliana, and for her guidance and statistical insight.

    Thank you to the professional staff at ACEMS, especially Cheryle Blair andClaudia Deasy.

    Thank you to Pierre Pudlo, for an ongoing great collaboration.

    Thank you to Kate Helmstedt for being my mentor.

    Thank you to Richard Boys, a brilliant statistician and a friend who we all miss.

    Thank you to everyone at ACEMS and QUT who supported me throughoutthis PhD, especially Leah, Matt, Miles, Amy, Ben, Belinda, Nick, John, Billiand Sam.

    Lastly, special thanks to my family and Claire Gely.

    vii

  • viii

  • Contents

    Abstract iii

    Keywords v

    Acknowledgements vii

    1 Introduction 11.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Aims and objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Research scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4 Thesis structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.5 Publications arising from this thesis . . . . . . . . . . . . . . . . . . . . . . . 7

    2 Literature review 92.1 Queueing systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Queueing networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    2.2.1 Dynamic queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 Simulation methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2.3.1 System dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.3.2 Discrete event simulation . . . . . . . . . . . . . . . . . . . . . . . . . 142.3.3 Stochastic simulation algorithm . . . . . . . . . . . . . . . . . . . . . . 142.3.4 Lindley-type recursive representation . . . . . . . . . . . . . . . . . . . 14

    2.4 Bayesian inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.4.1 Monte Carlo samplers . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.4.2 Approximate Bayesian computation . . . . . . . . . . . . . . . . . . . 182.4.3 Online methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.4.4 Prediction intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    2.5 State space models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.6 Parameter estimation for queueing systems . . . . . . . . . . . . . . . . . . . 23

    2.6.1 Likelihood-based methods . . . . . . . . . . . . . . . . . . . . . . . . . 232.6.2 Likelihood-free methods . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    3 Computationally efficient simulation of queues: the R package queuecom-puter 253.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.2 Queueing theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    ix

  • x CONTENTS

    3.3 Queue departure computation . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.3.1 Fixed number of servers . . . . . . . . . . . . . . . . . . . . . . . . . . 313.3.2 Changing number of servers . . . . . . . . . . . . . . . . . . . . . . . . 323.3.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    3.4 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.6 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    3.6.1 Comparison with simmer and simpy . . . . . . . . . . . . . . . . . . . 373.6.2 Replicate theoretical results for M/M/3 . . . . . . . . . . . . . . . . . 38

    3.7 Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.7.1 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.7.2 Results and discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.8 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.8.1 call centre . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.8.2 International airport terminal . . . . . . . . . . . . . . . . . . . . . . . 44

    3.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    4 Likelihood-free parameter estimation of dynamic queueing networks: casestudy of passenger flow in international airports 534.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.2 Queueing theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.3 Parameter Inference for Dynamic Queueing Networks . . . . . . . . . . . . . 594.4 Approximate Bayesian Computation . . . . . . . . . . . . . . . . . . . . . . . 604.5 Passenger Flow in an International Airport . . . . . . . . . . . . . . . . . . . 62

    4.5.1 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634.5.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674.5.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    4.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    5 Curve registration of functional data for approximate Bayesian computa-tion 775.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795.2 Functional data analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.3 Approximate Bayesian computation . . . . . . . . . . . . . . . . . . . . . . . 815.4 Peak shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    5.4.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835.4.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

    5.5 Passenger processing at an international airport . . . . . . . . . . . . . . . . . 865.5.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865.5.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

    5.6 Hydrological modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885.6.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895.6.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    5.7 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

  • CONTENTS xi

    6 Combined parameter and state inference with automatically calibratedapproximate Bayesian computation 936.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

    6.2.1 State space models and particle filters . . . . . . . . . . . . . . . . . . 966.2.2 Combined parameter and state inference . . . . . . . . . . . . . . . . . 976.2.3 Approximate Bayesian computation . . . . . . . . . . . . . . . . . . . 99

    6.3 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 996.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

    6.4.1 Skewed normal distribution . . . . . . . . . . . . . . . . . . . . . . . . 1036.4.2 Example: Hawkes process . . . . . . . . . . . . . . . . . . . . . . . . . 1046.4.3 Example: Econometric model . . . . . . . . . . . . . . . . . . . . . . . 107

    6.5 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    7 Conclusions and recommendations 1137.1 Research summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1137.2 Limitations and future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    7.2.1 Simulate more types of queueing models . . . . . . . . . . . . . . . . . 1157.2.2 DQN optimisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167.2.3 Scalable combined particle and state inference . . . . . . . . . . . . . 1167.2.4 Reformulate the DQN inference problem . . . . . . . . . . . . . . . . . 1177.2.5 Investigate different ABC distances for parameter inference . . . . . . 117

    7.3 Concluding remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    Bibliography 119

    A Simulation in airport management 135

    B Measure theory 145

    C Supplementary material for Chapter 4 147

  • xii CONTENTS

  • Chapter 1

    Introduction

    1.1 Motivation

    Critical real-world systems, including airports, manufacturing processes andhospitals are modelled with networks of queues. To estimate parameters,restrictive assumptions are typically placed on these models. For instance, aubiquitous assumption is that arrival and service distributions are time-invariant.An approach that removes this constraint is so-called dynamic queueing networks(DQNs), these are more realistic but, because of the complexity of the resultingmodel, do not allow for likelihood-based parameter estimation.

    Our motivating example is passenger flow in airports. In particular, we seek topredict passenger congestion within a terminal conditional on the flight schedule,the staff roster and other information. We want to build tools, which mayin future be used within a decision support app, where predictions are to becontinuously updated in accordance with real-time information such as flightdelays or staff changes.

    Demand for air transport continues to increase rapidly. Between 2009 and2015, air traffic within Australian capital cities grew from 98.1 to 124.9 millionpassengers arriving and departing (IBISWorld, 2016). According to MarketLine(2014), the number of air passengers globally rose from 2.7 billion (2011) to 3.3billion (2015) and is predicted to reach 4.4 billion in 2020. Rising passengernumbers has led to an increase in passenger congestion within airports (Bouweret al., 2015), more flight delays (Deshpande and Arikan, 2012) and capacityconstraints on future growth (Gelhausen et al., 2013).

    There is a simulation study for almost every system within an internationalairport passenger terminal Pyrgiotis et al. (2013); Nikoleris (2011) (Flightdelays); Haghani and Chen (1998); Luts et al. (2014) (Gate assignment); Bosson(2015) (Runway queueing); Barros and Dieke (2007) (Performance Evaluation);Bagler (2008) (Airport Network); Colizza et al. (2006) (Effect of the global

    1

  • 2 CHAPTER 1. INTRODUCTION

    airport network on global epidemics); and Pendergraft et al. (2004) (Securitysystems). Other literature seeks to answer specific questions relevant to theairport operator: Young (1998, 1999) consider passenger walking speeds and usethese to assess the benefit of automated pedestrian movement systems withinthe terminal and Farr et al. (2012) models way-finding by passengers withinairport terminals.

    The processes occurring in the terminal create not only a complex modellingproblem but also a complex statistical problem. Considerable variability existsin these processes due to passenger demographics, flight delays and securityscreening requirements. Even a model with accurate parameter estimatesinevitably produces predictions which deviate somewhat from observations.It is essential to convey not only point estimates and predictions but alsocorresponding assessments of uncertainty so that users continue to trust thetool (Sacha et al., 2016). The Bayesian framework is particularly appropriatehere, as uncertainty arising from sampling variability, parameter uncertaintyand stochasticity are unified under a common framework.

    The literature available, see reviews by Tošić (1992); Wu and Mengersen (2013),focus primarily on the modelling aspect of this problem. The question ofparameter estimation is not addressed. Techniques such as linear regressionare not applicable since the movements of individual passengers cannot beconsidered in isolation (Sutton and Jordan, 2011). Likelihood-based Bayesiantechniques for parameter estimation such as Markov chain Monte Carlo (MCMC)cannot be used since the DQN likelihood is, generally, intractable.

    Likelihood-free techniques for parameter estimation, such as approximateBayesian computation (ABC), were developed for statistical problems wherethe likelihood is intractable (Sisson et al., 2018a). These techniques rely onrepeated simulations from the model, rather than evaluation of the likelihoodfunction. Instead of a likelihood function, ABC uses a distance on the samplespace between observed data and model realisations to perform inference onunknown parameters. Existing queueing system simulation techniques are toocomputationally expensive for this approach to be feasible for DQNs.

    In this thesis, we develop an efficient simulation algorithm for queueing systems,applicable to the form of DQN found in airport terminals, which makes pa-rameter inference through ABC feasible. This algorithm, which we term queuedeparture computation (QDC), is implemented as an R package (queuecom-puter) and provides speed-ups of more than two orders of magnitude comparedto existing approaches to queueing simulation. This is addressed in Chapter 3.

    Furthermore, we leverage the computational speed-up of QDC to develop aparameter inference approach for DQNs applicable to airport terminals. Thisis the first time that parameter inference has been conducted on data arisingfrom a DQN. This is addressed in Chapter 4.

  • CHAPTER 1. INTRODUCTION 3

    One issue, which arose in developing a parameter inference approach for DQNs,relates to how data from a DQN are recorded. Since the behaviour of a DQN,by definition, changes with time, any informative observation of a DQN mustbe a function of time. Therefore, any distance we use on the sample space(space of observations) could be considered as a distance on functions; forinstance, in Chapter 4, we use maximum mean discrepancy. Existing distanceson functions, such as the L2 norm, are robust to observational noise on they-axis, but observational noise on the x-axis can lead to unreasonable distancesuninformative on the parameters of interest Marron et al. (2015). We considerso-called elastic distances (Srivastava et al., 2011), which are robust to both x-axis and y-axis noise and investigate their application to ABC. This is addressedin Chapter 5.

    The methods we develop in Chapter 4 and Chapter 5 assume that parametersare fixed. However, for a highly complex system such as an airport terminal,subject to changing market and regulatory pressures, one would expect thisnot to be the case. As a first step toward developing an inference frameworkfor DQNs, which does not rely on assumptions of fixed parameters, we extendexisting likelihood-based inference procedures to the likelihood-free domain.This is addressed in Chapter 6. We discuss now, the aims and objectives moreformally within the context of our motivating example.

    1.2 Aims and objectives

    The overall aim of this thesis is to develop statistical methods for simulation,estimation and prediction of dynamic queueing networks. We also have anapplied aim, related to our motivating example, which is to help internationalairports manage passenger flows within their terminals to meet objectives suchas waiting times and queue lengths. We use these aims to develop a set ofmethodological and applied objectives for the project which we introduce laterin this chapter. We use a conceptual model (Figure 1.1) to illustrate how weplan to simulate, estimate and predict queues at the immigration counter of aninternational arrivals terminal.

    We describe now, in conceptual terms, the framework of our approach, as aseries of steps represented in Figure 1.1. The flight schedule FS (step 1), whichis known but frequently updated is combined with fixed but unknown inputparameters θI (step 2) which describe passenger behaviour and demographicsto form, in step 3, a list of passenger details (a, s), where a and s denote,respectively, the arrival times to the immigration queue and the time eachpassenger needs with an immigration officer. In step 4, the control parameterθC represents the staffing and resources of the immigration counter. Queuecomputation, in step 5, deterministically transforms the list of passenger details(a, s) and control parameters θC into a set of times when passengers leave the

  • 4 CHAPTER 1. INTRODUCTION

    Figure 1.1: Conceptual model of steps required.

    system d in step 6. The performance measures of the system denoted by Z instep 7 reflect features such as average waiting time, average queue length andresource utilisation. These are computed from the output sequence d, the inputsequence (a, s) and the control parameters θC .

    Simulation methods here refer to the algorithmic component of step 5. Thismust be computationally efficient and modular to allow models to be scaled andadaptable for changing needs. We wish to avoid restrictive assumptions andtherefore make the simulation method applicable to a wide range of realisticqueueing networks. Therefore our first methodological objective is as follows

    M1 Simulate realisations from DQNs where there are complex interdependen-cies, in a modular, reproducible, and computationally efficient manner.

    Simulation, to generate realisations from queueing systems, is itself of a researchtopic of interest (Kin and Chan, 2010; Kiesling and Krieger, 2006). We take afurther step and use simulation to contribute to the overall aim of estimatingparameters. As noted previously, ABC can be used to estimate parameters whererealisations from the model can be simulated. Estimation methods will fit thedistribution of θI based on a known flight schedule FS and control parametersθC by comparing observed departure times dO to simulated departure times d.Our second methodological objective is as follows

    M2 Draw posterior samples of DQN input parameters using observed dataand ABC. Construct prediction intervals for decision support using theseposterior samples.

    Since DQN behaviour changes with time, informative observed data are afunction of time. For this reason, we use distances on functions to compareobserved data and simulated realisations. A common metric for functions is the

  • CHAPTER 1. INTRODUCTION 5

    Lp metric:

    Lp(f, g) =[∫|f(t)− g(t)|pdt

    ]1/p,

    where f and g are functions existing on the same domain and p is some positivereal number. Metrics such as this are useful when the functions are “aligned”,however, if either function is subject to some translation on its domain, thenthis can have a profound effect on any Lp metric. For instance, even though thefunction sin(x) has the same shape as cos(x), their distance in the Lp metric islarge. Therefore, in the context of an ABC algorithm, a model realisation ofthe form cos(x) may be rejected in favour of a seemingly less similar function.

    Regarding the airport data, this issue arose as small deviations in passengerdisembarkation times had a significant effect on observed functional outputs.This behaviour biased our metric in subtle ways. This problem of misalignedfunctions is the subject of a sizeable literature (Marron et al., 2015), commonlytermed curve registration. The techniques of curve registration, however, havenot been extended to the likelihood-free inference framework. With this inmind, our third methodological objective is as follows

    M3 Develop curve registration methods for the likelihood-free inference frame-work.

    The inference procedures, developed in M2 and M3 are batch operations. How-ever, many important phenomena within an airport are dynamic. For instance,when arriving at an airport, passengers from later flights than yours can stillaffect your journey through the terminal. Similarly, the effect of a flight frommany hours ago may still be felt within the terminal even if none of its pas-sengers are still present. To explore these effects, we need to able to performinference on time-varying parameters (states). However, the complexity ofthe simulation developed does not currently allow for the simulation to berun partway and then restarted from a later point of the simulation. Solvingthis problem is equivalent to formulating the DQN system as a state spacemodel. Then we could proceed with state space inference techniques. We areinterested in performing inference for time-indexed parameters (states), jointlywith fixed parameter inference, within a DQN. Likelihood-free techniques havebeen developed for such problems, but they require calibration of time-indexedtuning parameters. Our fourth methodological objective is as follows

    M4 Develop an automatically calibrated likelihood-free state and fixed param-eter inference technique.

    Applied (A) objectives mirror the methodological objectives (M), describedabove. We aim to use the methods developed to provide a practical benefit toan international airport with the following applied objectives:

    A1 Demonstrate that the model developed in M1 can be used to simulate

  • 6 CHAPTER 1. INTRODUCTION

    data that reflect queues in an international airport terminal.

    A2 Estimate parameters for this model using observed data at an internationalairport terminal and methods developed in M1 and M2. Where theseparameters refer to directly observable quantities, such as passengerwalking speeds we will verify these estimates with independent information.

    A3 Demonstrate that curve registration techniques developed in M3 can beapplied to international airport terminals.

    1.3 Research scope

    Queueing theory is an enormous field. It encompasses areas from monitoring(Chen and Zhou, 2015) to game theory (Hassin and Haviv, 2003). This thesisaddresses a specific subspace of this field, of statistical methods which couldfeasibly be applied to modelling airport terminals as a DQN. Aspects of suchan application which are not within the research scope of this thesis includetraditional operations research topics such as optimisation and scheduling;as well as user experience (UX) design and software development questionsgenerally. The scope of this thesis incorporates the development of statisticaland mathematical techniques which will form the basis of such a decision supportapplication.

    1.4 Thesis structure

    This thesis addresses the objectives in the following manner: Chapter 3 addressesM1 and A1; Chapter 4 addresses M2 and A2; Chapter 5 addresses M3 andA3; and Chapter 6 addresses M4.

    Each of the Chapters 3-6 are presented in the format of a journal article. Thisis because they have either been accepted or submitted or are in preparationfor submission. This means that each chapter has a self-contained literaturereview, and some content is repeated. There is an overall bibliography at theend for the entire thesis.

  • CHAPTER 1. INTRODUCTION 7

    1.5 Publications arising from this thesis

    Chapter 3 Ebert, A., Wu, P., Mengersen, K., & Ruggeri, F. (2017). Computationallyefficient simulation of queues: the R package queuecomputer. arXiv:1703.02151.Accepted for publication by the Journal of Statistical Software.

    Chapter 4 Ebert, A., Dutta, R., Mengersen, K., Mira, A., Ruggeri, F., & Wu, P. (2019).Likelihood-free parameter estimation for dynamic queueing networks: casestudy of passenger flow in an international airport terminal. arXiv:1804.02526.Submitted to the Journal of the Royal Statistical Society, Series C.

    Chapter 5 Ebert, A., Mengersen, K., Ruggeri, F., & Wu, P. (2019). Curve registration offunctional data for approximate Bayesian computation. Submitted to PLOSONE.

    Chapter 6 Ebert, A., Pudlo, P., Mengersen, K., & Wu, P. (2019). Likelihood-free inferencefor state space models with sequential sampling. In preparation.

    https://arxiv.org/abs/1703.02151https://arxiv.org/abs/1804.02526

  • 8 CHAPTER 1. INTRODUCTION

  • Chapter 2

    Literature review

    2.1 Queueing systems

    A queueing system can be used to model processes analogous to the queues weencounter in our everyday experience, namely customers waiting in a line tobe served by a server. We say analogy because the term customer could referto: a web-query (Sutton and Jordan, 2011); a patient in a hospital (Takagiet al., 2017); a shipping container in a seaport (Kozan, 1997); an item in amanufacturing system (Dallery and Gershwin, 1992); phone calls (Gans et al.,2003); or even cognitive tasks (Cao, 2013). Similarly, the term server could referto a web-server, medical staff, machinery or a customer service representativeat a call centre. The idea is that each customer i = 1, 2, · · · has an arrival timea = (a1, a2, · · · ) and an amount of time they require with a server, called theservice time s = (s1, s2, · · · ). Typically a server can serve only one customerat a time; a server which is currently serving another customer is said to beunavailable, and a server without a customer is available. If all servers areunavailable when a customer arrives, then customers must wait in the queueuntil a server is available. Detailed introductions to queueing systems can befound in standard texts such as Bhat (2015).

    Queueing systems are classified according to a set of criteria introduced byKendall (1953). A queue is denoted by fδ/fs/K/C/n/R where fδ is the distribu-tion of time between arrivals (inter-arrivals) δi = ai−ai−1; fs is the distributionof service times; K is the number of servers; C is number of customers thatthe system can hold; n is the total number of customers; and R denotes theway that customers in queue are allocated to servers, referred to as the queuediscipline. The most common example of a queueing system has exponential(M) inter-arrival and service times, with one server, an infinite system capacity,infinite number of customers and a first-come-first-serve (FCFS) queue discipline.In the notation of Kendall (1953) this is a M/M/1/∞/∞/FCFS queue, almostalways shortened to M/M/1. The inter-arrival and service times are drawn

    9

  • 10 CHAPTER 2. LITERATURE REVIEW

    independently from exponential processes δ ∼ exp(λ), s ∼ exp(µ), where λ andµ are the rate parameters for each exponential distribution respectively.

    If λ < Kµ, that is, if the rate of arrivals is less than the processing capacityof all servers in the system, then the queueing system reaches a steady state.Early papers on queueing theory derive results which map properties of queuesand parameters such as λ and µ to steady state expectations for performancemeasures of interest. Common performance measures of interest include:

    • N , the number of customers in the system;

    • B, the number of busy servers and

    • w, the customer waiting times.

    Analytic results exist for many such queueing systems, such as the M/M/Kqueueing system where the steady state probability of N customers in thesystem PN is (Thomopoulos, 2012, chapter 6),

    P0 =[

    (Kρ)K

    K!(1− ρ) + 1 +K−1∑i=1

    (Kρ)i

    i!

    ]−1(2.1)

    PN =

    P0(Kρ)nN ! N ≤ K

    P0(Kρ)n

    K!KN−K otherwise, (2.2)

    where ρ = λKµ , is the traffic intensity. Bhat (1969) shows that the time takento reach a steady state is very long for many realistic applications and thattherefore steady state results may not be of practical use in many situations.

    2.2 Queueing networks

    In a network of queueing systems (Jackson, 1957), termed a queueing network(QN), customers transition between queueing systems. After customers finishservice at one queueing system, they are assigned to their next queueing system.New customers may enter from outside the system, and others leave the systementirely. Complex systems such as hospitals (Takagi et al., 2017), web-servers(Sutton and Jordan, 2011) and biomolecular pathways (Ogle and Mather, 2016)can all be modelled as QNs.

    A review of previous works of Bayesian inference for QNs can be found in Armeroand Bayarri (1999). Sutton and Jordan (2011) build a sophisticated GibbsSampler to derive posteriors π[θ|(a,d)] for a tandem QN of type G/G/K/∞/∞.Their technique applies to QNs, where the arrival rate does not vary with time.Furthermore, their sampling algorithm is tailored to a particular data collectionscheme where a and d are observed directly with censoring. If there is anymeasurement error in these observations, it is unclear how the algorithm willperform since the technique relies on proposing unobserved values of s such that

  • CHAPTER 2. LITERATURE REVIEW 11

    the observations are consistent. If there is any model error or contaminatedobservations, there may not be a set s which is consistent with the dataset.

    We describe now the symbolic representation of QNs in diagrams. These symbolsare used to describe networks of queues later (see Appendix A) to model airportterminals. We begin with the symbols for lags and queues (Figure 2.1).

    Figure 2.1: Representation of queueing model.

    The lag and queue symbols relate input to output. In the case of the lag symbola2 = a1 + s1 where a1 and s1 are vectors of length n sampled from somearbitrary distributions with Rn+ support. In the airport terminal (see AppendixA) the lag step represents processing steps where passengers do not affect eachother’s processing times, for example, walking through the arrivals concoursewhere a1 is the time the passenger walked out of the gate, s1 is the time neededto walk to immigration and a2 is the arrival time at immigration. The queuesymbol represents queueing systems, that is, processing steps where passengersuse a limited resource and queue for service, for example, immigration processingwhere passengers queue to be seen by an immigration officer. In this case, d isthe departure process from a queueing system with inputs (a2, s2,K). This isequivalent to d = a2 +w+s2 where w is the waiting time which is a complicatedfunction of (a2, s2,K). A queueing system with infinite servers is equivalent toa lag step since w is always zero.

    The fork/join symbols (Figure 2.2) represent queueing networks whereby jobs(another term for customers) are forked into sub-jobs processed via a differentroute; the job is completed only when the sub-jobs join together again (Kimand Agrawala, 1989; Thomasian, 2015). This arrangement models baggagesystems where passengers and bags are forked into different sub-systems andjoin again at the baggage carousel. Customers and bags can only depart thebaggage carousel area once they have been joined; in other words, the departuretime is the maximum of the customer and bag arrival times.

    The fork/join arrangement is distinct from the partition/merge arrangement(Figure 2.3) considered by Hunt and Foote (1995). This describes a system wheregroups of passengers are partitioned for separate processing and then merged;as is the case in many immigration systems where processing is partitionedaccording to passenger nationality. The arrivals vector a is partitioned into a1

    and a2 and subsequently merged to form d = d1 ∪ d2, where ∪ is the unionoperator.

  • 12 CHAPTER 2. LITERATURE REVIEW

    Figure 2.2: Fork/join arrangement for queueing networks.

    Figure 2.3: Partition/merge arrangement for queueing networks.

    Queueing networks like many other models of complex and dynamic systems suchas ecological systems (Hartig et al., 2011), population genetics (Beaumont, 2010),epidemiology (Drovandi and Pettitt, 2011) and galaxies (Cameron and Pettitt,2012) can often only be understood through simulation. We describe now, themethodologies and software that can be used to simulate airport terminals, see(Wu and Mengersen, 2013; Hernandez-Gonzalez and Manuel Dario, 2018) forcomprehensive reviews of methodologies and software respectively.

    2.2.1 Dynamic queues

    Standard queueing models assume homogeneous (time-invariant) arrival andservice processes. In practice, there is almost always a temporal dependency.Such queueing systems are referred to as dynamic queueing systems. Dynamicqueueing systems find applications in a range of analyses: call centre data(Brown et al., 2005); airport passenger terminals (Wu et al., 2014); and settingstaffing requirements (Green et al., 2007). The notation of queueing theoryhas been adapted to such situations, such as M(t)/M/1 which represents aqueue where the arrivals process is an inhomogeneous Poisson point process,the service process is a homogeneous Poisson process, and there is one server.

    In general, analytic solutions do not exist for dynamic queues (Malone, 1995;

  • CHAPTER 2. LITERATURE REVIEW 13

    Worthington, 2009). Green et al. (1991) showed that using stationary queuesto model dynamic queues leads to serious error even if the deviation fromnon-stationarity is slight. Understanding the long-term and transient behaviourof such queues is achieved with simulation or approximation methods. For anoverview of approximation methods for dynamic queueing systems, see Malone(1995, pg. 27).

    QNs, with varying arrival rates, are termed dynamic queueing networks (DQN)and are commonly used to model queues in airport terminals (Wu et al., 2014),call centres (Brown et al., 2005), and hospitals (Armony et al., 2015). Brownet al. (2005), one of the very few works considering inference on DQNs usesa frequentist parameter inference scheme for a dataset collected from a callcentre where arrival, wait and service times are observed in full, and fδ is aninhomogeneous Poisson process. Once a QN reaches a certain level of complexitythe relationship of the input (arrival and service times) to output (departuretimes) involves temporal dependency structures of unknown duration leadingto intractable likelihoods (Ríos Insua et al., 2012a, Chapter 7), especially wherearrival or service rates change with time as in a DQN.

    2.3 Simulation methodologies

    The correct simulation methodology for a particular system and use-case is anopen question. We describe here briefly four useful methodologies for DQNsimulation.

    2.3.1 System dynamics

    System dynamics (SD) (Forrester, 1997) is a method for simulating systemswith continuous flows, such as those within oil refineries. This is not the casefor queueing networks since one may have two or three customers arrive withinan interval but not 2.5 customers. However, SD can be adapted to queueingnetworks with the simplifying assumption that these flows are continuous. Arelated technique, fluid approximation, also uses this continuous approximation(Liu and Whitt, 2012). The SD approach is adapted to airport simulationby Manataki and Zografos (2009, 2010). Recently Bießlich et al. (2014) usedAnyLogic, a simulation modelling program, to model an airport terminal withSD. Modelling systems whose evolution is inherently discrete with continuousapproximations leaves us unable to describe adequately some aspects of thefluctuations which these systems experience (Gillespie, 1977). Given that oneof our objectives was to construct prediction intervals for decision support, webelieve that this technique is inappropriate for our work.

  • 14 CHAPTER 2. LITERATURE REVIEW

    2.3.2 Discrete event simulation

    Discrete event simulation (DES) is the most common paradigm for simulatingqueues (Ríos Insua et al., 2012a, pg. 226). In DES there is a system state and atime-indexed list of events. At the time of an event, the state and the event listare operated on by the event. For instance, in a queueing system, the event listis made up of arrival events and departure events and the system state is thequeue length. Arrival events create departure events and add one to the queuelength. Departure events take one from the queue length. For more informationabout DES see Nance (1981). DES models overlap with agent-based modelling,which is a simulation methodology where the actions of each agent are simulatedseparately to understand the behaviour of a system as a whole. An agent-basedmodel can be thought of as a type of DES with spatial information; this isuseful where passenger flowlines are important, for instance, when identifyingbottlenecks. A variety of open-source and commercial software is available forDES. Actively maintained open source software packages for DES include theR package simmer (Ucar et al., 2018) and the Python package simpy (Matloff,2008). Commercial software recently applied in literature includes QuadstoneParamics (Cavada et al., 2017) to model a baggage handling system at SantiagoAirport, FlexSim to model security screening (Kierzkowski and Kisiel, 2017),Arena (Kim et al., 2018) to model check-in, and AnyLogic (Cheng et al., 2014)to model airport evacuation.

    2.3.3 Stochastic simulation algorithm

    Gillespie (1977) developed the stochastic simulation algorithm (SSA) to modelthe evolution of chemical reactions. Stochasticity leads the simulation to verydifferent outcomes between experiments, even when initial values and parametersare fixed. This algorithm spawned a rich literature of such techniques (Gillespie,2007). The connection between this literature and that of DES is unclear sinceDES is itself a broad term and SSA is couched in the language of chemicalreaction modelling. Montagna et al. (2015) outline the answer to this questionas they develop an algorithm leveraging advantages of both. The SSA algorithmis flexible in that it can model many types of chemical reactions. However, itcan be computationally expensive for complex systems.

    2.3.4 Lindley-type recursive representation

    To define the operation of a G/G/1 queue, Lindley (1952) proposed the followingequation for computing waiting times:

    wi =

    wi−1 + si−1 − δi if ai < di−10 otherwise (2.3)

  • CHAPTER 2. LITERATURE REVIEW 15

    where wi is the waiting time of customer i. This is equivalent to

    di = max(ai, di−1) + si, (2.4)

    which describes that either, the ith customer must wait for the (i−1)th customerto finish being served, or the server must wait for the ith customer to arrive.We refer to any computation of d from (a, s), inspired by Algorithm 2.3, asLindley-type recursive representations (LRR) to distinguish this approach fromevent-based DES. Chen and Chen (1990) generalise LRR to tandem networksof G/G/1 queues. Hunt and Foote (1995); Vazquez-Avila et al. (2015) did thesame for parallel G/G/1 queues. Vazquez-Avila et al. (2015) noted that theirimplementation of LRR for parallel G/G/1 queueing systems was over oneorder of magnitude faster than the DES software packages OMNeT++ andSimEvents.

    Kiefer and Wolfowitz (1955) presented an algorithm for computing wi for eachcustomer i in a multiserver G/G/K, but it is not considered an LRR since itinvolves a sorting operation for each i. The algorithm was used to define thebehaviour of multiserver queues, which they go on to describe analytically forGI/GI/K queueing systems. The algorithm (not the paper) was, surprisingly,ignored until Krivulin (1994) provided an LRR for G/G/K queueing systems.However, with each new customer i, the algorithm must search a growing i+ 1length vector. The algorithm, therefore, scales poorly, with computationalcomplexity O(n2), where n is the number of customers.

    Kin and Chan (2010) adapted the original algorithm of Kiefer and Wolfowitz(1955) to an O(n) LRR for multiserver tandem queues with blocking, that isG/G/K/C queueing systems where C is the maximum capacity number ofcustomers in the queueing systems. If the maximum capacity C is reachedupstream queueing systems do not process customers until there is spare capac-ity in the queue. Sutton and Jordan (2011) (seemingly unaware of Kiefer andWolfowitz (1955) and Kin and Chan (2010)) presented an equivalent formulationof LRR for G/G/K queues. Kin and Chan (2010) demonstrated the computa-tional efficiency of LRR for G/G/K queueing systems when the algorithms werebenchmarked against existing DES software Arena and SIGMA with speedupsof more than one order of magnitude demonstrated. The work of Kin and Chan(2010) generated little notice, with only three citations to date. Industry andacademia persist in, almost exclusively, using computationally inefficient DESsoftware for modelling queueing networks.

    2.4 Bayesian inference

    The Bayesian methodology for parameter estimation is conceptually simple, saywe wish to infer a parameter value θ with data x. The true but unknown value

  • 16 CHAPTER 2. LITERATURE REVIEW

    of θ is fixed; however, we represent our uncertain knowledge of the true valueof θ, prior to observing x, with the prior distribution π(·).∗

    Our knowledge of θ is updated with x. The probability distribution of xconditional on a hypothetical θ value is f(·|θ), referred to as the likelihood.Our knowledge of θ conditional on observing x is described by the posteriordistribution:

    π(θ|x) = f(x|θ)π(θ)∫f(x|s)π(s)ds

    , (2.5)

    which, if one accepts that π(·) represents (prior to observing x) our knowledgeof θ (Efron, 2013), can be immediately derived from the axioms of probability.This is conceptually simple, however, even with closed-form f(x|·) and π(·), theposterior can be difficult to evaluate. Methods for approximating the posteriorby constructing sampling schemes targeting θ|x are the basis for a rich literaturewithin Bayesian statistics, which we now discuss.

    2.4.1 Monte Carlo samplers

    Monte Carlo† describes a broad range of methods for solving mathematicalproblems using stochastic sampling (Hammersley and Handscomb, 1964). Anyoutput from such a technique is also stochastic, but this stochasticity is managedin such a way that this output or its distribution provides useful information.By the end of World War II, one of the earliest computers, ENIAC, wasdeveloped. Polish scientist Stanislaw Ulam wondered whether ENIAC‡ mightmake probabilistic techniques for solving mathematical and statistical problemsviable. He worked with others including John von Neumann and NicholasMetropolis to develop Monte Carlo methods. These methods were first employedto model neutrons and nuclear fission (Metropolis and Ulam, 1949).

    Two basic Monte Carlo methods for sampling θ from π(·|x) are describedby Smith and Gelfand (1992), rejection sampling and sampling importanceresampling, neither of which are suitable for high-dimensional problems. A moreadvanced technique, called Markov chain Monte Carlo (MCMC) was pioneeredby Metropolis et al. (1953) to simulate chemical systems. Hastings (1970)generalised the technique to problems of stochastic simulation and Gelfand andSmith (1990) popularised the technique for the purposes of Bayesian inference.For detailed accounts of its historical development see Robert and Casella

    ∗Bayesian methods use probability to quantify uncertainty regarding hypotheses. De Finetti(1974) contends that all probability is uncertainty. Gillies (2000) disagrees, arguing thatrandomness and uncertainty are distinct concepts, even if probability is used to describe both.

    †The term, Monte Carlo, was suggested by Nicholas Metropolis with reference to StanislawUlam’s uncle who frequented Monte Carlo Casino in Monaco (Metropolis, 1987).

    ‡Hammersley and Morton (1954) contend that Monte Carlo techniques need not employhigh computing power and describe how the method may be carried out by hand "Indeed,in quite a lot of Monte Carlo work, pen-and-paper is better than machine work". This mayexplain the erstwhile popularity of RAND Corporation (1955).

  • CHAPTER 2. LITERATURE REVIEW 17

    (2011); and Tierney (1994). The MCMC algorithm consists of sampling a chainof parameters θ1, θ2, . . ., in such a way that the chain is ergodic and Markovian,converging to π(·|x) (Mengersen and Tweedie, 1996). First we draw θ1 froma starting distribution q1(·), then we draw proposals from each time step t,conditional on the previous value θt−1 with the transition distribution q(·|θt−1).The algorithm proceedes in the following manner:

    sample θ∗t ∼ q(·|θt−1),

    compute α = min{

    1, π(θ∗t )f(x|θ∗t )

    π(θt−1)f(x|θt−1)× q(θt−1|θ

    ∗t )

    q(θ∗t |θt−1)

    },

    set θt =

    θ∗t with probability α,θt−1 otherwise.For cases where θ is a vector, q(·|θt−1) may represent a draw from the entirevector, a subvector or an individual scalar component (Smith and Roberts, 1993),with acceptance steps repeated over the entire partition of θ. The decision onwhether to update components of θ together or separately can be based on thecorrelation structure of θ, components which are highly correlated should besampled together. Gibbs sampling is a type of MCMC sampling where compo-nent updates are draws from full conditionals, for instance θjt ∼ π(·|θ

    −jt , x),

    where j represents the jth component and θ−jt is the subvector of θt whichexcludes component j. In this case, α is always 1, so the accept-reject step isunnecessary.

    Sequential Monte Carlo (SMC) samplers (Del Moral et al., 2006) providean alternative to MCMC samplers for posterior inference. The idea is totransition N ‘particles’ {θi1|i = 1 : N}, with corresponding normalised weights{W i1|i = 1 : N}, from a starting distribution q1(·), through a sequence oftransient distributions, such that the weighted particles ultimately representa draw from π(·|x). For instance, the sequence of T unnormalised transientdistributions given by {[π(·)f(x|·)]φtq1(·)1−φt |0 = φ1 < · · · < φT = 1} (Neal,2001), or sequential incorporation of data pieces into the posterior {π(·|y1:t)|t ∈1 : T}, where T is the number of data pieces (Chopin, 2002). The distributionsformed by unweighted particles should be as close as possible to the weighteddistribution. A variety of transition densities q(·|θit−1) have been proposed tomove particles between distributions, for instance Sisson et al. (2007) use asimple Gaussian kernel, however the complexity of the unweighted transientdistributions can lead to problems (Del Moral et al., 2006). Drovandi andPettitt (2011) recommend a full MCMC sampler to update particles througheach transient distribution, in this way the unweighted transient distributionsare as close as possible to the weighted transient distributions.

    The SMC transition density q(·|θit−1), as stated previously, may itself representan MCMC sampler. In this case, this embedded MCMC sampler has its owntransition density. A popular choice for this transition density was originally

  • 18 CHAPTER 2. LITERATURE REVIEW

    proposed by Chopin (2002), where a frequentist estimate of the covariance matrixof the previous steps’ particles {θit−1|i = 1 : N} is used within a multivariatenormal density as the MCMC transition density. This idea was preceded bythat of Haario et al. (2001), who used a covariance estimator within the contextof an MCMC sampler, based on all previous values of the chain.

    Over many iterations of the SMC algorithm, the normalised weights can becomedominated by a small number of particles, especially where the transition densityis an importance sampler rather than an MCMC sampler. For this reason,based on criteria (usually effective sample size) computed at each iteration,resampling (or rejuvenation) of particles can be performed intermittently (Liuand Chen, 1995). Resampling refers to the act of weighted sampling withreplacement from the original sample. Once resampling is performed, weightsare reset to 1/N . The purpose of resampling is to eliminate particles with smallweights and thereby improve the computational efficiency of the algorithm.The most straightforward resampling method is simple multinomial samplingwith replacement where a sample is drawn with probabilities proportionalto the weights. Repeated resampling leads to particle degeneracy, where asmall number of the original samples dominate all others. Furthermore, anyestimator loses efficiency when computed from resampled particles (Carpenteret al., 1999a). Alternatives to simple multinomial sampling can mitigate theseproblems (Fearnhead and Clifford, 2003; Li et al., 2015).

    2.4.2 Approximate Bayesian computation

    MCMC and SMC samplers rely on the evaluation of f(x|θ). However, for manycomplex models f(·|θ) is easy to sample directly but difficult or impossibleto evaluate, for instance, the outcome of a game of Solitaire (Metropolis andUlam, 1949) given the skill θ of a player. Intuitively we may think that the bestway to estimate θ, based on observed data x, is to take samples xθ ∼ f(·|θ)with different values of θ until xθ “looks like” x. Indeed it is an establishedresult that if one samples (θ, xθ) from π(·) and f(·|θ) keeping only those θvalues from tuples where xθ = x then this is exactly equivalent to samplingθ directly from π(·|x) (Rubin, 1984). This is the idea behind approximateBayesian computation (ABC).

    Since P (xθ = x) is small, or zero in the case of continuous distributions,other notions are introduced which have the effect of loosening the acceptancecondition. We accept θ with reference to a distance function d and a thresholdε > 0 s.t. θ is accepted when d(xθ, x) < ε. It is not necessary that d is atrue distance on the sample space, the triangle inequality is unnecessary andx=y → d(x, y)=0 must be true, but the converse need not be. Jousselmeand Maupin (2012) call this dissimilarity. In practice d is usually a Euclideandistance on lower dimensional summary statistics S.

  • CHAPTER 2. LITERATURE REVIEW 19

    These two adjustments introduce error such that the sampled distribution of θfrom the ABC procedure πε(·|x) is an approximation to the correct posteriorπ(·|x). If the summary statistics S(xθ) are sufficient statistics for f(·|θ) thenno error is introduced by comparing S(xθ), S(x) rather than xθ, x (Nunes andBalding, 2010). The tolerance ε > 0 introduces a bias in πε(·|x) towards theprior π(·) (Beaumont et al., 2002), however as ε is reduced to zero, the errorintroduced by this adjustment tends to zero (Dean et al., 2014). The approach,as we have so far discussed, is called rejection sampling. It is an inappropriatetool for high dimensional inference problems. More advanced ABC samplers,inspired by the likelihood-based Monte Carlo samplers (Section 2.4.1), havesince been developed.

    Marjoram et al. (2003) developed the ABC approach to MCMC sampling. Thelikelihood term f(·|θ∗t ) appearing within the MCMC sampler (Algorithm 2.6) isapproximated by the indicator function 1ε{xθt} := 1{d(xθt , x) < ε}. Wilkinson(2013) suggests that this 0-1 cut-off be smoothed such that the value decreaseswith distance, for instance with a Gaussian kernel exp[−0.5{d(xθt , x)/σ}2]. Sis-son et al. (2007) develop the SMC ABC sampler. Instead of the increasing powerterm φt, which was used in Section 2.4.1 to define the transient distributions, adecreasing sequence of ε1 > · · · > εT ≥ 0 terms are used to define a sequence ofABC posteriors targeting the final distribution of interest πεT (·|x). As in thecase of the likelihood-based SMC sampler, an MCMC transition density is agood choice for q(·|θit−1). We now need to tune many parameters, such as the εtsequence, and the number of iterations within the MCMC steps. To avoid thisproblem of choosing tuning parameters, Drovandi and Pettitt (2011) developedan enhanced, adaptive SMC ABC sampler termed replenishment ABC.

    Regarding the simulated annealing (Kirkpatrick et al., 1983) literature, Albertet al. (2015) pose the task of developing an efficient ABC sampler in the languageof non-equilibrium thermodynamics. When finding the ground-state of a realsystem, it is essential to cool the sample slowly lest the state of the sample endin a local minimum rather than the true ground state. In physics, transitionsare possible from low to high states even while undergoing cooling; this preventsstate transitions away from local minima. The probability of escaping localminima declines as the temperature is reduced; this is why the cooling processmust be slow. The ABC sampler developed, based on this approach, is calledsimulated annealing ABC (SABC).

    2.4.3 Online methods

    Most methods in statistics process data as a batch, where the analysis isperformed after all data are received. This can be impractical with big dataor where the data arrival rate is high. Online methods process data as itarrives, without referring to or storing previous data. In this way, parametersare updated with arriving data indefinitely with fixed compute and storage

  • 20 CHAPTER 2. LITERATURE REVIEW

    resources.

    Online methods update the statistical output in real-time, applications include:biosurveillance (Fricker Jr and Chang, 2008); computer vision (Oliver et al.,2000); radio astronomy (Michalak et al., 2012); and latent semantic indexing(Canini et al., 2009). A key challenge is that data analysis must keep up withthe arrival of the data (Michalak et al., 2012).

    Stream data refers to data with high velocity, arriving continuously at a fastrate from a dynamic environment (Chen et al., 2002). Many online algorithmsare developed for the analysis of stream data. There are several difficultieswhen dealing with stream data (Caudle and Wegman, 2009), one of which isthat the data arrival rate can exceed the processing rate.

    Fontenla-Romero et al. (2013) provides an overview of commonly used onlinealgorithms within the machine learning paradigm. In each case the set ofparameters θ is updated at each time-point k with new information accordingto the following equation:

    θk ← θk−1 + g(yk, xk)

    where g is a function of the data xk and response yk. Most of these algorithmsare developed with quite restrictive assumptions on the distribution of theincoming data.

    Bayesian approaches to online algorithms allow for a richer set of statisticalsituations (Broderick et al., 2013). In the Bayesian framework it is conceptuallysimple to update parameters with new data. If we consider Bayes’ Law witha dataset which is the realisation of n independent and identically distributedrandom variables: x = (x1, x2, · · · , xn) and a parameter θ we have:

    π(θ|x1:n) =f(x1:n|θ)π(θ)

    f(x1:n)

    =[∏ni=1 π(xi|θ)]π(θ)∫

    [∏ni=1 f(xi|s)]π(s)ds

    If we wish to incorporate a new piece of information xn+1, we can use theposterior π(·|x1:n) as the new prior,

    π(θ|x1:n+1) =f(xn+1|θ)π(θ|x1:n)∫f(xn+1|s)π(s|x1:n)ds

    π(θ|x1:n+1) =

    [∏n+1i=1 f(xi|θ)

    ]π(θ)∫ [∏n+1

    i=1 f(xi|s)]π(s)ds

    .

    While this is conceptually elegant, analytic solutions exist only in special cases

  • CHAPTER 2. LITERATURE REVIEW 21

    and the computational complexity of computing the normalising constant,

    ∫ [n+1∏i=1

    f(xi|s)]π(s)ds,

    grows quickly with the size of the dataset. Approximate methods to computeposteriors must be used, such as MCMC or variational Bayes (VB). See Ormerodand Wand (2010); Broderick et al. (2013) for an introduction to VB. Of thesetwo methods, only VB has been developed into online algorithms for the analysisof Stream Data.

    Sato (2001) developed an online adaptation to VB algorithms. See Šmídland Quinn (2006) for a comprehensive account of online Bayesian methods.Luts et al. (2014) presents several online VB algorithms for semi-parametricregression. Del Moral et al. (2010) has developed an online SMC algorithm forstate space model smoothing.

    We have yet to mention that parameter θ is assumed to be time-invariant, withits distribution in the Bayesian framework representing our uncertainty aboutits true value. However, if we allow the true value of parameter θ to change,then the formulation above is invalid. State space models allow for temporaldependencies; this is important if the behaviour of the queueing network changesover time.

    Online methods for ABC is a relatively unexplored area of research. One of theonly examples in the literature is Ehrlich et al. (2012), where ABC was used toestimate static parameters of a Hidden Markov Model.

    2.4.4 Prediction intervals

    In Bayesian statistics, parameter distributions are often summarised by credi-bility intervals, where a 100(α)% credible interval (L,U) for θ is defined as:

    α =∫ UL

    π(θ)dθ, (2.6)

    where π(θ) may represent a prior or a posterior distribution. In other words,the probability that θ ∈ (L,U) is α. A prediction interval is defined in muchthe same way, except that the distribution of interest is for a random variablerather than a parameter. The prediction interval (L,U) of Z, where Z is somerandom variable with conditional distribution f(Z|θ) is:

    α =∫ UL

    [∫f(Z|θ)π(θ)dθ

    ]dZ. (2.7)

    Once again we may consider π(θ) to be either a prior or a posterior distribution.If we consider Z to be the performance measures of a queueing system as shown

  • 22 CHAPTER 2. LITERATURE REVIEW

    in Figure 1.1, we see that Z is affected by unknown input parameters θI . Z isaffected by both simulation uncertainty and parameter uncertainty.

    2.5 State space models

    If parameters are allowed to change over time then ‘state space’ notation iscustomary rather than ‘regression-notation’ (Särkkä, 2013, pg. 35). We use thesymbol xt, rather than θ, to represent the state of the system at time t. Thestate xt defines the distribution of measurements yt (measurement model) andthe distribution of the next state xt+1 (dynamic model). We use θ to representadditional static parameters in the model. Typically this formulation is usedfor object tracking where the state represents the position of the object and themeasurements are the observations of the position. The state space model isdefined below:

    yt ∼ p(yt|xt, θ),

    xt+1 ∼ p(xt+1|xt, θ),

    x0 ∼ π(x0).

    We are often interested in the posterior distribution of the state. The terminologydepends on the temporal location of the state relative to the observationsit is conditioned on. Smoothing, filtering and prediction refer to posteriordistributions for states xt before, cotemporal to and after the last observedmeasurement yt′ respectively (Särkkä, 2013). The filtering distribution does nottypically have analytic solutions and is therefore approximated with particlefilters (Gordon et al., 1993). Particle filtering is expressible as a form of SMC(Doucet and Johansen, 2009); the transient distributions are {p(x1:t|y1:t)|∀t ∈1 : T}, where T is the time of the final observation. In cases where unknownfixed parameters coexist with state parameters, it is possible to embed a particlefilter within a larger algorithm for the fixed parameters, such as SMC (Chopinet al., 2013) and MCMC (Drovandi et al., 2016). The latter case is termedparticle Markov chain Monte Carlo (PMCMC) (Andrieu et al., 2010).

    ATSB (2015) recreates the path of the flight MH370 from satellite data usinga state space model estimated with a particle filter. At each time step k thestate vector xt is resampled from the distribution p(xt|xt−1). Each path iscalled a particle. The new path is compared to the likelihood p(yt|yt−1, xt), ifthe likelihood is above η the path branches into multiple paths with the samehistory, if the likelihood is below η the path is ended with probability p.

  • CHAPTER 2. LITERATURE REVIEW 23

    2.6 Parameter estimation for queueing systems

    2.6.1 Likelihood-based methods

    To model queueing systems accurately we must use available data to inferthe parameters of fδ and fs. Parameter inference for the simplest queueingsystem,M/M/1 was first considered by Clarke (1957). Clarke derived maximumlikelihood estimates for µ and λ using data collected in a time period from t0until a predefined amount τ of busy time is reached. Busy time is defined astime during which N(t) is greater than zero, therefore τ ≤ (t1 − t0). The datacollected in this time period is as follows:

    • NQ(t0), the number of customers in the queue at time t0;

    • na, the number of customers who arrive;

    • m, the number of customers who depart; and

    • dm, the departure time of the mth customer observed in the time period.

    We refer to the entire data collection as D. The likelihood function derived byClarke (1957) under this data collection scheme is

    L(λ, µ|D) ∝(

    1− λµ

    )e−µτ−λdmµm−NQ(t0)λna+NQ(t0). (2.8)

    This likelihood is used by Muddapur (1972) with the prior distribution

    π(λ, µ) ∝(

    1− λµ

    )e−µτ

    ′−λT ′µm′λn′

    (2.9)

    to derive the posterior joint distribution

    π(λ, µ|D) ∝(

    1− λµ

    )2e−µ(τ+τ

    ′)−λ(dm+T ′)µm+m′λna+n

    ′, (2.10)

    where τ ′, T ′, m′ and n′ are hyper-parameters.

    Another, more simple data collection scheme is used by Armero and Bayarri(1994, 1996) where we observe na inter-arrival times of total length ta =

    ∑nai=1 δi

    and ns service times of total length ts =∑nsi=1 si. The inter-arrival times and

    service times can be observed at any time, simultaneously or otherwise. Theresulting likelihood function in this case is:

    L(λ, µ|D) ∝ e−λta−µtsλnaµns , (2.11)

    which, when combined with a prior distribution can be used to derive π(λ, µ|D).Armero and Bayarri (1994) goes on further to derive predictive distributionsfor performance measures of interest.

  • 24 CHAPTER 2. LITERATURE REVIEW

    It should not be concluded that the data collection scheme of Armero and Bayarri(1994) is to be preferred to that of Clarke (1957), even if it is simpler. Clarke’sdata collection involves observation of the arrival and departure processes,whereas Armero’s data collection involves observation of the arrival and serviceprocesses. It depends on what information can be provided, for web-servers it iseasier to observe a and d (Sutton and Jordan, 2011). If the service process canbe observed directly, then parameter estimation for theM/M/1 queueing systemis equivalent to parameter estimation for two independent Poisson processes.

    The likelihood for a M/M/K queueing system was derived by Wolff (1965); itrequires complete knowledge of the system step function N(t) over the samplingperiod (0, T ). Posterior distributions have also been derived for G/M/1 andM/G/1 queueing systems.

    Sutton and Jordan (2011) built a sophisticated MCMC sampler to deriveposterior distributions π(θ|(a,d)) for tandem, partition/merge networks ofGI/GI/K/∞/∞ queueing systems. Particular attention is paid to missing dataproblems in observations of arrival and departure processes. Perez et al. (2017)and Perez and Casale (2018) develop an alternative approach to Sutton andJordan (2011) based on variational approximations (Ormerod and Wand, 2010).

    It is often the case that d is observed by (a, s) are not (Goeva et al., 2016;Heggland and Frigessi, 2004). We must rely on likelihood-free methods suchas: Moment matching (Goeva et al., 2016); indirect inference (Heggland andFrigessi, 2004); and ABC (Blum and François, 2010).

    2.6.2 Likelihood-free methods

    There are few examples of likelihood-free methods used for inference of queueingsystems. Heggland and Frigessi (2004) use indirect inference to estimate θI givenonly departure times. Blum and François (2010) revisits Heggland and Frigessi(2004)’s scenario with a non-linear regression model for ABC. The same G/M/1queue is used by Fearnhead and Prangle (2012) to demonstrate their semi-automatic ABC approach. The potential for ABC to model queueing systemsis yet to be fully realised. If it were possible to sample a and d given inputparameters θI and known, fixed control parameters θC in a computationallyefficient manner, then ABC inference for complex queueing networks could befeasible.

  • Chapter 3

    Computationally efficient simulation ofqueues: the R package queuecomputer

    Abstract

    Large networks of queueing systems model important real-world systems such asMapReduce clusters, web-servers, hospitals, call centres and airport passengerterminals. To model such systems accurately, we must infer queueing parametersfrom data. Unfortunately, for many queueing networks, there is no clearway to proceed with parameter inference from data. Approximate Bayesiancomputation could offer a straightforward way to infer parameters for suchnetworks if we could simulate data quickly enough.

    We present a computationally efficient method for simulating from a very generalset of queueing networks with the R package queuecomputer. Remarkablespeedups of more than 2 orders of magnitude are observed relative to the popularDES packages simmer and simpy. We replicate output from these packages tovalidate the package.

    The package is modular and integrates well with the popular R package dplyr.Complex queueing networks with tandem, parallel and fork/join topologies caneasily be built with these two packages together. We show how to use thispackage with two examples: a call centre and an airport terminal.

    25

  • Statement for authorship

    This chapter has been written as a journal article. The authors listed below have certified that:

    1. they meet the criteria for authorship as they have participated in the conception, execution or interpretation of at leastthe part of the publication in their field of expertise;

    2. they take public responsibility for their part of the publication, except for the responsible author who accepts overallresponsibility for the publication;

    3. there are no other authors of the publication according to these criteria;

    4. potential conflicts of interest have been disclosed to granting bodies, the editor or publisher of the journals of otherpublications and the head of the responsible academic unit; and

    5. they agree to the use of the publication in the student’s thesis and its publication on QUT’s ePrints site consistent withany limitations set by publisher requirements.

    The reference for the publication associated with this chapter is:Ebert, A., Wu, P., Mengersen, K., & Ruggeri, F. (2017). Computationally efficient simulation of queues: theR package queuecomputer. arXiv:1703.02151. Accepted for publication by the Journal of Statistical Software.

    Contributor Statement of contributionAnthony Ebert Developed and implemented the algorithm, wrote the manuscript.

    Signature and date:

    Paul Wu Provided guidance with regards to the software implementation, critically re-viewed the manuscript.

    Kerrie Mengersen Initiated the concept of the manuscript, critically reviewed the manuscript.Fabrizio Ruggeri Provided expertise with regard to queues and queueing theory, critically re-

    viewed the manuscript.

    Principal Supervisor Confirmation

    I have sighted email or other correspondence from all co-authors confirming their certifying authorship. (Ifthe co-authors are not able to sign the form please forward their email or other correspondence confirmingthe certifying authorship to the RSC).

    Name Signature Date

    Prof. Kerrie Mengersen18/02/2020

    18/02/2020

    26 CHAPTER 3. THE R PACKAGE QUEUECOMPUTER

  • CHAPTER 3. THE R PACKAGE QUEUECOMPUTER 27

    3.1 Introduction

    The queues we encounter in our everyday experience, where customers wait inline to be served by a server, are a useful analogy for many other processes.We say analogy because the word customers could represent: MapReducejobs (Lin et al., 2013); patients in a hospital (Takagi et al., 2017); items ina manufacturing system (Dallery and Gershwin, 1992); calls to a call centre(Gans et al., 2003); shipping containers in a seaport (Kozan, 1997) or evencognitive tasks (Cao, 2013). Similarly, server could represent: a computecluster; medical staff; machinery or a customer service representative at a callcentre. Queueing systems can also be networked together to form queueingnetworks. We can use queueing networks to build models of processes such asprovision of internet services (Sutton and Jordan, 2011), passenger facilitationat international airports (Wu and Mengersen, 2013) and emergency evacuations(Van Woensel and Vandaele, 2007). Clearly queueing systems and queueingnetworks are useful for understanding important real-world systems.

    Performance measures for a given queueing system can often only be derivedthrough simulation. Queues are usually simulated with discrete event simulation(DES) (Ríos Insua et al., 2012a, pg. 226). In DES changes in state are discon-tinuous. The state is acted upon by a countable list of events at certain timeswhich cause the discontinuities. If the occurrence of an event is independent ofeverything except simulation time, it is determined; otherwise, it is contingent(Nance, 1981).

    Popular DES software packages are available in many programming languagesincluding: the R package simmer (Ucar et al., 2018), the Python (Van Rossumand Drake, 2014) package simpy (Lünsdorf and Scherfke, 2013) and the Java(Gosling, 2000) package JMT (Bertoli et al., 2009). DES packages are often soexpressive that they can be considered languages in their own right, indeed theprogramming language Simula (Dahl and Nygaard, 1966) is a literal example ofthis.

    queuecomputer (Ebert, 2016) implements an algorithm that can easily beapplied to a wide range of queueing systems and networks of queueing systems.It is vastly more computationally efficient than existing approaches to DES. Weterm this new computationally efficient algorithm queue departure computation(QDC). Computational efficiency is important because if we can simulate fromqueues quickly, then we can embed a queue simulation within an approximateBayesian computation (ABC) algorithm (Sunnåker et al., 2013) and estimatequeue parameters for very complicated queueing models in a straightforwardmanner.

    In Section 3.2 we review the literature on queueing theory and develop notationused throughout this paper. In Section 3.3, we present the QDC algorithm andcompare it to DES. We demonstrate how to use the package in Section 3.4.

  • 28 CHAPTER 3. THE R PACKAGE QUEUECOMPUTER

    Details of implementation and usage are discussed in Section 3.5. The packageis validated in Section 3.6 by replicating results from DES packages simpy andsimmer. We compare computed performance measures from the output of aqueuecomputer simulation to theoretical results for M/M/2 queueing systems.We benchmark the package in Section 3.7 and compare computation time withsimpy and simmer. Examples in Section 3.8 are used to demonstrate how thepackage can be used to simulate a call centre and an international airportterminal.

    3.2 Queueing theory

    Queueing theory is the study of queueing systems and originated from the workof Agner Krarup Erlang in 1909 to plan infrastructure requirements for theDanish telephone system (Thomopoulos, 2012, pg 2).

    A queueing system is defined as follows. Each customer i = 1, 2, · · · has anarrival time ai (or equivalently an inter-arrival time δi = ai − ai−1, a0 = 0)and an amount of time they require with a server, called the service time si.Typically a server can serve only one customer at a time. A server which iscurrently serving another customer is said to be unavailable, a server withouta customer is available. If all servers are unavailable when a customer arrivesthen customers must wait in the queue until a server is available. Detailedintroductions to queueing systems can be found in standard texts such as Bhat(2015).

    The characteristics of a queueing system are expressed with the notation ofKendall (1953). This notation has since been extended to six characteristics:

    • fδ, inter-arrival distribution;

    • fs, service distribution;

    • K, number of servers ∈ N;

    • C, capacity of system ∈ N;

    • n, customer population ∈ N; and

    • R, service discipline

    Choices for inter-arrival and service distributions are denoted by “M” forexponential and independently distributed, “GI” for general and independentlydistributed and “G” for general without the independence assumption. Thecapacity of the system C refers to the maximum number of customers withinthe system at any one time∗. Customers are within the system if they arebeing served or waiting in the queue. The customer population n is the total

    ∗If the system is at full capacity and new customers arrive, new customers leave the systemimmediately without being served.

  • CHAPTER 3. THE R PACKAGE QUEUECOMPUTER 29

    number of customers, including those outside of the system (yet to arrive oralready departed). The service discipline R defines how customers in the queueare allocated to available servers. The most common service discipline is firstcome first serve (FCFS). To specify a queueing system, these characteristics areplaced in the order given above and separated by a forward slash “/".

    The simplest queueing system is exponential in distribution for both the inter-arrival δi

    iid∼ exp(λ) ∀i ∈ 1 : n and service processes siiid∼ exp(µ) ∀i ∈ 1 : n,

    where λ and µ are exponential rate parameters. Additionally, K is set to 1,C and n are infinite, and R is FCFS. It is denoted by M/M/1/∞/∞/FCFS,which is shortened to M/M/1.

    Parameter inference for this system was considered first by Clarke (1957),estimators were derived from the likelihood function. This likelihood is laterused by Muddapur (1972) to derive the joint posterior distribution. Bayesianinference for queueing systems is summarised in detail by Ríos Insua et al.(2012a).

    Managers and planners are less interested in parameter inference and more inter-ested in performance measures such as: N(t), the number of customers in systemat time t; B̄, the average number of busy servers; ρ, the resource utilization;and w̄, the average waiting time for customers. If λ < Kµ, the queueing systemwill eventually reach equilibrium and distributions of performance measuresbecome independent of time.

    In the case of a M/M/K system equilibrium distributions for performancemeasures are derived analytically, they are found in standard queueing theorytextbooks (Lipsky, 2008; Thomopoulos, 2012). For instance, the limit probabilityof N customers in the system P(N) is

    P(0) =[

    (Kρ)K

    K!(1− ρ) + 1 +K−1∑i=1

    (Kρ)i

    i!

    ]−1

    P(N) =

    P(0)(Kρ)nN ! N ≤ K

    P(0) (Kρ)n

    K!KN−K otherwise(3.1)

    where ρ, the resource utilization, is defined as λKµ . For a M/M/K system, thisis equal to the expected number of busy servers divided by the total number ofservers E(B)K (Cassandras and Lafortune, 2009, pg. 451). The expected numberof customers in the system is (Bhat, 2015)

    E(N) = Kρ+ ρ(Kρ)KP (0)

    K!(1− ρ)2 , (3.2)

  • 30 CHAPTER 3. THE R PACKAGE QUEUECOMPUTER

    and the expected waiting time is

    E(w) = (Kρ)KP (0)

    K!Kµ(1− ρ)2 . (3.3)

    If the parameters of fδ and fs are uncertain, then we must turn to predictivedistributions for estimates of performance measures, which are computed ana-lytically for M/M/K queues (Equations 3.2 and 3.3). Predictive distributionsof performance measures using Bayesian posterior distributions are derived byArmero (1994); Armero and Bayarri (1999).

    Jackson (1957) was one of the first to consider networks of queueing systems.In a Jackson network, there is a set of J queueing systems. After a customer isserved by queueing system j, they arrive at another queueing system with fixedprobability pj,k. Customers leave the system with probability 1 −

    ∑Jk=1 pj,k.

    Other examples of queueing networks include the tandem (Glynn and Whitt,1991), parallel (Hunt and Foote, 1995) and the fork/join (Kim and Agrawala,1989) topologies.

    In a tandem queueing network, customers traverse an ordered series of queuesbefore departing the system. Real examples of such systems include airportterminals, internet services and manufacturing systems. In a parallel network,customers are partitioned into different (a, s) to be seen by separate queueingsystems. In a fork/join network a task (another term for customer) is forkedinto a number of subtasks which are to be completed by distinct parallel servers.The difference from the parallel network is that the task can only depart thesystem once all subtasks have arrived at the join point.

    Most models of queueing systems assume time-invariant inter-arrival and serviceprocesses. In practice, many real-world queues have inter-arrival processeswhich are strongly time-dependent, such as: call centres (Weinberg et al., 2007;Brown et al., 2005), airport runways (Koopman, 1972) and hospitals (Brahimiand Worthington, 1991). In the case of the M/M/1 queue, we can adapt thenotation to M(t)/M(t)/1 to represent exponential processes where parametersλ(t) and µ(t) change with time. Such queueing systems are referred to asdynamic queueing systems.

    In general, analytic solutions do not exist for dynamic queueing systems (Malone,1995; Worthington, 2009). Green et al. (1991) showed that using stationaryqueueing systems to model dynamic queueing systems leads to serious erroreven if the deviation from stationarity is slight. The problem is compoundedonce we consider queueing networks. Understanding long-term and transientbehaviour of such queues can only be achieved with approximation methodsor simulation. We now detail the QDC algorithm, a computationally efficientmethod for simulating queueing systems.

  • CHAPTER 3. THE R PACKAGE QUEUECOMPUTER 31

    3.3 Queue departure computation

    3.3.1 Fixed number of servers

    QDC can be considered as a multiserver extension to an algorithm presentedby Lindley (1952). For a single server queueing system, the departure time ofthe ith customer is: di = max (ai, di−1) + si, since the customer either waitsfor a server or the server waits for a customer. The algorithm (not the paper)was, surprisingly, not extended to multiserver systems until Krivulin (1994).However, with each new customer i the algorithm must search a growing i+ 1length vector. This algorithm, therefore, scales poorly, with computationalcomplexity O(n2), where n is number of customers. Kin and Chan (2010)adapted the original algorithm of Kiefer and Wolfowitz (1955) to an O(nK)algorithm for multiserver tandem queues with blocking, that is G/G/K/Cqueueing systems where C is the maximum capacity number of customers inthe queueing systems.

    QDC can also be viewed as a computationally efficient solution to the set ofequations presented in Sutton and Jordan (2011, pg. 259) for FCFS queueingsystems. There is a single queue served by a fixed number of K servers. Theith customer observes a set of times bi = {bik|k ∈ 1 : K} which representsthe times when each server will next be available. The customer i selects theearliest available server pi = argmin(bi) from bi. The departure time for theith customer is, therefore, di = max(ai, bpi) + si, since the server must wait forthe customer or the customer must wait for the server. The QDC algorithmfor a fixed number of servers (Algorithm 1) pre-sorts the arrival times. Ratherthan assigning a bi for each customer i to form the matrix b ∈Mn×K , QDCconsiders b as a continually updated K length vector representing the state ofthe system.

    Algorithm 1 QDC for fixed K1: function QDC_numeric(a ∈ Rn+, s ∈ Rn+,K ∈ N)2: Sort (a, s) in terms of a (ascending)3: Create vector p ∈ Nn.4: Create vector b ∈ RK+ .5: Create vector d ∈ Rn+.6: bk ← 0 ∀k ∈ 1 : K7: for i ∈ 1 : n do8: pi ← arg min(b)9: bpi ← max(ai, bpi) + si

    10: di ← bpi11: end for12: Put (a,d,p) back to original (input) ordering of a13: return (d,p)14: end function

    This algorithm is simple and computationally efficient. At each iteration of the

  • 32 CHAPTER 3. THE R PACKAGE QUEUECOMPUTER

    loop, we need only search b, a K length vector for the minimum element incode line 8. In the language of DES, we consider b as the system state and a asthe event list, which are all determined events. This differs from conventionalDES approaches to modelling queueing systems where the queue length is thesystem state, and both a and d constitute the event list, where the events ofa are determined and the events of d are continually updated and thereforecontingent.

    Algorithm 1 can simulate any queue of the form G(t)/G(t)/K/∞/n/FCFSwhere K and n can be made arbitrarily large. Furthermore, the inter-arrivaland service distributions can be of a completely general form and even have adependency structure between them. Since the arrival and service times aresupplied by the user rather than sampled in-situ, the algorithm “decouples"statistical sampling from queue computation. This frees the user to simulatequeues of arbitrarily complex fδ,s, where K is fixed.

    3.3.2 Changing number of servers

    3.3.2.1 Conditional case

    Suppose that the number of servers that customers can use changes throughoutthe day. This reflects realistic situations where more servers are rostered on forbusier times of the day. We say that for a certain time t, the customers have achoice of K(t) open servers from K. This means that there are K(t) serversrostered-on for time t. We define the term closed as the opposite of open.

    We represent the number of open servers throughout the day as a step function.Time is on the positive real number line and is partitioned by L knot locationsx = (x1, · · · , xL) ∈ RL+ into L + 1 epochs (0, x1], (x1, x2], · · · , (xL,∞). Thenumber of open servers in each epoch is represented by a L+ 1 length vectory = (y1, · · · , yL+1) ∈ NL+10 . If we assume that none of the service times s spanthe length of more than one epoch (xl, xl+1], formally

    ∀i [si < min(xl+1 − xl|l ∈ 1 : L)] , (3.4)

    then we need to consider a change in state over at most one knot location.This step function is determined input by the user. Like the arrival and servicetimes (a, s) it is changeable by the user before the simulation but not duringthe simulation.

    We close server k by writing an ∞ symbol to bk ensuring that no customer canuse that server. If the server needs to be open again at time t, we write t to bkallowing customers to use that server. Since x now corresponds to changes in b,

  • CHAPTER 3. THE R PACKAGE QUEUECOMPUTER 33

    it is part of the event list along with a. The entire event list is still determinedand need not be updated mid-simulation.

    Algorithm 2 QDC for K(t) (conditional)1: function QDC_server.stepfun(a ∈ Rn+, s ∈ Rn+, x ∈ RL+, y ∈ N

    L+10 )

    2: Sort (a, s) in terms of a (ascending)3: xL+1 ←∞4: yL+2 ← 15: K ← max(y)6: Create vector b ∈ RK+ .7: bk ←∞ ∀k ∈ 1 : K8: bk ← 0 ∀k ∈ 1 : y09: Create vector p ∈ Nn.

    10: Create vector d ∈ Rn+.11: l← 112: p1 ← 113: for i ∈ 1 : n do14:15: // Adjustments to b with change in epoch16: if ∀k ∈ 1 : K [bk ≥ xl+1] OR ai ≥ xl+1 then17: if yl+1 − yl > 0 then18: for k ∈ (yl + 1 : yl+1) do19: bk ← xl+120: end for21: end if22: if yl+1 − yl < 0 then23: for k ∈ (yl+1 + 1 : yl) do24: bk ←∞25: end for26: end if27: l← l + 128: end if29: // End of adjustments to b with change in epoch30:31: pi ← arg min(b)32: bpi ← max(ai, bpi ) + si33: di ← bpi34:35: // Extra loop if current size is zero so that customer i can be processed in next

    epoch36: if yl = 0 then37: i← i− 138: end if39:40: end for41: Put (a, d, p) back to original (input) ordering of a42: return (d, p)43: end function

    This algorithm can simulate queues of the form G(t)/G(t)/K(t)/∞/n/FCFS,where K(t) refers t