1function G=MG1_NI_LRAi(A0, Ahat, Gamma, varargin)
2% Newton Iteration
for M/G/1-Type Markov Chains, exploiting low-rank Ai,
5% G=MG1_NI_LRAi(A0, Ahat, Gamma) solves G = A0 + A1 G + A2 G^2 + A3 G^3 + ... + A_N G^N,
6% where A0, A1,...,AN are mxm nonnegative matrices such that
7% (A0+A1+A2+...+AN)
is irreducible and stochastic.
8% Ai can be written as Ai = Gamma*Aihat,
for i = 1,...,N, with Aihat rxm
9% matrices and Gamma an mxr matrix.
10% Ahat = [A1hat A2hat A3hat ... ANhat] has r rows and m*N columns.
14% Mode: method used to solve the linear system at each iteration
15%
'DirectSum': solves the system directly
16%
'RealSchur': applies a real Schur decomposition (default)
17%
'ComplexSchur': applies a complex Schur decomposition
18% MaxNumIt: Maximum number of iterations (default: 50)
19% EpsilonValue: Required accuracy, used as stop criterium (default:10^(-14))
20% Verbose: The residual error
is printed at each step when set to 1,
32OptionValues{1}=[
'DirectSum ';
38for i=1:size(OptionNames,1)
39 options.(deblank(OptionNames(i,:)))=[];
44options.Mode='RealSchur';
47options.EpsilonValue=10^(-14);
49% Parse Optional Parameters
50options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
60while(check > options.EpsilonValue && numit < options.MaxNumIt)
63 %Compute B: matrices premultiplying Y_k, and C: right-hand side
64 Uinv=eye(m)+Gamma*inv(eye(r)-Uhatold*Gamma)*Uhatold;
66 B = zeros(r, (N-1)*r);
67 temp = Ahat(:,(N-1)*m+1:N*m);
70 B(:,i*r+1:(i+1)*r) = temp*UinvG;
71 temp = Ahat(:,i*m+1:(i+1)*m)+temp*K;
78 while k > 1 && checkB < options.EpsilonValue
79 checkB = norm(B(:, (k-1)*r+1:k*r), 'inf');
87 if strfind(options.Mode,'RealSchur') > 0
88 Y = solveSylvPowersRealSchur_FW(K, B, C);
89 elseif strfind(options.Mode,'ComplexSchur') > 0
90 Y = solveSylvPowersComplexSchur_FW(K, B, C);
92 Y = solveSylvPowersDirectSum(K, B, C);
96 check=norm(Uhat-Uhatold,inf);
98 if (~mod(numit,options.Verbose))
99 fprintf('Check after %d iterations: %d\n',numit,check);
102G = inv(eye(m) - Gamma*Uhat)*A0;
104if (numit == options.MaxNumIt)
105 warning('Maximum Number of Iterations %d reached',numit);
108if (options.Verbose>0)
111 A = [A Gamma*Ahat(:,(j-1)*m+1:j*m)];
113 temp=A(:,end-m+1:end);
115 temp=A(:,(i-1)*m+1:i*m)+temp*G;
117 res_norm=norm(G-temp,inf);
118 fprintf('Final Residual Error for G: %d\n',res_norm);