Simulating Queuing Models in SAS

Similar documents
Chapter 13. Waiting Lines and Queuing Theory Models

Chapter 14. Waiting Lines and Queuing Theory Models

An-Najah National University Faculty of Engineering Industrial Engineering Department. System Dynamics. Instructor: Eng.

OPERATING SYSTEMS. Systems and Models. CS 3502 Spring Chapter 03

Hamdy A. Taha, OPERATIONS RESEARCH, AN INTRODUCTION, 5 th edition, Maxwell Macmillan International, 1992

Use of Queuing Models in Health Care - PPT

Chapter C Waiting Lines

Chapter III TRANSPORTATION SYSTEM. Tewodros N.

QUEUING THEORY 4.1 INTRODUCTION

PERFORMANCE EVALUATION OF DEPENDENT TWO-STAGE SERVICES

Reducing Customer Waiting Time with New Layout Design

PERFORMANCE MODELING OF AUTOMATED MANUFACTURING SYSTEMS

Banks, Carson, Nelson & Nicol

Queuing Theory: A Case Study to Improve the Quality Services of a Restaurant

Midterm for CpE/EE/PEP 345 Modeling and Simulation Stevens Institute of Technology Fall 2003

Preface. Skill-based routing in multi-skill call centers

Chapter 2 Simulation Examples. Banks, Carson, Nelson & Nicol Discrete-Event System Simulation

Motivating Examples of the Power of Analytical Modeling

Application of queuing theory in construction industry

THE APPLICATION OF QUEUEING MODEL/WAITING LINES IN IMPROVING SERVICE DELIVERING IN NIGERIA S HIGHER INSTITUTIONS

BERTHING PROBLEM OF SHIPS IN CHITTAGONG PORT AND PROPOSAL FOR ITS SOLUTION

APPLICABILITY OF INFORMATION TECHNOLOGIES IN PARKING AREA CAPACITY OPTIMIZATION

Application the Queuing Theory in the Warehouse Optimization Jaroslav Masek, Juraj Camaj, Eva Nedeliakova

STATISTICAL TECHNIQUES. Data Analysis and Modelling

Chapter 1 INTRODUCTION TO SIMULATION

Techniques of Operations Research

Discrete Event Simulation: A comparative study using Empirical Modelling as a new approach.

Abstract. Introduction

4 BUILDING YOUR FIRST MODEL. L4.1 Building Your First Simulation Model. Knowing is not enough; we must apply. Willing is not enough; we must do.

G54SIM (Spring 2016)

Mathematical Modeling and Analysis of Finite Queueing System with Unreliable Single Server

CONTENTS CHAPTER TOPIC PAGE NUMBER

PRACTICE PROBLEM SET Topic 1: Basic Process Analysis

Recent Developments in Vacation Queueing Models : A Short Survey

Numerical investigation of tradeoffs in production-inventory control policies with advance demand information

Asymptotic Analysis of Real-Time Queues

Optimizing Capacity Utilization in Queuing Systems: Parallels with the EOQ Model

Harold s Hot Dog Stand Part I: Deterministic Process Flows

Modeling And Optimization Of Non-Profit Hospital Call Centers With Service Blending

1. For s, a, initialize Q ( s,

Math 29 Probability Final Exam. Saturday December 18, 2-5 pm in Merrill 03

WAYNE STATE UNIVERSITY Department of Industrial and Manufacturing Engineering May, 2010

A BUSINESS COURSE IN SIMULATION MODELING

SAS Enterprise Guide: Point, Click and Run is all that takes

Justifying Simulation. Why use simulation? Accurate Depiction of Reality. Insightful system evaluations

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

MATH 2070 Mixed Practice Sections

Mean and Individual Subject Graphs of Concentration vs. Time Data Using PROC SGPLOT

Explain the needs, goals, and pain points addressed. [The Customer] About. Main Goals. Pain Points

C programming on Waiting Line Systems

Proceedings of the 2012 Winter Simulation Conference C. Laroque, J. Himmelspach, R. Pasupathy, O. Rose, and A.M. Uhrmacher, eds

If you want to flag a question for later review, select the "Mark for review" button.

UNIT - 1 INTRODUCTION:

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

TimeNet - Examples of Extended Deterministic and Stochastic Petri Nets

Intro to O/S Scheduling. Intro to O/S Scheduling (continued)

Ferry Rusgiyarto S3-Student at Civil Engineering Post Graduate Department, ITB, Bandung 40132, Indonesia

OPTIMIZATION AND OPERATIONS RESEARCH Vol. IV - Inventory Models - Waldmann K.-H

Università degli Studi di Roma Tre Dipartimento di Informatica e Automazione. Via della Vasca Navale, Roma, Italy

General Terms Measurement, Performance, Design, Theory. Keywords Dynamic load balancing, Load sharing, Pareto distribution, 1.

Automated Energy Distribution In Smart Grids

Performance evaluation of centralized maintenance workshop by using Queuing Networks

Sven Axsäter. Inventory Control. Third Edition. Springer

Pilot prototype of autonomous pallets and employing Little s law for routing

Lecture 11: CPU Scheduling

CHAPTER 5: DISCRETE PROBABILITY DISTRIBUTIONS

Determining the Maximum Allowable Headway

Resource Allocation Strategies in a 2-level Hierarchical Grid System

Simulation of an Order Picking System in a Pharmaceutical Warehouse

An Adaptive Kanban and Production Capacity Control Mechanism

A Simple, Practical Prioritization Scheme for a Job Shop Processing Multiple Job Types

Use the following headings

Example1: Courseware System Description

Control Charts for Customer Satisfaction Surveys

Story - Shop MyWy self-serve Checkout solution

Cost Optimization for Cloud-Based Engineering Simulation Using ANSYS Enterprise Cloud

Business Process Management - Quantitative

Passenger Batch Arrivals at Elevator Lobbies

PLANNING AND CONTROL FOR A WARRANTY SERVICE FACILITY

SIMULATION ON DEMAND: Using SIMPROCESS in an SOA Environment

Global position system technology to monitoring auto transport in Latvia

PharmaSUG 2016 Paper 36

PreMBA Analytical Primer

Chapter 7 Entity Transfer and Steady-State Statistical Analysis

Project: Simulation of parking lot in Saint-Petersburg Airport

INTRODUCTION TO HOM. The current version of HOM addresses five key competitive advantage drivers

as the algorithm that will be implemented in Asynchronous Transfer Mode ( ATM ) networks.

An EOQ Model For Multi-Item Inventory With Stochastic Demand

IE221: Operations Research Probabilistic Methods

TEACHER NOTES MATH NSPIRED

CELLULAR BASED DISPATCH POLICIES FOR REAL-TIME VEHICLE ROUTING. February 22, Randolph Hall Boontariga Kaseemson

Markov and Non-Markov Models for Brand Switching and Market Share Forecasting

COMPARISON OF BOTTLENECK DETECTION METHODS FOR AGV SYSTEMS. Christoph Roser Masaru Nakano Minoru Tanaka

Principles of Operating Systems

PharmaSUG 2017 Paper 47

KWAME NKRUMAH UNIVERSITY OF SCIENCE AND TECHNOLOGY. Modelling Queuing system in Healthcare centres. A case study of the

All Possible Mixed Model Selection - A User-friendly SAS Macro Application

The Logic of Flow: Some Indispensable Concepts

On Shortcomings of the ns-2 Random Number Generator

Using Excel s Analysis ToolPak Add In

Transcription:

ABSTRACT Simulating Queuing Models in SAS Danny Rithy, California Polytechnic State University, San Luis Obispo, CA This paper introduces users to how to simulate queuing models using SAS. SAS will simulate queuing system in which entities (like customers, patients, cars or email messages) arrive, get served either at a single station or at several stations in turn, might have to wait in one or more queues for service, and then may leave. After the simulation, SAS will give a graphical output as well as statistical analysis of the desired queuing model. INTRODUCTION Queuing is a common occurrence in everyday life. From the customer perspective, we want to be served as quickly as possible. From the company s perspective, we want a smooth process flow so customers do not need stay in the system for an inappropriately long period of time. Unfortunately, businesses have limited resources so they cannot hire many employees or machines to serve all their customers. A standard queuing system is needed in order to balance the needs and desires of both customers and service. To analyze the efficiency of such a system, our approach will be to simulate queuing models. Queuing models are analytical modeling approaches that develop a simulation of the process of the system. In the real world, every service has a system where customers have to go through a process. For example, a grocery store has several checkout lanes so customers pay their groceries and exit once they finished. A patient enters a hospital to receive treatment for an illness and exits the hospital once they have completed acute treatment. There are many components that build each individually unique system. In our grocery store example, we have the grocery cart corral, individual product aisles, front-end purchase centers, registers, and bagging stations. In the hospital example, we have registration, the urgent-care clinic, exam rooms, treatment rooms, discharge, and pharmacy. Any system is always consisted of queues (waiting lines) and service. Queuing theory is usually introduced in stochastic processes, (stochastic) operations research, and discrete event simulation to industrial engineers, operations researchers and statisticians. The math behind these models is based on continuous-time Markov chains, of which will not be covered in this paper. This paper will show how SAS users can simulate queuing models based on real world operations. An alternative approach is to use a discrete event simulation software to point-and-click the component of the system for better visualization and less computation-intense. ARRIVAL, SERVICE AND QUEUE CHARACTERISTICS There are two main characteristics in the queuing models: arrival and service distribution. The arrival distribution describes the customer s arrival into the system. It can be either finite or infinite. The distribution usually follows the Poisson distribution. A customer doesn t always arrive and waits in the queue. Their behavior depends on the number of customers waiting in line. They can be patient, balking (those who do not join a queue due to the long line), and reneging (those who join a queue but leave before being served). The service distribution describes the service time during which a customer is being served. It can be either constant or random. The distribution usually follows an exponential distribution. However, it can be any distribution where mean and variance are known. There are several ways to serve each customer from the queue when the server completes the service of the current customer. First-In First-Out is a common discipline to serve customers on a first-in first-out basis. Last-In First-Out is also a common discipline to serve customers on a last-in first-out basis. Priority occurs when a customer is served based on the importance to complete their service requirement. 1

KENDALL NOTATION Kendall s notation describes and classifies a queuing node, which denotes as A/B/s where: A = The arrival distribution. M represents Markovian which it follows a Poisson distribution. D represents constant or deterministic distribution. G represents a general distribution where mean and variance are known. The Greek letter λ (lambda) represents the arrival distribution. B = The service time distribution. M represents Markovian which it follows an exponential distribution. D represents a constant or deterministic distribution. G represents a general distribution where mean and variance are known. The Greek letter μ (mu) represents the service distribution. s = Number of servers. For example, the M/M/1 is the simplest queuing system where the arrival distribution represents a Poisson distribution, the service distribution represents an exponential distribution and the system has one server. An ATM is a typical example of the M/M/1 queuing system. QUEUE PERFORMANCE By the end of the simulation, we want to know the following questions: How long does each customer being served in the system, on average? What is the probability that there is no customers in the queue? What is the average time that each customer is waiting in the line? How many servers do we need? These questions are typically measure the system performance with the following metrics: W q = Average time that each customer spends in the queue. W = Average time that each customer spends in the system. L q = Average number of customers in the queue. L = Average number of customers in the system. ρ = Utilization factor in the system (e.g probability that all servers are busy). One thing to note is ρ has to between 0 and 1 (the average service rate is greater than the average arrival rate; or λ < μ). This means that the system has too many customers waiting in line than the servers provide. In the long run, the system will be overload. STATISTICAL ANALYSIS OF THE SIMULATION RESULTS In order to understand a system, we need to measure the system performance with the metrics using PROC MEANS. The following statements are PROC MEANS for a specific metric. &system is a macro variable where it contains a dataset of the simulation in a specific queuing system from the DATA step. The following metrics are defined in the DATA step and used in the VAR statement for PROC MEANS: Xt is the number of customers in the system at time t. Lq is the number of customers in the queue at time t. In the DATA step, we define Lq as: Xt 1. This can only calculated if there are greater than one customer in the system, or Xt > 1. Wn is the waiting time in the system for customer nth. Wn_Lq is the waiting time in the queue for customer nth. p is defined as an indicator variable whether there is a customer at time t. To calculate L, we simply specify Xt in the VAR statement. title "Average Number of Customers in the System"; var Xt; ODS OUTPUT Means.Summary = L; 2

To calculate Lq, we specify Lq in the VAR statement. title "Average Number of Customers in the Queue"; var Lq; ODS OUTPUT Means.Summary = Lq; In this statements, we want to take the average of Wn. The WHERE statement takes a subset of each customer leaving the system and more than one customer in the system. This reveals the amount of time each customer spends in the system. title "Average Time in the System"; var Wn; where event = -1 or Xt >= 1; ODS OUTPUT Means.Summary = W; In this statements, we want to take the average of Wn_Lq. The WHERE statement takes a subset only when there are more than one customer in the system. The server can serve only one customer at a time, so any customer who enters the system while the server is busy must wait in line. title "Average Waiting Time in the Queue"; var Wn_Lq; where Lq >= 1 and event = 1; ODS OUTPUT Means.Summary = Wq; To calculate p, again, we specify p in the VAR statement to take the average. title "Average Server Utilization"; var p; ODS OUTPUT Means.Summary = rho; M/M/1 QUEUE Suppose we have a single server in a small grocery store. Customer arrival at the small grocery store holds a Poisson distribution at a mean rate of 15 customers per hour. A server can serve each customer with an exponential distribution at a mean service rate of 20 customers per hour. Display 1 reveals the step plot of the number of customers who stay in the system over time where there is only one server. Depending on the arrival and service rate, the numbers will vary. If the service rate is much higher than the arrival rate, then we expect to see less than two customers in the service line at any given time. However, if the arrival rate is higher than the service rate, then we expect to see the number of customers grow exponentially and at a very fast rate. Display 2 reveals the histogram of number of customers in the system. On average, the server will handle one customer at a time. Table 1 has the summary statistics of the simulation. The average waiting time in the system is 32.4 seconds and the average waiting time in the queue is 25.2 seconds. The server is busy 68% of the time. 3

Display 1. Step Plot of number of customers in the M/M/1 system over time. Display 2. Histogram of number of customers in the M/M/1 system. 4

Table 2. M/M/1 result with performance metrics. M/D/1 QUEUE The M/D/1 system is similar to the M/M/1 system except its service time is deterministic. A car wash is a typical example of the M/D/1 system. Suppose that people arrive at a pizza vending machine at a rate of 15 per hour and follow a Poisson distribution. It takes exactly 3 minutes to cook a pizza for each person through the process of adding ingredients, baking, and putting into a box. In this case, we specify the service rate as 20 per hour. Display 3 reveals the step plot of number of customers stay in the M/D/1 system over time while there is one server. Because the service time is deterministic, each customer leaves the system in 3 minutes. Therefore, the departure time is constant. Display 4 reveals the histogram of number of customers in the M/D/1 system. Table 2 has the summary statistics of the simulation. The average waiting time that each person spends in the queue is 6.09 minutes. The average time that each person spends in the system and receives his pizza is 12.94 minutes. The average time of the system is high due to a lengthy queue during a particular time. Display 3. Step Plot of number of customers in the M/D/1 system over time. 5

Display 4. Histogram of number of customers in the M/D/1 system. Table 2. M/D/1 result with performance metrics. M/G/1 QUEUE The M/G/1 system s service time has the general distribution where mean and variance are known. The distribution can any distribution ranges from binomial to normal. A repair shop is a typical example of the M/G/1 system where the repair time vary around the average. Suppose that cars arrive at an oil change station at a rate of 4 per hour and follow the Poisson distribution. It takes 12 minutes, on average, to change an oil for each car with a variance of 4 minutes. Assume the service time follows the normal distribution. Display 5 reveals the step plot of number of customers stay in the M/G/1 system over time while there is one server. Display 6 reveals the histogram of number of customers in the M/G/1 system. Table 3 has the summary statistics of the simulation. The average waiting time that each person spends in the queue is 25.2 minutes. The average time that each car spends in the system and gets oil change is 29.4 minutes. 6

Display 5. Step Plot of number of customers in the M/G/1 system over time. Display 6. Histogram of number of customers in the M/G/1 system. Table 3. M/G/1 result with performance metrics. 7

FUTURE WORK This paper is a bit more challenging than I expected. Most of the simulation are involved in the DATA steps than anywhere. The average time each customer spends in the system and queue are challenging to get the precise and consistent number compare to the classic performance metric. I will update this paper in future conference proceedings and presentations. Particularly, I plan on adding the M/M/s system to the list of queuing processes. I also acknowledge that there are economics considerations that need to be added (e.g how many servers do we need?) in order for the models to near completeness. Because each queuing model is simple, it is also important to consider the many other variables that occur in real world business modeling. What is the probability that a customer arrives to the system decided not to join because of the lengthy queue? What is the probability that a customer leaves the queue? These metrics are known as balking and reneging, respectively, and require their own consideration in such a study. ACKNOWLEDGMENTS I would like to thank my industrial engineering professors, Dr. Kurt Colvin and Jill Speece, for introducing me to queuing theory. I would like to thank my statistics professor, Dr. Kevin Ross, for teaching stochastic processes at Cal Poly and diving deeper into the theory with mathematical models using continuous-time Markov chains. I would like to thank Deanna Schreiber-Gregory for providing me feedbacks on this paper. Lastly, I would like to thank WUSS and Statistics and Analytics committees for accepting my paper! CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Name: Danny Rithy E-mail: rithy.danny@gmail.com Web: linkedin.com/in/drithy SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 8

/* M/M/1 Queue */ data mm1; * Specify parameters; lambda = 10; * arrival rate ; mu = 20; * service rate ; Source Code * Specify # of jumps for simulation ; Njumps = 50; * Start simulation at time 0 ; Xt = 0; * number of customers in time t; cumsum_wn = 0; * cumsum_wn is the cumulative waiting time for job nth ; p = 0; * 1 if server is busy and 0 otherwise ; output; * Start simulation in a do-until loop until we reach the limit ; do n = 2 to Njumps; t_rexp = rand("exponential") * lambda; /* This if- statement is based on the transition probability matrix and we randomly sample either -1 or 1 */ if rand("uniform") <= mu / (lambda+mu) then event = -1; event = 1; /* If there is no customer in time t, then immediately move the process from 0 to 1 customer according to transition rate matrix */ do; Xt = Xt + 1; cumsum_wn = cumsum_wn + (t_rexp / lambda); p = 0; do; Xt = Xt + event; cumsum_wn = cumsum_wn + (t_rexp / (lambda + mu)); p = 1; output; drop lambda mu mins event hours; data mm1; set mm1; Wn = dif(cumsum_wn); * Take the difference between waiting time of the nth job and (n-1)th job ; * Create a variable called Lq where it measures # of customers waiting in the queue; Lq = 0; Lq = Xt - 1; data mm1; set mm1; 9

Wn_Lq = abs(dif(wn)); * Take the difference between waiting time of the nth job and (n-1)th job in the QUEUE; /* M/D/1 Queue */ data md1; * Specify parameters; D = 20; * Deterministic time ; lambda = 15; * arrival rate ; mu = D; * service rate ; * Specify time for simulation ; Njumps = 50; * Start simulation at time 0 ; Xt = 0; * number of customers in time t; cumsum_wn = 0; * cumsum_wn is the cumulative waiting time for job nth ; p = 0; output; do n = 2 to Njumps; t_rexp = rand("exponential") * lambda; /* This if- statement is based on the transition probability matrix and we randomly sample either -1 or 1 */ if rand("uniform") <= mu / (lambda + mu) then event = -1; event = 1; /* If there is no customer in time t, then immediately move the process from 0 to 1 customer according to transition rate matrix */ do; Xt = Xt + 1; event = 1; cumsum_wn = cumsum_wn + (t_rexp / lambda); do; Xt = Xt + event; if event = -1 then cumsum_wn = cumsum_wn + mu; cumsum_wn = cumsum_wn + (t_rexp / mu + lambda); output; p = 0; p = 1; drop lambda mu n D Njumps; data md1; set md1; Wn = dif(cumsum_wn); * Take the difference between waiting time of the nth job and (n-1)th job ; 10

* Create a variable called Lq where it measures # of customers waiting in the queue ; Lq = 0; Lq = Xt - 1; data md1; set md1; Wn_Lq = abs(dif(wn)); * Take the difference between waiting time of the nth job and (n-1)th job in the QUEUE; /* M/G/1 Queue */ data mg1; * Specify parameters; lambda = 4; * arrival rate ; mu = 15; * service rate ; sd = 2; * Specify time for simulation ; Njumps = 50; * Start simulation at time 0 ; Xt = 0; * number of customers in time t; cumsum_wn = 0; * cumsum_wn is the cumulative waiting time for job nth ; p = 0; output; do n = 2 to Njumps; t_rexp = rand("exponential") * lambda; service_time = rand("normal", mu, sd); /* This if- statement is based on the transition probability matrix and we randomly sample either -1 or 1 */ if rand("uniform") <= mu / (lambda + mu) then event = -1; event = 1; /* If there is no customer in time t, then immediately move the process from 0 to 1 customer according to transition rate matrix */ do; Xt = Xt + 1; event = 1; cumsum_wn = cumsum_wn + (t_rexp / lambda); do; Xt = Xt + event; if event = -1 then cumsum_wn = cumsum_wn + 1/service_time; cumsum_wn = cumsum_wn + (t_rexp / (lambda + mu)); 11

output; p = 0; p = 1; drop lambda mu n Njumps; data mg1; set mg1; Wn = dif(cumsum_wn); * Take the difference between waiting time of the nth job and (n-1)th job ; * Create a variable called Lq where it measures # of customers waiting in the queue ; Lq = 0; Lq = Xt - 1; data mg1; set mg1; Wn_Lq = abs(dif(wn)); * Take the difference between waiting time of the nth job and (n-1)th job in the QUEUE; * Use SAS Macros to generate results from multiple datasets ; %macro queuing_plot(system=); title "Step Plot of Number of Customers in the System Over Time"; proc sgplot data = &system; step x = cumsum_wn y = Xt; xaxis label = "Time (t)"; yaxis label = "X(t)"; title "Histogram of Number of Customers in the System"; proc sgplot data = &system; histogram Xt; xaxis label = "# of Customers"; title "Histogram of Waiting Time in the Queue"; proc sgplot data = &system; histogram Wn / nbins = 10; xaxis label = "Time"; title "Average Number of Customers in the System"; var Xt; ODS OUTPUT Means.Summary = L; 12

title "Average Number of Customers in the Queue"; var Lq; ODS OUTPUT Means.Summary = Lq; title "Average Time in the System"; var Wn; where event = -1 or Xt >= 1; ODS OUTPUT Means.Summary = W; title "Average Waiting Time in the Queue"; var Wn_Lq; where Lq >= 1 and event = 1; ODS OUTPUT Means.Summary = Wq; title "Average Server Utilization"; var p; ODS OUTPUT Means.Summary = rho; %m data op_characteristics; input OP $45.; datalines; Average Number of Customers in the Queue Average Number of Customers in the System Average Waiting Time in the Queue Average Time in the System Average Server Utilization %macro queuing_metrics(system=, title=); data mean; set Lq (rename = (Lq_Mean = Mean)) L (rename = (Xt_Mean = Mean)) Wq (rename = (Wn_Lq_Mean = Mean)) W (rename = (Wn_Mean = Mean)) rho (rename = (p_mean = Mean)); data &system._result; merge op_characteristics mean; ODS PDF FILE = "F:\F-\WUSS 2016\Queuing Theory\&system._result.pdf"; title " &title Result"; proc report data = &system._result nowd style(header) = [background = BIBG font_size = 1 font_weight = bold]; column OP mean; define OP / "Operating Characteristics"; define mean / "Mean" mean format = 5.2; 13

compute OP; if OP IN ("Average Number of Customers in the System", "Average Time in the System") then call define (_row_, 'STYLE','STYLE = [background = BIBG ]'); endcomp; ODS PDF CLOSE; %m 14