LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
GIM1_pi.m
1function pi=GIM1_pi(B,R,varargin)
2%GIM1_pi Stationary vector of a GI/M/1-Type Markov Chain [Neuts]
3%
4% pi=GIM1_pi(B,R) computes the stationary vector of a GI/M/1-Type
5% Markov chain with a transition matrix of the form
6%
7% B1 A0 0 0 0 ...
8% B2 A1 A0 0 0 ...
9% P = B3 A2 A1 A0 0 ...
10% B4 A3 A2 A1 A0 ...
11% ...
12%
13% the input matrix R is the minimal nonnegative solution to the matrix
14% equation R = A0 + R A1 + R^2 A2 + ... + R^maxa Amaxa
15% The input matrix B equals [B1; B2; ...; Bmaxb].
16%
17% Optional Parameters:
18%
19% MaxNumComp: Maximum number of components (default: 500)
20% Verbose: The accumulated probability mass is printed at every
21% n steps when set to n (default:0)
22% Boundary: Allows solving the GI/M/1 Type MC with a more general
23% boundary
24%
25% B1 B0 0 0 0 ...
26% B2 A1 A0 0 0 ...
27% P = B3 A2 A1 A0 0 ...
28% B4 A3 A2 A1 A0 ...
29% ...
30% the parameter value contains the matrix [B0; A1; A2; ...;
31% Aamax].
32% The matrices B0 and Bi, i > 1, need not to be square.
33% (default: B0=A0)
34
35
36OptionNames=[
37 'Boundary ';
38 'MaxNumComp ';
39 'Verbose '];
40OptionTypes=[
41 'numeric';
42 'numeric';
43 'numeric'];
44
45OptionValues=[];
46
47options=[];
48for i=1:size(OptionNames,1)
49 options.(deblank(OptionNames(i,:)))=[];
50end
51
52% Default settings
53options.Boundary=[];
54options.MaxNumComp=500;
55options.Verbose=0;
56
57% Parse Optional Parameters
58options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
59
60m=size(R,1);
61
62temp=(eye(m)-R)^(-1);
63if( max(temp<-100*eps) )
64 error('MATLAB:QBD_pi:InvalidRInput',...
65 'The spectral radius of R is not below 1: QBD is not pos. recurrent');
66end
67
68if (isempty(options.Boundary))
69 maxb=size(B,1)/m;
70 BR=B((maxb-1)*m+1:end,:);
71 for i=maxb-1:-1:1
72 BR=R*BR+B((i-1)*m+1:i*m,:);
73 end
74 pi=stat(BR); % compute pi_0
75 pi=pi/(pi*temp*ones(m,1)); % normalize pi_0
76 sumpi=sum(pi);
77 numit=1;
78 while (sumpi < 1-10^(-10) && numit < 1+options.MaxNumComp)
79 pi(numit+1,1:m)=pi(numit,:)*R; % compute pi_(numit+1)
80 numit=numit+1;
81 sumpi=sumpi+sum(pi(numit,:));
82 if (~mod(numit,options.Verbose))
83 fprintf('Accumulated mass after %d iterations: %d\n',numit,sumpi);
84 drawnow;
85 end
86 end
87 pi=reshape(pi',1,[]);
88else
89 mb=size(B,2) % number of states of boundary level
90 maxbm1=(size(B,1)-mb)/m % maxb - 1
91 BR1=B(mb+(maxbm1-1)*m+1:end,:);
92 for i=maxbm1-1:-1:1
93 BR1=R*BR1+B(mb+(i-1)*m+1:mb+i*m,:);
94 end
95 maxa=(size(options.Boundary,1)-mb)/m
96 BR0=options.Boundary(mb+(maxa-1)*m+1:end,:);
97 size(BR0)
98 for i=maxa-1:-1:1
99 BR0=R*BR0+options.Boundary(mb+(i-1)*m+1:mb+i*m,:);
100 end
101 pi0=stat([B(1:mb,:) options.Boundary(1:mb,:); BR0 BR1]); % compute pi_0 and pi_1
102 pi0=pi0/(pi0(1:mb)*ones(mb,1)+pi0(mb+1:end)*temp*ones(m,1)); % normalize
103 pi=pi0(mb+1:end);
104 pi0=pi0(1:mb);
105 sumpi=sum(pi0)+sum(pi);
106 numit=1;
107 while (sumpi < 1-10^(-10) && numit < options.MaxNumComp)
108 pi(numit+1,1:m)=pi(numit,:)*R; % compute pi_(numit+1)
109 numit=numit+1;
110 sumpi=sumpi+sum(pi(numit,:));
111 if (~mod(numit,options.Verbose))
112 fprintf('Accumulated mass after %d iterations: %d\n',numit,sumpi);
113 drawnow;
114 end
115 end
116 pi=[pi0 reshape(pi',1,[])];
117 numit=numit+1;
118end
119
120if (numit == 1+options.MaxNumComp)
121 warning('Maximum Number of Components %d reached',numit-1);
122end