Docsity

Simulating Server Utilization & Waiting Times in M/G/1 Queue, Assignments of Statistics

Toggle sidebar
bg1
STA 4821 Homework 6 (The M/G/1 Queue) 40 Points
The following BASIC code simulates the single-server queue with FIFO service. It generates the interarrival
times and the service times for 100,000 customers; and it produces estimates of the server utilization, the
fraction of customers who must wait in the queue, and the average waiting time.
100 FOR i = 1 TO 100000
110 IA = (generate interarrival time)
120 T = T + IA
130 W = W + X – IA
140 IF W < 0 THEN W = 0
150 IF W > 0 THEN c = c + 1
160 SW = SW + W
170 X = (generate service time)
180 SX = SX + X
190 NEXT i
200 PRINT SX/T, c/100000, SW/100000
Adapt the program and run it (using the language of your choice) for four different service-time
distributions: (1) exponential service times, with mean service time E(X) = 0.5
(2) constant service time, X = 0.5
(3) X ~ U(0,1)
(4) P(X=1/3) = 0.9, P(X=2 )= 0.1
Assume that the interarrival times are exponentially distributed with mean value 0.625 (that is, Poisson
arrivals with rate
)61.λ
=
. Fill in the table. For case (1), draw the graph of the theoretical distribution
function of waiting times, F
w
(t); and, on the same axes plot the simulation estimates at the values of t as t
goes from –1 to 12 in increments of 1, and fill in the corresponding table.
Theory for the M/G/1 queue: If
λ
is the arrival rate and X is the service time, then the server utilization is
given by
≥
<
=1)(if1 1)(if XE XE λE(X)
ρλ
λ
The probability that a customer must wait in the queue is
ρ,)P(W
=
>
0
and the mean waiting time is given by the famous Pollaczek-Khintchine formula,
+⋅⋅
−
=)(
)(
1
2
)(
1
)(
2
XE
XVXE
WE
ρ
ρ.
In addition, if the service times are exponentially distributed, and the service is FIFO, then
≥−
<
=
⋅−−
) (tρe
)(t
(t)F
E(X)
t
ρ)(
w
01
00
1
pf2

Partial preview of the text

Download Simulating Server Utilization & Waiting Times in M/G/1 Queue and more Assignments Statistics in PDF only on Docsity!

STA 4821 Homework 6 (The M/G/1 Queue) 40 Points

The following BASIC code simulates the single-server queue with FIFO service. It generates the interarrival times and the service times for 100,000 customers; and it produces estimates of the server utilization, the fraction of customers who must wait in the queue, and the average waiting time.

100 FOR i = 1 TO 100000 110 IA = (generate interarrival time) 120 T = T + IA 130 W = W + X – IA 140 IF W < 0 THEN W = 0 150 IF W > 0 THEN c = c + 1 160 SW = SW + W 170 X = (generate service time) 180 SX = SX + X 190 NEXT i 200 PRINT SX/T, c/100000, SW/

Adapt the program and run it (using the language of your choice) for four different service-time distributions: (1) exponential service times, with mean service time E(X) = 0. (2) constant service time, X = 0. (3) X ~ U(0,1) (4) P(X=1/3) = 0.9, P(X=2 )= 0.

Assume that the interarrival times are exponentially distributed with mean value 0.625 (that is, Poisson arrivals with rate λ = 1_._ 6 ). Fill in the table. For case (1), draw the graph of the theoretical distribution

function of waiting times, Fw(t) ; and, on the same axes plot the simulation estimates at the values of t as t goes from –1 to 12 in increments of 1, and fill in the corresponding table.

Theory for the M/G/1 queue: If λ is the arrival rate and X is the service time, then the server utilization is given by

1 if ( ) 1

if ( ) 1 E X ρ λ E(X) E X λ

λ

The probability that a customer must wait in the queue is

P(W > 0 ) = ρ ,

and the mean waiting time is given by the famous Pollaczek-Khintchine formula ,

E X

E X V X

E W

ρ

ρ .

In addition, if the service times are exponentially distributed, and the service is FIFO, then

ρ e (t )

(t ) Fw (t) ( ρ )E(X)t 1 0

1

There is no simple formula for Fw(t) when the service times are not exponentially distributed. (Therefore, simulation is an important tool for the analysis of queues whose service times have any arbitrary specified distribution of service times; and the theoretical results for the special case of exponential service times are important because they can be used to check the logic and accuracy of the simulation.)

ρ P(W > 0) P(W > 0.5) E(W) X theory simulation theory simulation theory simulation theory simulation 1

2 NA

3 NA

4 NA

Fw(t) t theory simulation

  • 0 1 2 3 4 5 6 7 8 9