Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ws: 2 . 8 6 8 5 Wq: 0 . 8 6 8 5 1 c _ util: 0 . 4 8 0 4 2

Ws: 2.8685
Wq: 0.86851
c_util: 0.48042
p_drop: 0.039156
p_state: 0.52860.26430.132150.0330380.00275310.039156
Ws =2.869 FAIL
Wq 0.869 FAIL
c_util 0.480 FAIL
p_drop 0.03916 FAIL
p_state 0.52860.26430.132150.0330380.00275310.039156
The probabilities sum to 1. Test PASSED
p_state: 0.52860.26430.132150.0330380.00275310.039156
The probabilities sum to 1. Test PASSED.% Test and validation code
lambda =2; % Arrival rate: 2 calls per minute
mu =0.1; % Service rate: 0.1 calls per minute per agent
c =4; % Placeholder, needs adjustment based on system requirements
% Placeholder, needs adjustment based on system requirements
Nwait = lambda /(mu - lambda);
% Calculate System Capacity (N)
N = c + Nwait;
% Call the MMCQ function with the given parameters
[Ws, Wq, c_util, p_drop, p_state]= MMCQ(1,0.5,4,5);
% Display the results
disp(['Ws: ', num2str(Ws)]);
disp(['Wq: ', num2str(Wq)]);
disp(['c_util: ', num2str(c_util)]);
disp(['p_drop: ', num2str(p_drop)]);
disp(['p_state: ', num2str(p_state)]);
% 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)
% Calculate rho: the traffic intensity per server
rho = lambda / mu;
% Calculate p0, the probability of having zero customers in the system
p0=1/ sum((c * rho).^(0:c-1)/ factorial(0:c-1)+(c * rho)^c / factorial(c));
% Initialize p_state
p_state = zeros(1, Nwait +1);
p_state(1)= p0;
% Calculate p_state based on the number of customers relative to the number of servers (c)
for i =1:Nwait
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(Nwait +1);
% 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:Nwait).* 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;
% Calculate Wq: the average time a customer spends in the queue
Wq = Lq / lambda_eff;
end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions