Professional Documents
Culture Documents
Question 3:
M/M(a,b)/1 bulk or batch service queue where service starts only when the queue size reaches or exceeds 'a'
and capacity being 'b'.
Solution:
General Bulk Service Rule is followed in our simulation, according to which:
The input is assumed to be Poisson with one arrival at each epoch of Poisson process with rate .
The service time distribution of a batch is assumed to be exponential with parameter .
The server will take in a batch a minimum number of units (a units, here), which is less than or equal to his
capacity, b units in the given case. The server adopts the following policy. If, on completion of a batch
service, he finds q units waiting and if
(i) 0 <= q < a, then he waits till the queue size grows to a,
(ii) a <= q <= b, then he takes a batch of size q for service, and
(iii) q > b, then he takes a batch of size b for service (in order of arrival or in random order), while those in
excess of b units wait in the queue.
Theoretical Formulae:
Matlab Code:
%M/M(a,b)/1 Simulation
%Following parameter values are taken for simulating the given problem
la=5;
mu=4;
a=3;
b=6;
n=50000;
for i=1:n
waiting_time_queue(i)=start_time_service(i)-intime_into_queue(i);
end
disp('W =');
disp(mean(waiting_time_queue));
disp('Nq =');
i=1;j=1;
last_timestamp=0;
queue_size=0;
sum=0;
%We take the weighted average of number of people in the queue at discrete time
intervals where queue length changes.
%Queue length changes when a new batch starts or a new arrival into the queue
occurs
while (i<=n && j<batch_no)
if(intime_into_queue(i)< batch_start_time(j))
sum=sum+(intime_into_queue(i)-last_timestamp)*queue_size;
queue_size=queue_size+1;
last_timestamp=intime_into_queue(i);
i=i+1;
elseif(intime_into_queue(i)== batch_start_time(j))
sum=sum+(batch_start_time(j)-last_timestamp)*queue_size;
queue_size=queue_size-batch_size_history(j)+1;
last_timestamp=batch_start_time(j);
i=i+1;
j=j+1;
else
sum=sum+(batch_start_time(j)-last_timestamp)*queue_size;
queue_size=queue_size-batch_size_history(j);
last_timestamp=batch_start_time(j);
j=j+1;
end
end
disp(sum/outtime_from_queue(n));
disp('T =');
for i=1:n
waiting_time_system(i)=outtime_from_queue(i)-intime_into_queue(i);
end
%We take the weighted average of number of people in the queue at discrete time
intervals where length of the system changes.
%System length changes when a service is over or a new arrival into the queue
occurs
disp(mean(waiting_time_system));
disp('N =');
i=1;j=1;
last_timestamp=0;
queue_size=0;
sum=0;
while (i<=n && j<batch_no)
if(intime_into_queue(i)< batch_end_time(j))
sum=sum+(intime_into_queue(i)-last_timestamp)*queue_size;
queue_size=queue_size+1;
last_timestamp=intime_into_queue(i);
i=i+1;
else
sum=sum+(batch_end_time(j)-last_timestamp)*queue_size;
queue_size=queue_size-batch_size_history(j);
last_timestamp=batch_end_time(j);
j=j+1;
end
end
disp(sum/outtime_from_queue(n));
Bibliography