Simulation for Queuing System

Here I display an example of a program I wrote to simulate queuing systems. The Windows program was developed in C# and can be downloaded here. The C# code is available on GitHub.

Below you find an explanation of the types of queuing systems the program analyses and how to use the program. This is just a sample program and for a consultancy project the program would be adapted to suit the needs of the client.

Queuing sytems
The program simulates a queuing system. Generically a queue consists of jobs which arrive at random times and require a random processing time. A queuing system consists of a number of queues and a number of workers which process the jobs. Examples are call-centers ( a job is a phone call, processing time is the duration of the call and different queues are created for different types of calls) or traffic on website (different queues for example for downloading files, posting a comment or browsing the Q&A). We assume that workers can handle any job in any queue.

Schematic overview of a queueing system with 3 queues and 5 workers.

Schematic overview of a queueing system with 3 queues and 5 workers.

Prioritizing vs. non-prioritizing simulation program.
Note that there are only a finite number of workers and if a job arrives with all workers busy it experiences a delay. The standard procedure to handle the jobs is by First-Come-First-Serve (FCFS) i.e., the job which arrives first gets served first regardless in which queue it arrived. We call this non-prioritized. Another possibility is to use prioritizing: jobs in Queue 1 are processedbefore any jobs in Queue 2 or higher, jobs in Queue 2 are processed after all the jobs in Queue 1 but before any job in Queue 3 and higher, etc….

The simulation program estimates the expected delay of the jobs for each separate queue when using FCFS in comparison with the expected delay when using priority. Importantly, the program not only produces an estimate but also gives information about the accuracy of the estimate. See the manual below for more information.

Manual
1. The program starts by asking for user input to set up the queuing system. The first step is to select the total number of queues in the queueing system which ranges between 2 and 5 queues. (This cap of 5 queues is artificial, the program can actually handle any number of queues greater than 2.)

Select the number of queues

Select the number of queues

2. Once the number of queues has been chosen we enter all the necessary data for each queue: the average inter-arrival time and processing time. The average inter-arrival time is the average time between the arrival of jobs. The average processing time records the average time it takes a job from a specific queue to be processed. These times are recorded in seconds. (Technical note: It is assumed that the inter-arrival and processing times are exponentially distributed.)

Example when a system with 2 queues is chosen.

Example when a system with 2 queues is chosen.

3. Before starting the simulations enter the total number of runs the program wil use. In this case it means how many jobs the program will generate i.e. 100 runs is equivalent to generating a total number of 100 jobs. When the number of runs is set, start the simulations by pressing the button.

The standard number of simulation runs is set to 10,000.

The standard number of simulation runs is set to 10,000.

4. The program displays the result of the simulation. For each queue it compares the estimate of the expected delay when using FCFS with the estimate for the expected delay when using prioritizing. Importantly it also displays information about the accuracy of the estimate for the expected delay. In fact it displays 95% confidence intervals, i.e., in 95% of the time a random sample will fall into this confidence interval.

To give a specific example consider the figure below. The estimate for the expected delay of a  job in Queue 3 when using priority is approximately 0.2. Furthermore, in 95% of the time the  expected delay will be somewhere between 0.18 and 0.22.

Display of 95% confidence intervals for the waiting times of each queue.

Visualization of 95% confidence intervals for the waiting times of each queue.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s