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]
5% Return value: pi=[pi0,pi1,pi2 + pi3 + ...];
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
13% Q = B3 A2 A1 A0 0 ...
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]
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
29%
P = B3 A2 A1 A0 0 ...
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]
40% Boundary: B0, which allows solving the GI/M/1 Type CTMC
41% with a more general boundary states block
45% Q = B3 A2 A1 A0 0 ...
48% The matrices B0 need not to be
49% square. (
default: B0=A0)
59for i = 1:size(OptionNames, 1)
60 options.(deblank(OptionNames(i,:)))=[];
65options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
70if (mod(size(B,1)-mb,m) ~= 0)
71 error('MATLAB:GIM1_pi_ETAQA: input matrix B has incorrect number of rows');
73 degb = (size(B,1)-mb)/m;
76if (mod(size(A,1),m) ~= 0)
77 error('MATLAB:GIM1_pi_ETAQA: input matrix A has incorrect number of rows');
79 dega = (size(A,1))/m-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');
92if (~isempty(options.Boundary))
93 B0 = options.Boundary;
97 error('MATLAB:GIM1_pi_ETAQA:input options.Boundary has incorrect number of rows');
100 error('MATLAB:GIM1_pi_ETAQA:input options.Boundary has incorrect number of columns');
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);
119% compute X so that pi*X = [1,0s]
121Firstc = ones(mb+2*m,1);
122% compute sum_i=2 R^(i-2)*(I-R)*B(i)
124tempsum = zeros(m,mb);
126 tempsum = tempsum + temp*B(mb+(i-1)*m+1:mb+i*m,:);
129% compute sum_i=1 R^(i-1)*(I-R)*A(i+1);
130Secondc = [B(1:mb,:);B(mb+1:mb+m,:);tempsum];
134 tempsum = tempsum + temp*A(m+(i-1)*m+1:m+i*m,:);
137Thirdc = [B0;A(m+1:m+m,:);tempsum];
138%compute sum_i=1 R^i A(i+1)
142 tempsum = tempsum + temp*A(m+(i-1)*m+1:m+i*m,:);
145Fourthc = [zeros(mb,m);A(1:m,:);(A(1:m,:)+A(m+1:m+m,:)+tempsum)];
146Fourthc= Fourthc(:,1:end-1);
148X = [Firstc, Secondc, Thirdc, Fourthc];
149rside = [1,zeros(1,mb+2*m-1)];