0% found this document useful (0 votes)
84 views6 pages

Queuing Theory Mini Project: Abin Mathew (CS16S038), Bhaswar Majumder (EE16S038)

This document describes a queuing theory mini project by students Abin Mathew and Bhaswar Majumder. It discusses an M/M(a,b)/1 queue where service starts when the queue size reaches a and the server takes batches of a minimum of a items and up to b items. Theoretical formulas are provided and MATLAB code is included to simulate the queue and calculate performance metrics like average wait time, number in the queue, average time in system, and average arrivals per unit time. References on queuing theory and stochastic processes are also listed.

Uploaded by

Bhaswar Majumder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views6 pages

Queuing Theory Mini Project: Abin Mathew (CS16S038), Bhaswar Majumder (EE16S038)

This document describes a queuing theory mini project by students Abin Mathew and Bhaswar Majumder. It discusses an M/M(a,b)/1 queue where service starts when the queue size reaches a and the server takes batches of a minimum of a items and up to b items. Theoretical formulas are provided and MATLAB code is included to simulate the queue and calculate performance metrics like average wait time, number in the queue, average time in system, and average arrivals per unit time. References on queuing theory and stochastic processes are also listed.

Uploaded by

Bhaswar Majumder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Queuing Theory Mini Project

Abin Mathew (CS16S038), Bhaswar Majumder (EE16S038)

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;

%Calculating Theoretical Values in the following subsection


disp('M/M(a,b)/1 Queue Simulation');
disp('---------------------------------------------------------------------');
disp('Theoretical Computation Results :');
disp('roots of characteristic equations:');
c=[4 4 4 4 4 4 -5];
r1=roots(c);
disp(r1);
r=.5636;
disp('real root of characteristic equation (r + r^2 + r^3+......+r^6= la/mu = 5/4)
which is in between 0 and 1 is:');
disp(r);
p00=((a/(1-r))+((((r^(a+1))-(r^(b+1)))/(1-r)^2)))^(-1);
disp('p00 =');
disp(p00);
Nq= (p00/(1-r))*((.5*a*(a-1))+(r^2*(a*r^(a-1)*(1-r)-(1-r^a))/(1-r)^2)+(r^2*(1-
r^b)/(1-r)^2));
W=Nq/la;
T=W+(1/mu);
N=la*T;
disp('W =');
disp(W);
disp('Nq =');
disp(Nq);
disp('T =');
disp(T);
disp('N =');
disp(N);
disp('---------------------------------------------------------------------------')

%Caluculating parameter values through Simulation in this subsection

disp('Simulated Results :');


inter_arrival_time=exprnd(1/la,[1,n]);%Array of Inter Arrival Time
intime_into_queue=cumsum(inter_arrival_time);%Actual arrival time of each customer
start_time_service=zeros(1,n);%Stores the start time of service of each customer
service_time=exprnd(1/mu,[1,n]);%Stores the service time of each batch
outtime_from_queue=zeros(1,n);%Outtime of each customer from the system
waiting_time_queue=zeros(1,n); %Waiting time of the customer in the queue
waiting_time_system=zeros(1,n);%Waiting time of the customer in the system
batch_size_history=zeros(1,n);
batch_start_time=zeros(1,n);
batch_end_time=zeros(1,n);
for i = 1:a %First batch starts when 'a' number of customers arrive%
start_time_service(i)=intime_into_queue(a);
outtime_from_queue(i)=start_time_service(i) +service_time(1);
end
outtime_of_batch=outtime_from_queue(1);
batch_end_time(1)=outtime_of_batch;
last_index=a;
i=a+1;
batch_size_history(1)=a;
batch_start_time(1)=intime_into_queue(a);
batch_no=2;
while (i<=n)
count=0;
j=last_index+1;
while(j<=n && intime_into_queue(j)<=outtime_of_batch) %counts number of
customers in the queue
count=count+1;
j=j+1;
end
if(count < a) %Case where less than 'a' customers are in the queue
batch_size_history(batch_no)=min(a,n-last_index);
last_index=last_index+min(a,n-last_index);
batch_start_time(batch_no)=intime_into_queue(last_index);
batch_end_time(batch_no)=service_time(batch_no)+
batch_start_time(batch_no);
while(i<=last_index)
start_time_service(i)=intime_into_queue(last_index);
outtime_from_queue(i)=start_time_service(i) +service_time(batch_no);
i=i+1;
end
batch_no=batch_no+1;
outtime_of_batch = outtime_from_queue(last_index);
elseif(count >=a & count <=b) %Case where no of customers >=a and <=b
last_index=last_index+count;
batch_size_history(batch_no)=count;
batch_start_time(batch_no)=outtime_of_batch;
batch_end_time(batch_no)=service_time(batch_no)+
batch_start_time(batch_no);
while(i<=last_index)
start_time_service(i)=outtime_of_batch;
outtime_from_queue(i)=start_time_service(i) +service_time(batch_no);
i=i+1;
end
batch_no=batch_no+1;
outtime_of_batch = outtime_from_queue(last_index);
else %Case where more than b customers are in the queue
last_index=last_index+b;
batch_size_history(batch_no)=b;
batch_start_time(batch_no)=outtime_of_batch;
batch_end_time(batch_no)=service_time(batch_no)+
batch_start_time(batch_no);
while(i<=last_index)
start_time_service(i)=outtime_of_batch;
outtime_from_queue(i)=start_time_service(i) +service_time(batch_no);
i=i+1;
end
batch_no=batch_no+1;
outtime_of_batch = outtime_from_queue(last_index);
end
end

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

1. Stochastic Models in Queuing Theory, 2nd Edition, Academic Press, J. Medhi.

2. Introduction to Probability Models, 11th Edition, Sheldon Ross, Elsevier.

You might also like