1function [G,R,U]=QBD_FI(A0,A1,A2,varargin)
2%QBD_FI Functional Iterations
for Quasi-Birth-Death Markov Chains [Neuts]
6% G=QBD_FI(A0,A1,A2) computes the minimal nonnegative solution to the
7% matrix equation G = A0 + A1 G + A2 G^2, where A,B and C are square
8% nonnegative matrices, with (A0+A1+A2) irreducible and stochastic
10% [G,R]=QBD_FI(A0,A1,A2) also provides the minimal nonnegative solution
11% to the matrix equation R = A2 + R A1 + R^2 A0
13% [G,R,U]=QBD_FI(A0,A1,A2) also provides the minimal nonnegative solution
14% to the matrix equation U = A1 + A2 (I-U)^(-1) A0
16% CONTINUOUS TIME CASE:
18% G=QBD_FI(A0,A1,A2) computes the minimal nonnegative solution to the
19% matrix equation 0 = A0 + A1 G + A2 G^2, where A,B and C are square
20% nonnegative matrices, with (A0+A1+A2) having row sums equal to zero
22% [G,R]=QBD_FI(A0,A1,A2) also provides the minimal nonnegative solution
23% to the matrix equation 0 = A2 + R A1 + R^2 A0
25% [G,R,U]=QBD_FI(A0,A1,A2) also provides the minimal nonnegative solution
26% to the matrix equation U = A1 + A2 (-U)^(-1) A0
30% MaxNumIt: Maximum number of iterations (default: 10000)
31% Mode:
'Traditional': G(n+1) = (I-A1)^(-1) * (A0 + A2 * G^2)
32%
'Natural': G(n+1) = A0 + (A1 + A2*G(n))*G(n)
33%
'U-Based': G(n+1) = (I-A1-A2*G(n))^(-1)*A0
34%
'Shift<Mode>': where <Mode>
is Traditional, Natural or
35% U-Based uses the Shift Technique
37% Verbose: When set to k, the residual error
is printed every
39% StartValue: Starting value for iteration (default: 0)
40% RAPComp: set to 1 if the QBD has RAP components
52OptionValues{1}=[
'Traditional ';
60for i=1:size(OptionNames,1)
61 options.(deblank(OptionNames(i,:)))=[];
65options.Mode='U-Based';
66options.MaxNumIt=10000;
69options.StartValue=zeros(m,m);
72% Parse Optional Parameters
73options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
76 % Convert to discrete time problem, if needed
79 if (sum(diag(A1)<0)) % continues time
88 QBD_ParsePara(A0,A1,A2);
91 QBD_RAP_ParsePara(A0,A1,A2);
93 % Convert to discrete time problem - uniformization
103% check whether G
is known explicitly
104[G,R,U]=QBD_EG(A0,A1,A2,options.Verbose,nargout);
114if (strfind(options.Mode,'Shift')>0)
115 theta=stat(A0+A1+A2);
116 drift=theta*sum(A0,2)-theta*sum(A2,2);
117 if (drift < 0) % MC
is transient -> use the dual MC
118 if (nargout > 1 | options.Verbose>0)
121 A2=A2-ones(m,1)*(theta*A2);
122 A1=A1+ones(m,1)*(theta*A0);
126 if (nargout > 2 | options.Verbose>0) % store A0old to compute U
134if (strfind(options.Mode,'Natural')>0)
135 while(check > 10^(-14) & numit < options.MaxNumIt)
138 check=norm(G-Gold,inf);
140 if (~mod(numit,options.Verbose))
141 fprintf('Check after %d iterations: %d\n',numit,check);
147if (strfind(options.Mode,'Traditional')>0)
148 invA1=(eye(m)-A1)^(-1);
149 while(check > 10^(-14) & numit < options.MaxNumIt)
152 check=norm(G-Gold,inf);
154 if (~mod(numit,options.Verbose))
155 fprintf('Check after %d iterations: %d\n',numit,check);
161if (strfind(options.Mode,'U-Based')>0)
162 while(check > 10^(-14) & numit < options.MaxNumIt)
164 G=(eye(m)-A1-A2*G)^(-1)*A0;
165 check=norm(G-Gold,inf);
167 if (~mod(numit,options.Verbose))
168 fprintf('Check after %d iterations: %d\n',numit,check);
173if (numit == options.MaxNumIt)
174 warning('Maximum Number of Iterations %d reached',numit);
177if (strfind(options.Mode,'Shift')>0)
178 if (drift < 0) % transient
179 if (nargout > 1 | options.Verbose >0)
180 A1=A1-ones(m,1)*theta*A0; % restore original A1
181 A2=A2old; % restore original A2
185 if (nargout > 1 | options.Verbose >0)
186 A1=A1-sum(A2,2)*uT; % restore original A1
188 if (nargout > 2 | options.Verbose >0)
189 A0=A0old; % restore original A0
194if (options.Verbose>0)
195 res_norm=norm(G-A0-(A1+A2*G)*G,inf);
196 fprintf('Final Residual Error for G: %d\n',res_norm);
201 R=A2*(eye(m)-(A1+A2*G))^(-1);
202 if (options.Verbose>0)
203 res_norm=norm(R-A2-R*(A1+R*A0),inf);
204 fprintf('Final Residual Error for R: %d\n',res_norm);
211 if (options.Verbose>0)
212 res_norm=norm(U-A1-A2*(eye(m)-U)^(-1)*A0,inf);
213 fprintf('Final Residual Error for U: %d\n',res_norm);