LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
QBD_qlen_ETAQA.m
1function qlen = QBD_qlen_ETAQA(B,A,B0,pi,n)
2%QBD_qlen_ETAQA computes n-th moment of a Quasi-Birth-Death(QBD) process
3%using the ETAQA method [Riska, Smirni]
4%
5%
6% Return value: qlen = E[qlen^n];
7%
8% Usage:
9% For Continuous Case:
10% qlen=QBD_qlen_ETAQA(B,A,B0,pi,n) computes the n-th moment of Q length of a
11% QBD-type Continuous Time Markov Chain(CTMC) with an infinitesimal generator
12% matrix of the form,
13%
14% B1 B2 0 0 0 ...
15% B0 A1 A2 0 0 ...
16% Q = 0 A0 A1 A2 0 ...
17% 0 0 A0 A1 A2 ...
18% ...
19% where B = [B1,B2] and A = [A0,A1,A2], B0 describes the backward transition from
20% second level of states to the boundary level of states. The input pi is the aggregated
21% probabilities computed from ETAQA method.
22%
23%
24% For Discrete Case:
25% pi=QBD_qlen_ETAQA(B,A,B0,pi,n) computes the n-th moment of Q length of a
26% QBD-type Discrete Time Markov with a transition matrix of the form,
27%
28% B1 B2 0 0 0 ...
29% B0 A1 A2 0 0 ...
30% P =0 A0 A1 A2 0 ...
31% 0 0 A0 A1 A2 ...
32% ...
33% where B = [B1,B2] and A = [A0,A1,A2], B0 describes the backward transition from
34% second level of states to the boundary level of states. The input pi is
35% the aggregated probabilities computed from ETAQA method
36%
37%
38
39mb = size(B,1);
40m = size(A,1);
41testm = size(B0,1);
42testmb = size(B0,2);
43if (testm ~= m)
44 error('Matrix B0 has an incorrect number of rows');
45end
46if (testmb ~= mb)
47 error('Matrix B0 has an incorrect number of columns');
48end
49if (mod(size(B,2)-mb,m) ~= 0 || (size(B,2)-mb)/m ~=1 )
50 error('Matrix B has an incorrect number of columns');
51end
52if (mod(size(A, 2),m) ~= 0 || size(A,2)/m ~= 3)
53 error('Matrix A has an incorret number of columns');
54end
55
56
57if abs((sum(B,2) - ones(mb,1))'*ones(mb,1)) < 1e-12
58 % if this is a transition matrix transform it to the infinitesimal
59 % generator
60
61 A(:,m+1:2*m) = A(:,m+1:2*m) - eye(m);
62 B(:,1:mb) = B(:,1:mb) - eye(mb);
63end
64
65pi0 = pi(1:mb);
66pi1 = pi(mb+1:mb+m);
67pistar = pi(mb+m+1:mb+2*m);
68
69lsleft = A(:,1:m) + A(:,m+1:2*m) + A(:,2*m+1:3*m);
70lsleft = lsleft(:,1:end-1);
71lsleft = [lsleft,(A(:,2*m+1:3*m) - A(:,1:m))*ones(m,1)];
72
73r = pistar;
74
75for k = 1:n
76 bk = (-1)*(2^k*pi0*B(:,mb+1:mb+m) + 2^k*pi1*A(:,m+1:2*m) + 3^k*pi1*A(:,2*m+1:3*m));
77 bkrest = zeros(1,m);
78 for l = 1:k
79 bkrest = bkrest + bino(k,l)*(2^l*r(k-l+1,:)*A(:,2*m+1:3*m) + r(k-l+1,:)*A(:,m+1:2*m));
80 end
81 bk = bk - bkrest;
82 ck = -2^k*pi1*A(:,2*m+1:3*m)*ones(m,1);
83 ckrest = 0;
84 for l = 1:k
85 ckrest = ckrest + bino(k,l)*r(k-l+1,:)*A(:,2*m+1:3*m)*ones(m,1);
86 end
87 bk = bk(1:end-1);
88 ck = ck - ckrest;
89 rside = [bk,ck];
90 rk = rside /lsleft;
91 r = [r;rk];
92end
93
94qlen = sum(r(end,:),2) + sum(pi1,2);
95
96
97 function b = bino(n,k)
98 b = factorial(n)/(factorial(k)*factorial(n-k));
99 end
100
101end