Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I got all the tests failed with wrong answers: For example I know Ws = 2 . 1 5 5 7 , the equations for
I got all the tests failed with wrong answers: For example I know Ws the equations for pstate, cutil, pdenom, Lq Please help me to correct the codes and make all teh tests passed. Here is the code: function Ws Wq cutil, pdrop, pstate MMCQlambda mu c Nwait
rho lambda c mu; Calculate the utilization factor
cbar rho c rhoc factorialc rho;
cutil cbar c; Calculate the utilization
Calculate pprobability of no customers in the system
pdenom sumc rho:c factorial:c ;
pdenom pdenom c rhoc factorialc rhorhoNwait factorialNwait rho;
p pdenom;
pstate zeros Nwait ;
Calculate pN probability of having N customers in the system
for i :Nwait
if i c
pstatei rhoi factoriali p;
else
pstatei rhoi factorialc ci c p;
end
end
pN pstateNwait ; probability of having N customers in the system
Calculate lambdaloss and lambdaeff
lambdaloss lambda pN;
lambdaeff lambda lambdaloss;
Calculate Lq average number of customers in the queue
Lq sum:Nwait pstate;
Calculate Ls average number of customers in the system
Ls Lq lambdaeff mu;
Calculate pdrop probability of a customer being dropped
pdrop pN pN;
Calculate Ws and Wq
Ws Ls lambdaeff;
Wq Lq lambdaeff;
end Run this test case to check your code
c ; Number of servers
lambda ; Average Arrival Rate per minute
mu ; Service rate
Nwait ;
Call the MMCQ function with the given parameters
Ws Wq cutil, pdrop, pstate MMCQlambda mu c Nwait;
Ws Wq cutil, pdrop, pstate MMCQ;
Define a relative error function
relerror @x y absx y y;
Validate the results and print "PASS" or "FAIL" for each metric
if relerrorWs
fprintfWs f PASS
Ws;
else
fprintfWs f FAIL
Ws;
end
if relerrorWq
fprintfWq f PASS
Wq;
else
fprintfWq f FAIL
Wq;
end
if relerrorcutil,
fprintfcutil f PASS
cutil;
else
fprintfcutil f FAIL
cutil;
end
if relerrorpdrop,
fprintfpdrop f PASS
pdrop;
else
fprintfpdrop f FAIL
pdrop;
end
fprintfpstate: s
numstrpstate;
fprintfsumpstate: f
sumpstate;
Extra Tests: pstate
pstate should have Nwait probabilities
dispThe probability of being in state numstrNwait is numstrpstateNwait ;
dispThe probability of being in state is numstrpstate;
Check that the probabilities sum to
if abssumpstatee
dispThe probabilities sum to Test PASSED.;
else
dispThe probabilities do not sum to Test FAILED.;
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started