Page 133 - DCAP601_SIMULATION_AND_MODELING
P. 133
Unit 8: Simulation of Queuing System (II)
1. Two Servers in Series Simulation Algorithm: Notes
Initialize: t = N = N = 0, SS = (n , n ) = (0, 0); generate T , set t = T , t = t = .
A D 1 2 0 A 0 1 2
Update the system state by means of the subsequent cases:
(a) t = min(t , t , t ) (a new arrival at time t )
A A 1 2 A
reset t = t , N = N + 1, n = n + 1;
A A A 1 1
generate T and reset t = T (next arrival time);
t A t
if n = 1 generate Y ~ G and reset t = t + Y ;
1 1 1 1 1
collect output data A (N ) = t.
1 A
(b) t < t , t t (a departure from 1 at time t )
1 A 1 2 1
reset t = t , n = n — 1, ; n = n + 1;
1 1 1 2 2
if n > 0 generate Y ~ G and reset t = t + Y ;
1 1 1 1 1
otherwise set t = (queue 1 is empty);
1
if n = 1 generate Y ~ G and reset t = t + Y ;
2 2 2 2 2
collect output data A (N — n ) = t.
2 A 1
(c) t < t , t < t (a departure from 2 at time t )
2 A 2 1 2
reset t = t , n = n — 1, N = N + 1;
2 2 2 D D
if n > 0 generate Y ~ G and reset t = t + Y ;
2 2 2 2 2
otherwise set t = (queue 2 is empty);
2
collect output data D(N ) = t.
D
Cases 1, 2, and 3 are used until t > T.
A
Then cases 2 and 3 are used until n = 0.
1
Then case 3 is used until n = 0.
2
Then T = max(t — T, 0).
p
2. End of “run” results
(a) Times (A (1),A (1),D(1)), . . . , (A (N ),A (N ),D(N )) provide (A — A ), (D — A ),
1 2 1 A 2 A A 2 1 2
(D — A ) averages.
1
(b) Time T is server overtime.
p
(c) (Event,Time) data (n (t ), n (t ), t ) offers history.
1 i 2 i i
3. Averages over many runs provide expected service time, server overtime, and other
statistics.
4. Generalizations to numerous servers in series.
5. Example Matlab Function for Two Servers in Series function [A A D T E ] = sriesv(T,lam,
1 2 p v
l , l )
1 2
Sample Runs
for i =1:100
[A , A , D, T , E ] = sriesv(9,6,4,3);
1 2 p v
DA(i) = mean(D-A );
1
end, disp(mean(DA))
6.1033
[A , A , D, T , E ] = sriesv(.5,6,4,3); disp(Ev)
1 2 p v
1 0 0.006042
0 1 0.082711
0 0 0.14119
1 0 0.15819
2 0 0.23596
1 1 0.26024
LOVELY PROFESSIONAL UNIVERSITY 127