Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am getting the error: Unrecognized function or variable ' p 0 _ denom'. Error in MMCQ ( line 9 0 5 ) p 0

I am getting the error: "Unrecognized function or variable 'p0_denom'.
Error in MMCQ (line 905)
p0=1/ p0_denom please help me to correct the error and make all the tests passed. %% Run this test case to check your code
% Parameters
c =2; % Number of servers
lambda =2; % Average Arrival Rate
mu =0.1; %% The service time should be 1/10 minutes(work units/time),10 minutes per customers. (it is service time, so the unit should be a time unit).
Nwait =15;
% rho = lambda /(c * mu);
rho = lambda / mu;
% Call the MMCQ function with the given parameters
[Ws, Wq, c_util, p_drop, p_state]= MMCQ(1,0.5,4,5);
% Define a relative error function
% Validation checks are performed for four key metrics:
% Ws is compared to p_state(1) with a tolerance of 0.5%.
% Wq is compared to p_state(2) with the same tolerance.
% c_util is compared to a predefined value (0.4986) with a tolerance of 0.5%.
% p_drop is compared to a predefined value (0.00272) with a tolerance of 0.5%.
rel_error = @(x, y) abs(x - y)/ y; % rel_error calculates relative errors between values (used for comparisons).
% Validate the results and print "PASS" or "FAIL" for each metric
if rel_error(Ws,2.1557)<0.005; % Ws is compared with p_state(1).
fprintf('Ws =%6.3f PASS
', Ws);
else
fprintf('Ws =%6.3f FAIL
', Ws);
end
if rel_error(Wq,0.1557)<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;% p_drop is compared with 0.00272.
fprintf('p_drop =%8.5f PASS
', p_drop);
else
fprintf('p_drop =%8.5f FAIL
', p_drop);
end
fprintf('p_state: %s
', p_state);
fprintf('sum(p_state): %f
', sum(p_state));
fprintf('p_drop: %s
', p_drop);
% Extra Tests:
p_state % p_state should have 10 probabilities
sum(p_state)% p_state Should be 1
disp(['The probability of being in state ',' is ', num2str(p_state)]);
% Check that the probabilities sum to 1
if abs(sum(p_state)-1)<1e-5
disp('The probabilities sum to 1. Test PASSED.');
else
disp('The probabilities do not sum to 1. Test FAILED.');
endfunction [Ws, Wq, p_drop, p_state, c_util]= MMCQ(x, mu, c, Nwait)
% Calculate p0(probability of no customers in the system)
% rho = lambda/mu;
p0_denom = sum((c * rho).^(0:(c -1))/ factorial(0:(c -1)));
p0_denom = p0_denom +((c * rho)^c /(factorial(c)*(1- rho)))*(1-(rho^Nwait /(factorial(Nwait)*(1- rho))));
p0=1/ p0_denom;
p_state = zeros(1, Nwait +1);
pN = p_state(Nwait +1);
% Calculate lambda_loss and lambda_eff
lambda_loss = lambda * pN;
lambda_eff = lambda - lambda_loss;
Lq = sum((0:Nwait).* p_state);
% Calculate Ls (average number of customers in the system)
Ls = Lq + lambda_eff / mu;
p_drop = pN /(1+ pN);
% 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;
end
end
% Calculate Ws and Wq
Ws = Ls / lambda_eff;
Wq = Lq / lambda_eff;
c_bar = Ls - Lq;
% Calculate the utilization factor
% c_bar = rho *(1+(c * rho)^c / factorial(c)/(1- rho));
c_util = c_bar / c;
end

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_2

Step: 3

blur-text-image_3

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago