LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Q_CT_MAP_MAP_1.m
1function [ql,soj_alpha,wait_alpha,Smat]=Q_CT_MAP_MAP_1(C0,C1,D0,D1,varargin)
2%[ql,soj_alpha,wait_alpha,S]=Q_CT_MAP_MAP_1(C0,C1,D0,D1)
3% computes the Sojourn time and Waiting time distribution of
4% a continuous time MAP/MAP/1/FCFS queue
5%
6% INPUT PARAMETERS:
7% * MAP arrival process (with m_a states)
8% the m_axm_a matrices C0 and C1 characterize the MAP arrival process
9%
10% * MAP service process (with m_s states)
11% the m_sxm_s matrices D0 and D1 characterize the MAP service process
12%
13% RETURN VALUES:
14% * Queue length distribution
15% ql(i) = Prob[(i-1) customers in the queue]
16% * Sojourn time distribution,
17% is PH characterized by (soj_alpha,Smat)
18% * Waiting time distribution,
19% is PH characterized by (wait_alpha,Smat)
20%
21% USES: QBD Solver and QBD_pi from SMCSolver and Q_Sylvest
22%
23% OPTIONAL PARAMETERS:
24%
25% Mode: The underlying methods used to compute the performance
26% measures. For this function two different modes can be
27% specified. The parameter value may include a specific option
28% for one of them, or a combination of one name for each option,
29% i.e., both 'Sylves', 'FI' and 'SylvesFI' are possible values
30% for this parameter.
31%
32% 1. The method to solve the linear system at each iteration of
33% the algorithm to compute matrix T (default: 'Sylves')
34% 'Sylves' : solves a Sylvester matrix equation at each step
35% using a Hessenberg algorithm
36% 'Direct' : solves the Sylvester matrix equation at each
37% step by rewriting it as a (large) system of
38% linear equations.
39%
40% 2. The underlying function to compute the R matrix of the
41% underlying QBD can be selected using the following
42% parameter values (default: 'CR')
43% 'CR' : Cyclic Reduction [Bini, Meini]
44% 'FI' : Functional Iterations [Neuts]
45% 'IS' : Invariant Subspace [Akar, Sohraby]
46% 'LR' : Logaritmic Reduction [Latouche, Ramaswami]
47% 'NI' : Newton Iteration
48%
49% MaxNumComp: Maximum number of components for the vectors containig
50% the performance measure.
51%
52% Verbose: When set to 1, the computation progress is printed
53% (default:0).
54%
55% Optfname: Optional parameters for the underlying function fname.
56% These parameters are included in a cell with one entry holding
57% the name of the parameter and the next entry the parameter
58% value. In this function, fname can be equal to:
59% 'QBD_CR' : Options for Cyclic Reduction [Bini, Meini]
60% 'QBD_FI' : Options for Functional Iterations [Neuts]
61% 'QBD_IS' : Options for Invariant Subspace [Akar, Sohraby]
62% 'QBD_LR' : Options for Logaritmic Reduction [Latouche, Ramaswami]
63% 'QBD_NI' : Options for Newton Iteration
64
65
66OptionNames=[
67 'Mode ';
68 'MaxNumComp ';
69 'Verbose ';
70 'OptQBD_CR ';
71 'OptQBD_FI ';
72 'OptQBD_IS ';
73 'OptQBD_LR ';
74 'OptQBD_NI '];
75
76OptionTypes=[
77 'char ';
78 'numeric';
79 'numeric';
80 'cell ';
81 'cell ';
82 'cell ';
83 'cell ';
84 'cell '];
85
86
87OptionValues{1}=['Direct ';
88 'Sylves ';
89 'CR ';
90 'FI ';
91 'IS ';
92 'LR ';
93 'NI ';
94 'DirectCR';
95 'DirectFI';
96 'DirectIS';
97 'DirectLR';
98 'DirectNI';
99 'SylvesCR';
100 'SylvesFI';
101 'SylvesIS';
102 'SylvesLR';
103 'SylvesNI'];
104options=[];
105for i=1:size(OptionNames,1)
106 options.(deblank(OptionNames(i,:)))=[];
107end
108
109% Default settings
110options.Mode='SylvesCR';
111options.MaxNumComp = 1000;
112options.Verbose = 0;
113options.OptQBD_CR=cell(0);
114options.OptQBD_FI=cell(0);
115options.OptQBD_IS=cell(0);
116options.OptQBD_LR=cell(0);
117options.OptQBD_NI=cell(0);
118
119% Parse Parameters
120Q_CT_MAP_ParsePara(C0,'C0',C1,'C1')
121Q_CT_MAP_ParsePara(D0,'D0',D1,'D1')
122
123% Parse Optional Parameters
124options=Q_ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
125% Check for unused parameter
126Q_CheckUnusedParaQBD(options);
127
128
129% Determine constants
130ma=size(C0,1);
131ms=size(D0,1);
132mtot=ma*ms;
133
134% Test the load of the queue
135invC0=(-C0)^(-1);
136pi_a=stat(C1*invC0);
137lambda=sum(pi_a*C1);
138invD0=(-D0)^(-1);
139pi_s=stat(D1*invD0);
140mu=sum(pi_s*D1);
141
142load=lambda/mu;
143if load >= 1
144 error('MATLAB:Q_CT_MAP_MAP_1:LoadExceedsOne',...
145 'The load %d of the system exceeds one',load);
146end
147
148% Compute Queue length
149% Compute classic QBD blocks A0, A1 and A2
150Am1 = kron(eye(ma),D1);
151A0 = kron(eye(ma),D0)+kron(C0,eye(ms));
152A1 = kron(C1,eye(ms));
153B0 = kron(C0,eye(ms));
154
155if (strfind(options.Mode,'FI')>0)
156 [G,R]=QBD_FI(Am1,A0,A1,options.OptQBD_FI{:});
157elseif (strfind(options.Mode,'LR')>0)
158 [G,R]=QBD_LR(Am1,A0,A1,options.OptQBD_LR{:});
159elseif (strfind(options.Mode,'IS')>0)
160 [G,R]=QBD_IS(Am1,A0,A1,options.OptQBD_IS{:});
161elseif (strfind(options.Mode,'NI')>0)
162 [G,R]=QBD_NI(Am1,A0,A1,options.OptQBD_NI{:});
163else
164 [G,R]=QBD_CR(Am1,A0,A1,options.OptQBD_CR{:});
165end
166
167stv = QBD_pi(Am1,B0,R,'MaxNumComp',options.MaxNumComp,'Verbose',options.Verbose);
168
169ql = zeros(1,size(stv,2)/(mtot));
170for i=1:size(ql,2)
171 ql(i) = sum(stv((i-1)*mtot+1:i*mtot));
172end
173
174
175% Compute Sojourn and Waiting time PH representation
176if(nargout > 1)
177 LM=kron(C1,D1);
178
179 % Compute T iteratively
180 Told=zeros(mtot,mtot);
181 eyeD0=kron(eye(ma),D0);
182 C0eye=kron(C0,eye(ms));
183 Tnew=eyeD0;
184 if (strfind(options.Mode,'Direct')>0)
185 eyeC0eye=kron(eye(mtot),C0eye);
186 while(max(max(abs(Told-Tnew)))>10^(-10))
187 Told=Tnew;
188 L=-reshape(eye(mtot),1,mtot^2)*(kron(Tnew',eye(mtot))+...
189 eyeC0eye)^(-1);
190 Tnew=eyeD0+reshape(L,mtot,mtot)'*LM;
191 end
192 L=reshape(L,mtot,mtot)';
193 else
194 [U,Tr]=schur(C0,'complex');
195 %U'*Tr*U = A
196 U=kron(U,eye(ms));
197 Tr=kron(Tr,eye(ms));
198 while(max(max(abs(Told-Tnew)))>10^(-10))
199 Told=Tnew;
200 L=Q_Sylvest(U,Tr,Tnew);
201 Tnew=eyeD0+L*LM;
202 end
203 end
204
205 % Compute Smat
206 theta_tot=kron(pi_a*C1,pi_s/mu)/load;
207 nonz=find(theta_tot>0);
208 theta_tot_red=theta_tot(nonz);
209 Tnew=Tnew(:,nonz);
210 Tnew=Tnew(nonz,:);
211 Smat=diag(theta_tot_red)^(-1)*Tnew'*diag(theta_tot_red);
212
213 % alpha vector of PH representation of Sojourn time
214 soj_alpha=load*(diag(theta_tot)*kron(ones(ma,1),sum(D1,2)))'/lambda;
215 soj_alpha=soj_alpha(nonz);
216
217 % alpha vector of PH representation of Waiting time
218 wait_alpha=load*(diag(theta_tot)*L*kron(sum(C1,2),sum(D1,2)))'/lambda;
219 wait_alpha=wait_alpha(nonz);
220end