Académique Documents
Professionnel Documents
Culture Documents
2: A SingleServer Queue
Discrete-Event Simulation: A First Course
c 2006 Pearson Ed., Inc. 0-13-142917-5
1/ 30
arrivals
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
queue
service node
. . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
server
departures
A single-server service node consists of a server plus its queue If there is only one service technician, the machine shop model from section 1.1 is a single-server queue
2/ 30
Queue Discipline
Queue discipline: the algorithm used when a job is selected from the queue to enter service FIFO rst in, rst out LIFO last in, rst out SIRO serve in random order Priority typically shortest job rst (SJF)
3/ 30
Assumptions
Service is non-preemptive
Once initiated, service of a job will continue until completion
Service is conservative
Server will never remain idle if there is one or more jobs in the service node
4/ 30
Specication Model
For a job i : The arrival time is ai The delay in the queue is di The time that service begins is bi = ai + di The service time is si The wait in the node is wi = di + si The departure time is ci = ai + wi
wi di si
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
time
ai
bi
ci
5/ 30
Arrivals
time
ai2
ai1
ai
ai+1
6/ 30
Algorithmic Question
Given the arrival times and service times, can the delay times be computed? For some queue disciplines, this question is dicult to answer If the queue discipline is FIFO,
di is determined by when ai occurs relative to ci 1 .
7/ 30
Cases
ci bi si | di | ri | |
ai
ai
ci
si | ri | |
8/ 30
9/ 30
Example 1.2.2
10/ 30
Output Statistics
The purpose of simulation is insight gained by looking at statistics The importance of various statistics varies on perspective:
Job perspective: wait time is most important Manager perspective: utilization is critical
11/ 30
Job-Averaged Statistics
Job-averaged statistics: computed via typical arithmetic mean Average interarrival time: 1 r= n
1/r is the arrival rate
n
ri =
i =1
an n
1 n
si
i =1
12/ 30
Example 1.2.3
The server is not quite able to process jobs at the rate they arrive on average.
13/ 30
Job-Averaged Statistics
di
i =1
1 w= n
wi
i =1
w=
wi =
i =1
1 n
(di + si ) =
i =1
1 n
di +
i =1
1 n
si = d + s
i =1
14/ 30
Example 1.2.4
From the data in Example 1.2.2, d = 26.7 From Example 1.2.3, s = 34.7 Therefore w = 26.7 + 34.7 = 61.4. Recall verication is one (dicult) step of model development Consistency check: used to verify that a simulation satises known equations
Compute w , d , and s independently Then verify that w = d + s
15/ 30
Time-Averaged Statistics
Time-averaged statistics: dened by area under a curve (integration) For SSQ, need three additional functions
l (t ): number of jobs in the service node at time t q (t ): number of jobs in the queue at time t x (t ): number of jobs in service at time t
By denition, l (t ) = q (t ) + x (t ). l (t ) = 0, 1, 2, . . . q (t ) = 0, 1, 2, . . . x (t ) = 0, 1
16/ 30
Time-Averaged Statistics
376
17/ 30
Time-Averaged Statistics
Over the time interval (0, ): 1 1 time-averaged number in the queue: q = 1 time-averaged number in service: x = time-averaged number in the node: l = Since l (t ) = q (t ) + x (t ) for all t > 0 l =q+x
Sucient to calculate any two of l, q , x
l (t )dt
0
q (t )dt
0
x (t )dt
0
18/ 30
Example 1.2.5
The average of numerous random observations (samples) of the number in the service node should be close to l .
Same holds for q and x
19/ 30
Littles Theorem
How are job-averaged and time-average statistics related? Theorem (Little, 1961) If (a) queue discipline is FIFO, (b) service node capacity is innite, and (c) server is idle both at t = 0 and t = cn then
cn 0 cn 0 cn 0
n i =1 wi n i =1 di n i =1 si
and and
20/ 30
i (t )
0 < t < cn
and so
cn cn n n cn n n
l (t )dt =
0 0 i =1
i (t )dt =
i =1 0
i (t )dt =
i =1
(ci ai ) =
i =1
wi
Example 1.2.6
10 9 8 7 6 5 4 3 2 1 0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 ........... . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . .. . .. . . 9 .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 .................... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 ........................... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 ..................... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 4 .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 ............. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
376
376
10
l (t )dt =
0
Discrete-Event Simulation: A First Course
wi = 614
i =1
22/ 30
Littles Equations
Using = cn in the denition of the time-averaged statistics, along with Littles Theorem, we have
cn n
cn l =
0
l (t )dt =
i =1
wi = nw
l=
and q =
and
x=
23/ 30
Computational Model
The ANSI C program ssq1 implements Algorithm 1.2.1 Data is read from the le ssq1.dat consisting of arrival times and service times in the format a 1 s1 a 2 s2 . . . . . . an sn
24/ 30
Example 1.2.8
Running program ssq1 with ssq1.dat 1/r 0.10 and 1/s 0.14
25/ 30
Trac Intensity
Assuming cn /an is close to 1.0, the trac intensity and utilization will be nearly equal
26/ 30
Case Study
Sven and Larrys Ice Cream Shoppe owners considering adding new avors and cone options concerned about resulting service times and queue length Can be modeled as a single-server queue ssq1.dat represents 1000 customer interactions Multiply each service time by a constant
In the following graph, the circled point uses unmodied data Moving right, constants are 1.05, 1.10, 1.15, . . . Moving left, constants are 0.95, 0.90, 0.85, . . .
27/ 30
0.5
Sven and Larry will have to assess the impact of the increased service times
Discrete-Event Simulation: A First Course Section 1.2: A SingleServer Queue 28/ 30
Graphical Considerations
12.0 10.0 8.0 q 6.0 4.0 2.0 0.0 0.4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
x 1.0
0.5
0.6
0.7
0.8
0.9
Since both x and q are continuous, we could calculate an innite number of points Few would question the validity of connecting the dots
29/ 30
Guidelines
If there is essentially no uncertainty and the resulting interpolating curve is smooth, connecting the dots is OK
Leave the dots as a reminder of the data points
If there is essentially no uncertainty but the curve is not smooth, more dots should be generated If the dots correspond to uncertain (noisy) data, then interpolation is not justied
Use approximation of a curve or do not superimpose at all
30/ 30