Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please advise to fix the error for summation of p _ state not getting to equal to 1 ? this is for multiserver

Can you please advise to fix the error for summation of p_state not getting to equal to 1? this is for multiserver MMCQ Valdation test for finite MMCQ queuing system function [Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait)
% Calculate the utilization factor
rho = lambda / mu;
% rho = lambda /(c * mu);
% c_bar = rho *(1+(c * rho)^(c -1)/ factorial(c -1)/(1- rho)^2); % Fix c_bar calculation
% Calculate p0(probability of no customers in the system)
p0_denom = sum((c * rho).^(0:(c -1))/ factorial(0:(c -1)))+(c * rho)^c / factorial(c)/(1- rho); % Fix p0_denom calculation
p0=1/ p0_denom;
p_state = zeros(1, Nwait +1);
p_state(1)= p0;
% Calculate pN (probability of having N customers in the system)
for i =1:Nwait
if i <= c
p_state(i +1)=(rho^i / factorial(i))* p0;
else
% p_state(i +1)=(rho^i / factorial(c)*(c^(i - c)))* p0; % Fix the p_state calculation
p_state(i +1)=(rho^i / factorial(c)*(c- i)/(c -(c - i))* p0); % Fix the p_state calculation
end
end
% Calculate Lq (average number of customers in the queue)
Lq = sum((0:Nwait).* p_state);
%_=__
% Lq = lambda_eff * Wq;
% Calculate lambda_loss and lambda_eff
lambda_loss = lambda * p_state(Nwait +1);
lambda_eff = lambda - lambda_loss;
% Calculate Ls (average number of customers in the system)
Ls = Lq + lambda_eff / mu;
% Calculate the utilization
c_bar = Ls - Lq;
c_util = c_bar / c;
% Calculate p_drop (probability of a customer being dropped)
p_drop = p_state(Nwait +1);
% Calculate Ws and Wq
Ws = Ls / lambda_eff;
Wq = Lq / lambda_eff;
end% INSERT YOUR CODE HERE
% c=2; % Number of servers/Agents
% p=lamda./(c.*mu); % p= System Utilization
% for k=0:20
% approxvalue(k+1)=(lamda/mu).^k./factorial(k);
% end
% r =15; % The number of callers in the series(hold lines)
% result(1)=approxvalue (1); % Initializing the result
% for i=2:5
% result (i-1)= sum(approxvalue(1:i));
% end
%% To calculate the smallest number of customer agents that meets the requirements
%% Wq = Waiting time in queue
%% Ws = Waiting time in system
%% Lq = # of items in queue
%% ls = # of items in system
% p0=(result(1,:)+((lamda./mu).^c(1,:))./(factorial(c(1,:)).*(1-(lamda./(c(1,:).*mu))))).^-1;%Probability system is empty
%_=__
Lq = lambda * Wq;
Wa =1/(c * mu-lambda); % Average waiting time
% disp(Wa);
Wq = Lq / lambda; % Waiting time in queue
P_w = Wq / Wa;% Probability that arrival must wait
%=_+1/
% Ws = Wq +1/mu; % Average time in System
%=___=__?
Ls = Ws * lambda; % Average Number in the System(I am someow getting errors with Ls so I have to change Ls )
% disp(Ls );
%Figure8
figure
subplot(3,1,2)
xlim([220])
ylim([0.2018980.201933])
horzcat(Wq);
horzcat(c);
plot([Wq,c])% Probability that arrival must wait against thd number of servers
xlabel('Number of Servers (c)')
ylabel('Average hold Lines')
title('Probability that arrival must wait');
grid% Run this test case to check your code
c =2; % Number of servers
lambda =2; % Average Arrival Rate per minute
mu =0.1; % Service rate
Nwait =15;
% Call the MMCQ function with the given parameters
%[Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait);
[Ws, Wq, c_util, p_drop, p_state]= MMCQ(1,0.5,4,5);
% Define a relative error function
rel_error = @(x, y) abs(x - y)/ y;
% Validate the results and print "PASS" or "FAIL" for each metric
if rel_error(Ws, p_state(1))<0.005
fprintf('Ws =%6.3f PASS
', Ws); % indicating that waiting times meet the specified criteria.
else
fprintf('Ws =%6.3f FAIL
', Ws); % Ws is compared with p_state(1).
end
if rel_error(Wq, p_state(2))<0.005% Wq is compared with 0.1557.
fprintf('Wq =%6.3f PASS
', Wq);
else
fprintf('Wq =%6.3f FAIL
', Wq);
end
if rel_error(c_util, 0.4986)<0.005% c_util is compared with 0.4986.
fprintf('c_util =%6.3f PASS
', c_util);
else
fprintf('c_util =%6.3f FAIL
', c_util);
end
% if rel_error(p_drop, 0.00272)<0.005
% fprintf('p_drop =%8.5f PASS
', p_drop);
% else
% fprintf('p_drop =%8.5f FAIL
', p_drop);
% end
if rel_error(p_drop, 0.00283)<0.005
fprintf('p_drop %6.3f PASS
', p_drop);
else
fprintf('p_drop %8.5f FAIL
', p_drop);
end
fprintf('p_state: %s
', num2str(p_state));
fprintf('sum(p_state):

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

hiring trends for sonography in usa

Answered: 1 week ago