Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am not getting the MMCQ Queuing validation tests passed for the call center. Only c_util passed but the value is not correct. Can you

I am not getting the MMCQ Queuing validation tests passed for the call center. Only c_util passed but the value is not correct. Can you please check the MATLAB Codes and let me know the fixed code version. % % Run this test case to check your code % Parameters c = 2; % Number of servers lambda = 20; % 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; % Compute the Erlang B formula to calculate the probability of blocking p_block = erlangb(c, rho); % % Calculate p_drop (probability of a customer being dropped) % p_state = zeros(1, Nwait + 1); % pN = p_state(Nwait + 1); % p_drop = p_block * (1 - pN); % p_state = zeros(1, Nwait + c + 1); % p_state = zeros(1, Nwait+1); % 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, 0.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.'); end function [Ws, Wq, c_util, p_drop, p_state] = MMCQ(lambda, mu, c, Nwait) % INPUTS: % lambda = arrival rate % mu = service rate % Nwait = Number of queue elements, not including servers % c = Number of servers % OUTPUTS: % Ws = Average wait in the system % Wq = Average wait in the queue % c_util = Average percentage of servers busy % p_drop = probability the queue is full % p_state = probability of each state % Calculate traffic intensity rho rho = lambda / (c * mu); % Calculate the utilization factor c_bar = Ls - Lq; c_util = c_bar./c ; % c_util = rho; % Calculate p0 (probability of no customers in the system) 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 / (1 - rho))); p0 = 1 / p0_denom; p_state = zeros(1, Nwait + 1); pN = p_state(Nwait + 1); %_=_ _=_ lambda_loss = lambda * pN; % _=_ lambda_eff = lambda - lambda_loss; % _=_+_/ Ls = Lq + lambda_eff/mu % Calculate p_drop (probability of a customer being dropped) p_drop = pN; % p_drop = p_block * (1 - pN); % Calculate pN (probability of having N customers in the system) % p_state = zeros(1, Nwait + 1); 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 ls (average number of customers in the system) % Ls = (c_util + pN * (c_util / (1 - rho))) / (1 - rho); % Calculate Ws (average time a customer spends in the system) % =_+1/ from the lecture % Ws = ls / lambda; % _=_/_ Ws = Ls / lambda_eff; % Wq = Ws - (1 / mu); % Calculate Wq (average time a customer spends waiting in the queue) % _=/(() ) from the lecture % _=_/_ Wq = Lq / lambda_eff; % Wq = Ws - (1 / mu); 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

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago