LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MG1_pi_ETAQA.m
1function pi=MG1_pi_ETAQA(B,A,G,varargin)
2%MG1_pi_ETATA Aggregate probability vector of a M/G/1 process
3%Using the newETAQA method [Stathopoulos, Riska, Hua, Smirni]
4%
5% Return value: pi=[pi0,pi1,pi2 + pi3 + ...];
6%
7% Usage:
8% For Continous Case:
9% pi=MG1_pi_ETAQA(B,A,G) computes the aggregate prob. vector
10% of an M/G/1-type Markov chain with a infinitesimal
11% generator matrix of the form
12%
13%
14% B0 B1 B2 B3 B4 ...
15% A0 A1 A2 A3 A4 ...
16% Q = 0 A0 A1 A2 A3 ...
17% 0 0 A0 A1 A2 ...
18% ...
19%
20% the input matrix G is the minimal nonnegative solution to the matrix
21% equation 0 = A0 + A1 G + A2 G^2 + ... + Aamax G^amax
22% A = [A0 A1 ... Aamax] and B = [B0 B1 B2 ... Bbmax]
23%
24% pi=MG1_pi_ETAQA([],A,G) computes the aggregate prob. vector of an M/G/1-type
25% Markov chain with an infinitesimal generator matrix of the form
26%
27% A0 A1 A2 A3 A4 ...
28% A0 A1 A2 A3 A4 ...
29% Q = 0 A0 A1 A2 A3 ...
30% 0 0 A0 A1 A2 ...
31% ...
32%
33% For Discrete Case:
34% pi = MG1_pi_ETAQA(B,A,G) computes the aggregatet prob. vector
35% of an M/G/1-type Markov chain with a transition matrix P of the form
36%
37%
38% B0 B1 B2 B3 B4 ...
39% A0 A1 A2 A3 A4 ...
40% P = 0 A0 A1 A2 A3 ...
41% 0 0 A0 A1 A2 ...
42% ...
43%
44% the input matrix G is the minimal nonnegative solution to the matrix
45% equation G = A0 + A1 G + A2 G^2 + ... + Aamax G^amax
46% A = [A0 A1 ... Aamax] and B = [B0 B1 B2 ... Bbmax]
47%
48% pi=MG1_pi_ETAQA([],A,G) computes the aggregate prob. vector of an M/G/1-type
49% Markov chain with a transition matrix P of the form
50%
51% A0 A1 A2 A3 A4 ...
52% A0 A1 A2 A3 A4 ...
53% P = 0 A0 A1 A2 A3 ...
54% 0 0 A0 A1 A2 ...
55% ...
56%
57% Optional parameters:
58% Boundary: Allows solving the MG1 type Markov chain with a more
59% general boundary:
60%
61% B0 B1 B2 B3 B4 ...
62% C0 A1 A2 A3 A4 ...
63% Q/P= 0 A0 A1 A2 A3 ...
64% 0 0 A0 A1 A2 ...
65% ...
66%
67% the parameter value contains the matrix C0.
68% The matrices C0 and B1,B2,... need not to be square.
69% (default: C0=A0)
70%
71%
72
73
74OptionNames = [ 'Boundary '];
75
76OptionTypes = [ 'numeric'];
77
78
79OptionValues = [];
80
81Options=[];
82for i = 1:size(OptionNames,1)
83 options.(deblank(OptionNames(i,:)))=[];
84end
85
86% Default settintgs
87
88options.Boundary=[];
89
90% Parse Optional Parameters
91options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
92
93m=size(A,1); % number of states for the repetitive structure
94dega=size(A,2)/m-1; % computer amax
95A0 = A(:,1:m);
96
97
98if (isempty(B))
99 mb=m; % number of boundary states
100 degb=dega; % the number of B(i) - 1, bmax
101 B=A;
102 if (isempty(options.Boundary))
103 C0 = A0;
104 else
105 C0 = options.Boundary;
106 end
107else
108 mb=size(B,1);
109 if (mod(size(B,2)-mb,m) ~= 0)
110 error('Matrix B has an incorrect number of columns');
111 end
112 if (isempty(options.Boundary))
113 C0 = A0;
114 else
115 C0 = options.Boundary;
116 end
117 degb=(size(B,2)-mb)/m; % bmax
118end
119
120if (isempty(options.Boundary) & mb ~= m)
121 error('The Boundary option must be used since a dimension of B0 is not identical to A0');
122end
123
124
125if (~isempty(options.Boundary))
126 if (size(options.Boundary,1) ~= m || size(options.Boundary,2) ~= mb)
127 error('The boundary parameter value has an incorrect dimension');
128 end
129end
130
131if (sum(B,2) - zeros(mb,1))'*ones(mb,1) > 1e-12
132% if this is a transition matrix, transform it to a infinitesimal generator matrix
133% change B0 and A1 by substracting from them the identity matrix
134 if ((sum(B,2) - ones(mb,1))'*ones(mb,1) < 1e-12)
135 B(:,1:mb) = B(:,1:mb) - eye(mb);
136 A(:,m+1:2*m) = A(:,m+1:2*m) - eye(m);
137 end
138end
139
140
141
142
143% test the drift condition
144% alpha = (sum_i=-1 Ai*i)*e
145% a = stochastic_root(sum_i=-1 Ai);
146% drift = alpha*a
147
148sumA = A(:,dega*m+1:end);
149alpha = sum(sumA,2);
150for i = dega-1:-1:1
151 sumA=sumA+A(:,i*m+1:(i+1)*m);
152 alpha=alpha+sum(sumA,2);
153end
154sumA=sumA+A(:,1:m);
155a=stat(sumA);
156drift=a*alpha;
157
158if (drift >= 1)
159 error('MATLAB:MG1_pi_ETAQA:NotPositiveRecurrent',...
160 'The Markov chain characterized by A is not positive recurrent');
161end
162
163% begin the exact computation for boundary and repetitive aggregated probabilities
164% Preparation 1: compute the S_hat
165% S_hat(j) = B(j)*G^0 + B(j+1)*G + B(j+2)*G^2 + B(j+3)*G^3 + ..., j >= 1
166
167Shat = B(:,mb + (degb-1)*m+1:end);
168if degb <= 1
169 % this is for the QBD case
170 % do nothing here because Shat already has a value
171else
172 % this is for the non QBD case
173 for i = degb-1:-1:1
174 temp = B(:,mb+(i-1)*m+1:mb+i*m) + Shat(:,1:m)*G;
175 Shat = [temp,Shat];
176 end
177end
178% Preparation 2: compute the S
179% S(j) = A(j)*G^0 + A(j+1)*G^1 + A(j+2)*G^2 + A(j+3)*G^3 + ..., j >= 1 for the forward subscript it is 0
180S = A(:,dega*m+1:end);
181if dega <=1
182 error('MATLAB:MG1_pi_ETAQA:NotEnoughAblocks',...
183 'The number of repeative state blocks is less than 2, this is not a irreducible Markov Chain');
184else
185 for i = dega-1:-1:1
186 temp = A(:,i*m+1:(i+1)*m) + S(:,1:m)*G;
187 S = [temp,S];
188 end
189end
190
191
192
193%Preparation 3: Build Xnew, where xXnew = [1 0s]. x is the aggregated
194%stationary probability vector
195%Compute first block column of Xnew, Firstc = [1s]'
196%Second block column of Xnew, Secondc=[B0;C0;0s]';
197%Third block column of Xnew, Thirdc=[B(1)+Shat(2)*G;A(1)+S(1)*G;0s];
198%Fourth block column of Xnew, Fourthc=[sum_i>=2 Bi + sum_i>=3 Shati*G;
199%sum_i>=2 A(i)+sum_i>=2 S(i)*G;sum_i>=1 A(i) + sum_i>=1 S(i)*G] -1 col
200Firstc=ones(mb+2*m,1);
201Secondc=[B(:,1:mb);C0;zeros(m,mb)];
202if (size(Shat,2) < 2*m)
203 temp = zeros(mb,m);
204 Shat = [Shat,temp];
205end
206
207if (size(S,2) < 2*m)
208 temp = zeros(m,m);
209 S = [S,temp];
210end
211
212if ((size(S,2)/m >= 2) && (size(Shat,2)/m >=2) )
213 Thirdc = [B(:,mb+1:mb+m) + Shat(:,m+1:2*m)*G;A(:,m+1:2*m)+S(:,m+1:2*m)*G;zeros(m,m)];
214else
215 if (size(S,2)/m < 2)
216 error('MATLAB:MG1_pi_ETAQA:ReducibleMarkovChain',...
217 'The number of repetitive state blocks is less than 2, this is not a irreducible Markov Chain');
218 else
219 Thirdc = [B(:,mb+1:mb+m);A(:,m+1:2*m) + S(:,m+1:2*m)*G;zeros(m,m)];
220 end
221end
222% compute the fourth column
223% Bsum = B(2) + B(3) + B(4) + ...
224% Shat_sum = Shat(3) + Shat(4) + ...
225% Asum = A(2) + A(3) + A(4) + ...
226% Ssum = S(2) + S(2) + S(3) + ...
227Bsum=zeros(mb,m);
228Shat_sum=zeros(mb,m);
229if (degb <= 2)
230 if (degb == 1)
231 Bsum = Bsum;
232 else
233 Bsum = Bsum + B(:,mb+1*m+1:mb+2*m);
234 end
235else
236 for i = 2:degb-1
237 Bsum=Bsum+B(:,mb+(i-1)*m+1:mb+(i)*m);
238 Shat_sum=Shat_sum+Shat(:,i*m+1:(i+1)*m);
239 end
240 Bsum=Bsum + B(:,mb+(degb-1)*m+1:end);
241end
242
243
244
245
246Asum = zeros(m,m);
247Ssum = zeros(m,m);
248if dega >= 3
249 for i = 2:dega-1
250 Ssum = Ssum + S(:,i*m+1:(i+1)*m);
251 Asum = Asum + A(:,i*m+1:(i+1)*m);
252 end
253 Asum = Asum + A(:,dega*m+1:end);
254else
255 if dega == 2
256 Asum = Asum + A(:,dega*m+1:end);
257 else
258 error('MATLAB:MG1_pi_ETAQA:NotEnoughA Blocks',...
259 'The number of repetitive state blocks are less than 3, the Markov Chain is reducible');
260 end
261end
262
263
264Fourthc = [Bsum+Shat_sum*G;Asum+Ssum*G;Asum+A(:,m+1:2*m)+(Ssum+S(:,m+1:2*m))*G];
265Xtemp = [Secondc,Thirdc,Fourthc];
266
267i = 0;
268rankt = 0;
269rankXtemp = rank(Xtemp);
270while (rankt ~= rankXtemp && i <= (mb+2*m-1))
271 rankt = rank([Xtemp(:,1:i),Xtemp(:,i+2:mb+2*m)]);
272 i = i+1;
273end
274
275
276
277Xtemp = [Xtemp(:,1:i-1),Xtemp(:,i+1:mb+2*m)];
278
279
280Xnew = [Firstc,Xtemp];
281
282
283
284
285
286rside = [1,zeros(1,mb+2*m-1)];
287pi = rside / Xnew;
288
289end