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]
5% Return value: pi=[pi0,pi1,pi2 + pi3 + ...];
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
16% Q = 0 A0 A1 A2 A3 ...
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]
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
29% Q = 0 A0 A1 A2 A3 ...
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
40%
P = 0 A0 A1 A2 A3 ...
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]
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
53%
P = 0 A0 A1 A2 A3 ...
58% Boundary: Allows solving the MG1 type Markov chain with a more
63% Q/
P= 0 A0 A1 A2 A3 ...
67% the parameter value contains the matrix C0.
68% The matrices C0 and B1,B2,... need not to be square.
74OptionNames = [
'Boundary '];
76OptionTypes = [
'numeric'];
82for i = 1:size(OptionNames,1)
83 options.(deblank(OptionNames(i,:)))=[];
90% Parse Optional Parameters
91options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
93m=size(A,1); % number of states for the repetitive structure
94dega=size(A,2)/m-1; % computer amax
99 mb=m; % number of boundary states
100 degb=dega; % the number of B(i) - 1, bmax
102 if (isempty(options.Boundary))
105 C0 = options.Boundary;
109 if (mod(size(B,2)-mb,m) ~= 0)
110 error('Matrix B has an incorrect number of columns');
112 if (isempty(options.Boundary))
115 C0 = options.Boundary;
117 degb=(size(B,2)-mb)/m; % bmax
120if (isempty(options.Boundary) & mb ~= m)
121 error('The Boundary option must be used since a dimension of B0
is not identical to A0');
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');
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);
143% test the drift condition
144% alpha = (sum_i=-1 Ai*i)*e
145% a = stochastic_root(sum_i=-1 Ai);
148sumA = A(:,dega*m+1:end);
151 sumA=sumA+A(:,i*m+1:(i+1)*m);
152 alpha=alpha+sum(sumA,2);
159 error('MATLAB:MG1_pi_ETAQA:NotPositiveRecurrent',...
160 'The Markov chain characterized by A
is not positive recurrent');
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
167Shat = B(:,mb + (degb-1)*m+1:end);
169 % this
is for the QBD case
170 % do nothing here because Shat already has a value
172 % this
is for the non QBD case
174 temp = B(:,mb+(i-1)*m+1:mb+i*m) + Shat(:,1:m)*G;
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);
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');
186 temp = A(:,i*m+1:(i+1)*m) + S(:,1:m)*G;
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)
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)];
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');
219 Thirdc = [B(:,mb+1:mb+m);A(:,m+1:2*m) + S(:,m+1:2*m)*G;zeros(m,m)];
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) + ...
233 Bsum = Bsum + B(:,mb+1*m+1:mb+2*m);
237 Bsum=Bsum+B(:,mb+(i-1)*m+1:mb+(i)*m);
238 Shat_sum=Shat_sum+Shat(:,i*m+1:(i+1)*m);
240 Bsum=Bsum + B(:,mb+(degb-1)*m+1:end);
250 Ssum = Ssum + S(:,i*m+1:(i+1)*m);
251 Asum = Asum + A(:,i*m+1:(i+1)*m);
253 Asum = Asum + A(:,dega*m+1:end);
256 Asum = Asum + A(:,dega*m+1:end);
258 error('MATLAB:MG1_pi_ETAQA:NotEnoughA Blocks',...
259 'The number of repetitive state blocks are less than 3, the Markov Chain
is reducible');
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];
269rankXtemp = rank(Xtemp);
270while (rankt ~= rankXtemp && i <= (mb+2*m-1))
271 rankt = rank([Xtemp(:,1:i),Xtemp(:,i+2:mb+2*m)]);
277Xtemp = [Xtemp(:,1:i-1),Xtemp(:,i+1:mb+2*m)];
280Xnew = [Firstc,Xtemp];
286rside = [1,zeros(1,mb+2*m-1)];