LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MG1_NI_LRA0.m
1function G=MG1_NI_LRA0(A, A0hat, Gamma, varargin)
2% Newton Iteration for M/G/1-Type Markov Chains, exploiting low-rank A0
3%
4% G=MG1_NI_LRA0(A, A0hat, Gamma) solves G = A0 + A1 G + ... + A_N G^N,
5% where A = [A1 A2 A3 ... AN] has m rows and m*N columns and is
6% a nonnegative matrix. A0 is also nonnegative and can be written as
7% A0 = A0hat*Gamma, where A0hat and Gamma are mxr and rxm matrices,
8% respectively. (A0+A1+A2+...+AN) is irreducible and stochastic.
9%
10% Optional Parameters:
11%
12% Mode: method used to solve the linear system at each iteration
13% 'DirectSum': solves the system directly
14% 'RealSchur': applies a real Schur decomposition (default)
15% 'ComplexSchur': applies a complex Schur decomposition
16% MaxNumIt: Maximum number of iterations (default: 50)
17% EpsilonValue: Required accuracy, used as stop criterium (default:10^(-14))
18% Verbose: The residual error is printed at each step when set to 1,
19% (default:0)
20
21
22OptionNames=['Mode ';
23 'MaxNumIt ';
24 'EpsilonValue';
25 'Verbose '];
26OptionTypes=['char ';
27 'numeric';
28 'numeric';
29 'numeric'];
30OptionValues{1}=['DirectSum ';
31 'RealSchur ';
32 'ComplexSchur '];
33
34
35options=[];
36for i=1:size(OptionNames,1)
37 options.(deblank(OptionNames(i,:)))=[];
38end
39
40% Default settings
41options.Mode='RealSchur';
42options.MaxNumIt=50;
43options.Verbose=0;
44options.EpsilonValue=10^(-14);
45
46% Parse Optional Parameters
47options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
48
49% check whether G is known explicitly
50G=MG1_EG([A0hat*Gamma A],options.Verbose);
51if (~isempty(G))
52 return
53end
54
55m = size(A,1);
56N = size(A,2)/m;
57r = size(Gamma,1);
58
59check = 1;
60numit = 1;
61
62Ghat = zeros(m,r);
63while(check > options.EpsilonValue && numit < options.MaxNumIt)
64 Gold = Ghat;
65
66 %Compute B: matrices premultiplying Y_k, and C: right-hand side
67 B = zeros(m, (N+1)*r);
68 B(:,(N-1)*r+1:N*r) = A(:,(N-1)*m+1:N*m)*Ghat;
69 K = Gamma*Ghat;
70 for i = N-2:-1:0
71 B(:,i*r+1:(i+1)*r) = A(:,i*m+1:(i+1)*m)*Ghat + B(:,(i+1)*r+1:(i+2)*r)*K;
72 end
73 C = Ghat - B(:,1:r) - A0hat;
74 B = reshape( [reshape(B(:,r+1:end),r*m,N); zeros((m-r)*m,N)], m,N*m);
75 for i = 0:N-1
76 B(:,i*m+1:(i+1)*m) = B(:,i*m+1:i*m+r)*Gamma;
77 end
78 %B = A(:,m+1:end) + B;
79 B = A + B;
80 B(:,1:m) = B(:,1:m) - eye(m);
81
82 if strfind(options.Mode,'RealSchur') > 0
83 Y = solveSylvPowersRealSchur_FW(K, B, C);
84 elseif strfind(options.Mode,'ComplexSchur') > 0
85 Y = solveSylvPowersComplexSchur_FW(K, B, C);
86 else
87 Y = solveSylvPowersDirectSum(K, B, C);
88 end
89
90 Ghat = Ghat + Y;
91 check=norm(Ghat-Gold,inf);
92 numit = numit + 1;
93 if (~mod(numit,options.Verbose))
94 fprintf('Check after %d iterations: %d\n',numit,check);
95 end
96end
97G = Ghat*Gamma;
98
99if (numit == options.MaxNumIt)
100 warning('Maximum Number of Iterations %d reached',numit);
101end
102
103if (options.Verbose>0)
104 A = [A0hat*Gamma A];
105 temp=A(:,end-m+1:end);
106 for i=N:-1:1
107 temp=A(:,(i-1)*m+1:i*m)+temp*G;
108 end
109 res_norm=norm(G-temp,inf);
110 fprintf('Final Residual Error for G: %d\n',res_norm);
111end