LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
GIM1_pi_ETAQA.m
1function pi=GIM1_pi_ETAQA(B,A,R,varargin)
2%GIM1_pi Aggregate Probability Vector of a GI/M/1 process
3%implemented using ETAQA method [Riska, Smirni]
4%
5% Return value: pi=[pi0,pi1,pi2 + pi3 + ...];
6% For Continous Case:
7% pi=GIM1_pi(B,A,R) computes the aggregate probability vetor
8% of a GI/M/1-Type Continuous Time Markov Chain(CTMC) with
9% an infinitesimal generator matrix of the form
10%
11% B1 A0 0 0 0 ...
12% B2 A1 A0 0 0 ...
13% Q = B3 A2 A1 A0 0 ...
14% B4 A3 A2 A1 A0 ...
15% ...
16%
17% the input matrix R is the minimal nonnegative solution to the
18% matrix equation 0 = A0 + R A1 + R^2 A2 + ... + R^maxa Amaxa
19% The input matrix B equals [B1; B2; ...; Bmaxb], the input
20% matrix A equals [A0;A1;A2; ...; Amaxa]
21%
22% For discrete Case:
23% pi=GIM1_pi(B,A,R) computes the aggregate probability vetor
24% of a GI/M/1-Type Discrete Time Markov Chain(DTMC) with
25% an infinitesimal generator matrix of the form
26%
27% B1 A0 0 0 0 ...
28% B2 A1 A0 0 0 ...
29% P = B3 A2 A1 A0 0 ...
30% B4 A3 A2 A1 A0 ...
31% ...
32%
33% the input matrix R is the minimal nonnegative solution to the
34% matrix equation R = A0 + R A1 + R^2 A2 + ... + R^maxa Amaxa
35% The input matrix B equals [B1; B2; ...; Bmaxb], the input
36% matrix A equals [A0;A1;A2; ...; Amaxa]
37%
38% Optional Parameters:
39%
40% Boundary: B0, which allows solving the GI/M/1 Type CTMC
41% with a more general boundary states block
42%
43% B1 B0 0 0 0 ...
44% B2 A1 A0 0 0 ...
45% Q = B3 A2 A1 A0 0 ...
46% B4 A3 A2 A1 A0 ...
47% ...
48% The matrices B0 need not to be
49% square. (default: B0=A0)
50%
51
52OptionNames = [
53 'Boundary '];
54
55OptionTypes = [
56 'numeric'];
57OptionValues = [];
58options = [];
59for i = 1:size(OptionNames, 1)
60 options.(deblank(OptionNames(i,:)))=[];
61end
62
63options.Boundary=[];
64
65options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
66
67m=size(R,1);
68mb=size(B,2);
69
70if (mod(size(B,1)-mb,m) ~= 0)
71 error('MATLAB:GIM1_pi_ETAQA: input matrix B has incorrect number of rows');
72else
73 degb = (size(B,1)-mb)/m;
74end
75
76if (mod(size(A,1),m) ~= 0)
77 error('MATLAB:GIM1_pi_ETAQA: input matrix A has incorrect number of rows');
78else
79 dega = (size(A,1))/m-1;
80end
81
82temp=(eye(m)-R)^(-1);
83if( max(temp<-100*eps))
84 error('MATLAB:GIM1_pi_ETAQA:InvalidRInput',...
85 'The spectral radius of R is not below 1: GIM1 is not pos. recurrent');
86end
87
88
89
90
91
92if (~isempty(options.Boundary))
93 B0 = options.Boundary;
94 testmb = size(B0,1);
95 testm = size(B0,2);
96 if (testmb ~= mb)
97 error('MATLAB:GIM1_pi_ETAQA:input options.Boundary has incorrect number of rows');
98 end
99 if (testm ~= m)
100 error('MATLAB:GIM1_pi_ETAQA:input options.Boundary has incorrect number of columns');
101 end
102else
103 B0 = A(1:m,:);
104end
105
106test = B(1:mb,:)+B0;
107
108if abs((sum(test,2) - ones(mb,1))'*ones(mb,1)) < 1e-10
109 % transform from DTMC to CTMC
110 B(1:mb,:) = B(1:mb,:) - eye(mb);
111 A(m+1:2*m,:) = A(m+1:2*m,:) - eye(m);
112
113end
114
115
116
117
118
119% compute X so that pi*X = [1,0s]
120
121Firstc = ones(mb+2*m,1);
122% compute sum_i=2 R^(i-2)*(I-R)*B(i)
123temp = eye(m) - R;
124tempsum = zeros(m,mb);
125for i = 2:degb
126 tempsum = tempsum + temp*B(mb+(i-1)*m+1:mb+i*m,:);
127 temp = R*temp;
128end
129% compute sum_i=1 R^(i-1)*(I-R)*A(i+1);
130Secondc = [B(1:mb,:);B(mb+1:mb+m,:);tempsum];
131temp = eye(m)-R;
132tempsum = zeros(m,m);
133for i = 2:dega
134 tempsum = tempsum + temp*A(m+(i-1)*m+1:m+i*m,:);
135 temp = R*temp;
136end
137Thirdc = [B0;A(m+1:m+m,:);tempsum];
138%compute sum_i=1 R^i A(i+1)
139temp = R;
140tempsum = zeros(m,m);
141for i=2:dega
142 tempsum = tempsum + temp*A(m+(i-1)*m+1:m+i*m,:);
143 temp = R*temp;
144end
145Fourthc = [zeros(mb,m);A(1:m,:);(A(1:m,:)+A(m+1:m+m,:)+tempsum)];
146Fourthc= Fourthc(:,1:end-1);
147
148X = [Firstc, Secondc, Thirdc, Fourthc];
149rside = [1,zeros(1,mb+2*m-1)];
150pi = rside /X;
151
152
153end
154