1function [G,R,U]=MG1_IS(D,varargin)
2%MG1_IS Invariant Subspace
for M/G/1-Type Markov Chains [Akar,Sohraby]
4% G=MG1_IS(A) computes the minimal nonnegative solution to the
5% matrix equation G = A0 + A1 G + A2 G^2 + A3 G^3 + ... + A_max G^max,
6% where A = [A0 A1 A2 A3 ... A_max] has m rows and m*max columns and
is
7% a nonnegative matrix, with (A0+A1+A2+...+A_max) irreducible and
12% MaxNumIt: Maximum number of iterations (
default: 50)
13% Verbose: The residual error
is printed at each step when set to 1,
15% Mode:
'MSignStandard' uses the matrix sign approach
16%
'MSignBalzer' uses the matrix sign approach with Balzer
18%
'Schur' relies on a Schur decomposition
19% (default: MSignBalzer)
28OptionValues{1}=[
'MSignStandard';
33for i=1:size(OptionNames,1)
34 options.(deblank(OptionNames(i,:)))=[];
38options.Mode='MSignBalzer';
42% Parse Optional Parameters
43options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
45% check whether G
is known explicitly
46G=MG1_EG(D,options.Verbose);
56sumD=D(:,maxd*m+1:end);
58% beta = (D_maxd)e + (D_maxd + D_maxd-1)e + ... + (Dmaxd+...+D1)e
60 sumD=sumD+D(:,i*m+1:(i+1)*m);
61 beta=beta+sum(sumD,2);
69 F{i+1}=-D(:,i*m+1:(i+1)*m);
73% Step 2, H(s)=sum_{i=0}^f F_i (1-s)^(f-i) (1+s)^i = sum_{i=0}^f H_i s^i
83 con1=conv(con1,temp1);
86 con2=conv(con2,temp2);
88 contrib=conv(con1,con2);
90 H{j+1}=H{j+1}+contrib(j+1)*F{i+1};
96% Step 3, \hat{H}_i = H_f^-1*H_i
99 hatH{i+1}=H{f+1}*H{i+1};
103y=[ones(m,1); zeros(m*(f-1),1)];
104x0T=[zeros(1,m) 1] / [hatH{1} ones(m,1)];
106 xT(1,(i-1)*m+1:i*m)=x0T*hatH{i+1};
108xT(1,(f-1)*m+1:f*m)=x0T;
113 Zold((i-1)*m+1:i*m,i*m+1:(i+1)*m)=eye(m);
116 Zold(m*(f-1)+1:m*f,i*m+1:(i+1)*m)=-hatH{i+1};
119Zold=Zold+sign(drift)*y*xT;
121% Step 6, classic matrix sign function algorithm
122if ( exist(
'ordschur') ~= 5 || ~strcmp(options.Mode,
'Schur'))
123 % Step 6, classic matrix sign function algorithm
124 if (strcmp(
'Schur',options.Mode))
125 fprintf(
'Ordschur not supported by current MATLAB version\n');
126 fprintf(
'An automatic switch is performed to the MSignBalzer Mode\n');
129 Znew=(Zold+inv(Zold))/2;
132 while (check > epsilon && numit < options.MaxNumIt)
135 if (strcmp(options.Mode,
'MSignStandard'))
138 determ=(1+abs(det(Zold))^(1/(m*f)))^(-1);
140 Znew=determ*Zold+(1-determ)*inv(Zold);
141 check=norm(Znew-Zold,1)/norm(Zold,1);
142 if (options.Verbose==1)
143 fprintf(
'Check after %d iterations: %d\n',numit,check);
147 if (numit == options.MaxNumIt && check > epsilon)
148 warning(
'Maximum Number of Iterations %d reached: T may not have m columns',numit);
151 T=orth(Znew-eye(m*f));
154 [T,U]=ordschur(T,U,
'lhp');
159G=(T(1:m,:)+T(m+1:2*m,:))*inv(T(1:m,:)-T(m+1:2*m,:));
160if (options.Verbose==1)
161 temp=D(:,end-m+1:end);
162 for i=size(D,2)/m-1:-1:1
163 temp=D(:,(i-1)*m+1:i*m)+temp*G;
165 res_norm=norm(G-temp,inf);
166 fprintf(
'Final Residual Error for G: %d\n',res_norm);