LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_mg1k_loss.m
1function [lossprob_mg1k,rho]=qsys_mg1k_loss(lambda,svc_density,K)
2% Niu-Cooper, Transform-Free Analysis of M/G/1/K and Related Queues, Mathematics of Operations Research
3% Vol. 18, No. 2 (May, 1993), pp. 486-510 (25 pages)
4% TEST:
5% mu=3; lambda=2; K=5; [lossprob_mg1k,rho]=qsys_mg1k_loss(lambda,@(t)mu.*exp(-mu.*t),K)
6%
7%sigma is the embedded probability seen immediately after the kth *service-start* epoch
8tmax = 1e4/lambda;
9mu = 1/integral(@(t) t.*svc_density(t),0,tmax);
10a = zeros(1,K-1);
11for j=0:1e3
12 factj = factorial(j);
13 a(1+j)=integral(@(t)exp(-lambda*t).*((lambda*t).^j).*svc_density(t),0,tmax)/factj;
14 if a(1+j)<1e-12
15 break
16 end
17end
18% We model the number of customers waiting in the queue immediately
19% after the kth *service-start* epoch
20P = zeros(K-1);
21if false
22 P(1,1) = a(1+0)+a(1+1);
23 P(2,1) = a(1+0);
24 for j=1:(K-3)
25 for i=0:(j+1)
26 P(1+i,1+j) = a(1+(j+1-i));
27 end
28 end
29 for i=0:(K-2)
30 P(1+i,1+(K-2)) = sum(a(1+((K-2+1-i)):end));
31 end
32else
33 % traditional embedded process at departure
34 for i=0:(K-2)
35 P(1,1+i)=a(1+i);
36 P(2,1+i)=a(1+i);
37 end
38 P(1,K-1)=1-sum(P(1,:));
39 P(2,K-1)=1-sum(P(2,:));
40 for j=3:K-1
41 for i=j-1:(K-2)
42 P(j,i)=a(1+i-j+1);
43 end
44 P(j,K-1)=1-sum(P(j,1:K-2));
45 end
46end
47P=dtmc_makestochastic(P);
48sigma = dtmc_solve(P);
49rho = lambda / mu;
50lossprob_mg1k = 1-1/(sigma(1+0)*a(1+0)+rho);
51end