LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
GIM1_R.m
1function R=GIM1_R(A,Dual,Algor,varargin)
2%GIM1_R determines R matrix of a GI/M/1-Type Markov Chain
3%
4% R=GIM1_R(A,Dual,Algor) computes the minimal nonnegative solution to the
5% matrix equation R = A0 + R A1 + R^2 A2 + R^3 A3 + ... + R^max A_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
8% stochastic.
9%
10% The parameter Dual specifies whether the Ramaswami or Bright
11% duals is used. This parameter can take on 3 values:
12%
13% 'B': Uses the Bright dual
14% 'R': Uses the Ramaswami dual
15% 'A': Automatic, uses the Bright dual for a positive
16% recurrent chain and the Ramaswami dual otherwise
17%
18% The 'A' typically results in the lowest computation time (when CR is
19% used)
20%
21% The parameter Algor determines the class of algorithms used to
22% compute G. This is realized by computing the G matrix of the
23% Bright/Ramaswami Dual of the Markov chain.
24%
25% Four classes are supported:
26%
27% 'FI' : Functional Iterations [Neuts]
28% 'CR' : Cyclic Reduction [Bini, Meini]
29% 'NI' : Newton Iteration [Perez, Telek, Van Houdt]
30% 'RR' : Ramaswami Reduction [Bini, Meini, Ramaswami]
31% 'IS' : Invariant Subspace [Akar, Sohraby]
32%
33% Optional Parameters:
34%
35% See MG1_FI, MG1_CR, MG1_NI, MG1_RR and MG1_IS for the supported
36% optional parameters
37
38m=size(A,1);
39dega=size(A,2)/m-1;
40
41% compute invariant vector of A and the drift
42% drift > 1: positive recurrent GIM1, drift < 1: transient GIM1
43sumA=A(:,dega*m+1:end);
44beta=sum(sumA,2);
45% beta = (A_maxd)e + (A_maxd + A_maxd-1)e + ... + (Amaxd+...+A1)e
46for i=dega-1:-1:1
47 sumA=sumA+A(:,i*m+1:(i+1)*m);
48 beta=beta+sum(sumA,2);
49end
50sumA=sumA+A(:,1:m);
51theta=stat(sumA);
52drift=theta*beta;
53
54if (strcmp(Dual,'R')|(strcmp(Dual,'A') & drift <=1 )) % RAM dual
55 % compute the RAM Dual process
56 for i=0:dega
57 A(:,i*m+1:(i+1)*m)=diag(theta.^(-1))*A(:,i*m+1:(i+1)*m)'*diag(theta);
58 end
59else % Bright dual
60 if (drift > 1) % A -> positive recurrent GIM1
61 % compute the Caudal characteristic of A
62 eta=GIM1_Caudal(A);
63 else % A -> transient GIM1 (=recurrent MG1)
64 eta=MG1_Decay(A);
65 end
66 % compute invariant vector of A0+A1*eta+A2*eta^2+...+Amax*eta^max
67 sumAeta=eta^dega*A(:,dega*m+1:end);
68 for i=dega-1:-1:0
69 sumAeta=sumAeta+eta^i*A(:,i*m+1:(i+1)*m);
70 end
71 theta=stat(sumAeta+(1-eta)*eye(m));
72 % compute the Bright Dual process
73 for i=0:dega
74 A(:,i*m+1:(i+1)*m)=eta^(i-1)*diag(theta.^(-1))*A(:,i*m+1:(i+1)*m)'*diag(theta);
75 end
76end
77
78switch Algor
79 case 'FI'
80 G=MG1_FI(A,varargin{:});
81 case 'CR'
82 G=MG1_CR(A,varargin{:});
83 case 'NI'
84 G=MG1_NI(A,varargin{:});
85 case 'RR'
86 G=MG1_RR(A,varargin{:});
87 case 'IS'
88 G=MG1_IS(A,varargin{:});
89 otherwise
90 error('MATLAB:GIM1_R:InvalidAlgor',...
91 'Algorithm ''%s'' is not supported',Algor)
92end
93
94if (strcmp(Dual,'R')|(strcmp(Dual,'A') & drift <=1 )) % RAM dual
95 R=diag(theta.^(-1))*G'*diag(theta);
96else % Bright dual
97 R=diag(theta.^(-1))*G'*diag(theta)*eta;
98end