Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a MATLAB Expert help to get my MATLAB Code work to validate the MMCQ Multiserver finite call center queuing system tests all passed.

I need a MATLAB Expert help to get my MATLAB Code work to validate the MMCQ Multiserver finite call center queuing system tests all passed. I posted the project many times to get it right but no luck with chegg expert so far. Here is the code below: The issues to be fixed are : All validation tests should pass , correct the p0 calcualtion, pN, and N values and recomended the optimal number of servers and lambda for the all validation tests to pass: % Run this test case to check your code
% Test and validation code
lambda =2; % Arrival rate: 2 calls per minute
mu =0.1; % Service rate: 0.1 calls per minute per agent
% Assuming an initial number of agents for the calculation
c =4; % Placeholder, needs adjustment based on system requirements
% Nwait = Nwait Maximum number of customers waiting in the queue. Placeholder, needs adjustment based on system requirements
% Calculate Nwait based on the arrival and service rate
% Nwait is maximum queue length.
Nwait = lambda /(mu - lambda);
% Calculate System Capacity(N)= c + Queue Length
N = c + Nwait;
% Call the MMCQ function with the given parameters
%[Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait);
% Run this test case to check your code
[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,2.1557)<0.005
fprintf('Ws =%6.3f PASS
', Ws);
else
fprintf('Ws =%6.3f FAIL
', Ws);
end
if rel_error(Wq,0.1557)<0.005
fprintf('Wq=%6.3f PASS
', Wq);
else
fprintf('Wq %6.3f FAIL
', Wq);
end
if rel_error(c_util, 0.4986)<0.005
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
fprintf('p_state %s
', num2str(p_state));
% Extra Tests
% p_state should have Nwait+1 probabilities
if rel_error(sum(p_state),1)<0.005
disp('The probabilities sum to 1. Test PASSED');
else
disp('The probabilities do not sum to 1. Test FAILED.');
end
% Extra Tests
disp(['p_state: ', num2str(p_state)]);
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.');
end
% function [Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait)
function [Ws, Wq, c_util, p_drop, p_state]= MMCQ(lambda, mu, c, Nwait)
% Calculate rho: the traffic intensity per server, which is the ratio of the arrival rate to the combined service rate of all servers.
rho = lambda /(mu); % updated for the MMCQ Finite Queuing System
% Calculate p0, the probability of having zero customers in the system.
% Calculate the probability of zero customers in the system
p0=1/(sum((c*rho).^(0:c-1)/ factorial(0:c-1))+((c*rho)^c /(factorial(c)*(1- rho))));
%% Calculate the average number of customers in the queue
% Nwait =((rho^c * c * rho * P0)/(factorial(c)*(1- rho)^2));
% p_state = zeros(1, Nwait +1);
% Calculate the total number of possible customers in the system.
% N =((c*lambda/mu)^N / factorial(c))*(1- lambda/(c*mu))* p0;
% Calculate System Capacity(N)= c + Queue Length
N = c + Nwait;
% disp(N);
% fprintf('The total number of possible customers in the system, N =%s
',N);
p_state = zeros(1, N +1);
p_state(1)= p0;
% Calculate the p_state based on the number of customers relative to the number of servers (c):
% For states c to Nwait (Customers Being Served or Waiting):the system includes customers waiting in the queue. for i =1:Nwait
for i =1:N
ci = min(i, c);
if i <= c
p_state(i +1)= ci / c * p_state(i)* rho / factorial(i);
else
p_state(i +1)= c^ci / factorial(ci)* p_state(i)* rho^i / factorial(c);
end
end
p_state = p_state / sum(p_state);
% Calculate pN: the probability of dropping a customer (the system being full).
pN = p_state(N);
% pN = p_state(Nwait +1);
% pN =((c*lambda/mu)^N / factorial(c))*(1- lambda/(c*mu))* p0;
% Calculate the rate of lost customers due to the system being full.
lambda_loss = lambda * pN;
% Calculates the effective arrival rate, considering the lost customers.
lambda_eff = lambda - lambda_loss;
% Calculate Lq: the average number of customers in the queue, calculated using the state probabilities.
Lq = sum((0:N).* p_state);
% Calculates Ls: the total average number of customers in the system, both in service and in the queue.
Ls = Lq + lambda_eff / mu;
% Calculate c_bar (Average Busy Servers) and c_util (Utilization Factor)**:
c_bar = Ls - Lq;
c_util = c_bar / c;
p_drop = pN;
% Calculate Ws:the average time a customer spends in the system.
Ws = Ls / lambda_eff;
% Calcualte Wq: the average time a customer spends in the queue.
Wq = Lq / lambda_eff;
end. All validation tests failed wth the following outputs: Ws =44.805 FAIL
Wq 42.805 FAIL
c_util 0.473

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

More Books

Students also viewed these Databases questions

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago