Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Single queue Multiple server problem

ricky_rubioricky_rubio Posts: 2Member
I want do a queuing model for single queue multiple server. Currently, i can do for 2 servers only. I want to make the user can input the number of servers and the queue should react according to the number of servers. Please need help here..

arrivalT = [1 5 7 10 18 19 20 25 28 30];
serviceT = [3 7 9 2 20 20 3 1 20 8];
interarrival_time=zeros(1,9);
for a=2:9
interarrival_time(a-1)=arrivalT(a)-arrivalT(a-1);
end
serverN = input('Number of server:');
serverservisT=zeros(1,2);
finishT=zeros(1,10);

fS1=arrivalT(1)+serviceT(1);
finishT(1)=fS1;
fS2=arrivalT(2)+serviceT(2);
finishT(2)=fS2;
for i=3:10
if arrivalT(i)>fS1
finishT(i)=arrivalT(i)+serviceT(i);
fS1=finishT(i);
elseif arrivalT(i)>fS2
finishT(i)=arrivalT(i)+serviceT(i);
fS2=finishT(i);
else
if fS1<fS2
finishT(i)=fS1+serviceT(i);
fS1=finishT(i);
else
finishT(i)=fS2+serviceT(i);
fS2=finishT(i);

end
end
end
fprintf('ATime STime Ftime
');
k=[arrivalT', serviceT', finishT'];
disp(k);
disp(fS1);
disp(fS2);
total_interarrival_time=sum(interarrival_time);
interarrival_rate=total_interarrival_time/10;
total_service_time=sum(serviceT);
service_rate=total_service_time/10;
server_utilization= interarrival_rate/service_rate;
disp(server_utilization);
Sign In or Register to comment.