Skip to content

miguelrizzog96/Queue_Simulation_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 

Repository files navigation

Discrete Event simulation of a queue using Python.

Written by: Miguel Angel Rizzo Gonzalez

Project Overview:

  • Generated a Simulation model that outputs the performance measures, such as average length, average waiting time, utilization of the system, etc. to provide information for designing or improving service facilities.
  • Showed that using this approach, system changes and different layouts can be tested without actually having to carry them out physically.
  • ***Simulated over 1000 customer arrivals using Python ***

Why Study Queues?

Waiting to be attended is part of daily life. We wait in restaurants, we do a line to board a plane, and we stand in line to be served at official dependencies. The phenomenon of waiting is not limited to human beings: jobs wait to be processed, planes fly in circles at different heights until they are allowed to land, and the cars stop at traffic lights. Deleting the waiting entirely is not a feasible option because the cost of installation and operation of the operation center can be prohibitive. Our only recourse is to search the balance between the cost of offering a service and the cost of waiting for it to be served. Queue analysis is the vehicle to achieve this goal. (Taha,H.)

How does it work?

Consider this Example: A filling station that has two dispensers. Cars arrive about every 5 minutes on average according to a Poisson process. The average time it takes to fill a car is 3 minutes, also a Poisson process. These rates often are actually modeled from actual data to get accurate results. When a car enters the facility, and at least a station is idle, they enter the system. if not they wait in line until a station becomes available, as it can be seen on the following diagram:

Which data do we need?

  • λ: the arrival rate (the expected number of consecutive arrivals per the same unit time, e.g. 1 minute)
  • μ: the service rate (the expected number of consecutive service completions per the same unit time, e.g. 1 minute)
  • the distribution of the data
  • c: the number of servers
  • The number of customers to be simulated

Data Visualization

Here are the distributions of the data and the value counts for other variables like occupation and number of customers in an example model. Below are a few key points of the corresponding system.

Figure 2020-09-17 074636 (1) Figure 2020-09-17 074636 (2) Figure 2020-09-17 074636 (3) Figure 2020-09-17 074636 (4) Figure 2020-09-17 074636

Model Development Steps

Using Python 3.7.6:

Parameters: λ = 1 (Poisson) , μ = 1.5 (Poisson) , c = 1 , n=1000

  • Generated arrival and service times with random number generation using the python library numpy
  • Generated lists and dataframes with conditional statements to represent the events ocurring in the queue
  • Used the generated model for simulating a multiple server queue with n customers

Example Results for c=1

Output:
Time Between Arrivals (minutes): 1.0108
Service Time (minutes): 0.6494
Utilization: 0.6418
Expected wait time in line (Wq) (minutes): 1.5845
Expected number of customers in line (Lq): 1.5673
Expected number of clients in the system (Ls): 2.2092
Expected time spent on the system (Ws) (minutes): 2.2338

For a complete walkthrough, check: Source Code

About

Discrete Event simulation of a queue using Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published