-
In a single server queue,
- Calling population is infinite; Arrival rate doesn't change.
- Units are served according to FIFO.
- Arrivals are defined by the distribution of the time between arrivals to inter-arrival time.
- Service times are according to a distribution.
- Arrival rate must be less than the service rate (stable stystem), otherwise will grow unbounded (unstable system).
-
Queuing system state
- System
- Server
- Units (in queue or being served)
- Clock
- State of the system
- Number of units in the system
- Status of the server (idle, busy)
- Events
- Arrival of a unit
- Departure of a unit
-
Arrival Event
- If server is idle unit gets service, otherwise unit enters queue for service.
- How do events occur?
- Events occur randomly
-
Departure Event
- If queue is not empty begin servicing next unit, otherwise server will be idle.
The single-server queuing model that will be simulated is as follows:
- The simulation will end when
n = 1000
delays in queue have been completed. - The interarrival and service times will now be modeled as independent random variables from exponential distributions with mean 1 minute for the interarrival times and mean 0.5 minute for the service times. Recall the pdf of an exponential distribution.
- The interarrival and service times are the generated input quantities from the exponential distribution.
The single-server queue with exponential interarrival and service times is commonly called the M/M/1 queue.
To simulate this model, we need a way to generate random variates from an exponential distribution. First, a random-number generator is invoked to generate a variate U that is distributed (continously) uniformly between 0 and 1. This distribution is referred to as U(0, 1)
. Note that the U(0, 1)
distribution is fundamental to simulation modelling because a random variate from any distribution can be generated by first generating one or more U(0, 1)
random variates then performing some kind of transformation.
After obtaining U, we shall take the natural logarithm of it, multiply the result by B(refer to the formula for pdf of an exponential distribution), and finally change the sign to return what we will show to be an exponential random variate with mean B, i.e. -B ln U. (B is the beta sign)
Remember to modularize the program into several subprograms to clarify the logic and interactions.
The simulation program includes a main program, routines for initialization, timing, report generation, and generating exponential random variates. (Refer to the flow chart for the next-event time-advance approach)
The event routines are as follows:
Event description | Event Type |
---|---|
Arrival of a customer to the system | 1 |
Departure of a customer from the system | 2 |
Flowchart for arrival routine
Flowchart for departure routine