1function [ql,wait_alpha,Smat]=Q_CT_MAP_M_C(D0,D1,mu,c,varargin)
2% [ql,wait_alpha,Smat]=Q_CT_MAP_M_C(D0,D1,mu,c) computes the Queuelength
3% and waiting time distribution of a MAP/M/c/FCFS queue
6% * MAP(D0,D1) arrival process (with m states)
8% * mu exponential service rate
10% * c number of servers
13% * Queue length distribution,
14% ql(i) = Prob[(i-1) customers in the queue]
16% * Waiting time distribution,
17%
is PH characterized by (wait_alpha,Smat)
19% USES: USES: QBD Solver from SMCSolver and Q_Sylvest
23% Mode: The underlying methods used to compute the performance
24% measures. For
this function two different modes can be
25% specified. The parameter value may include a specific option
26%
for one of them, or a combination of one name
for each option,
27% i.e., both
'Sylves',
'FI' and
'SylvesFI' are possible values
30% 1. The method to solve the linear system at each iteration of
31% the algorithm to compute matrix T (
default:
'Sylves')
32%
'Sylves' : solves a Sylvester matrix equation at each step
33% using a Hessenberg algorithm
34%
'Direct' : solves the Sylvester matrix equation at each
35% step by rewriting it as a (large) system of
38% 2. The underlying function to compute the R matrix of the
39% underlying QBD can be selected using the following
40% parameter values (default:
'CR')
41%
'CR' : Cyclic Reduction [Bini, Meini]
42%
'FI' : Functional Iterations [Neuts]
43%
'IS' : Invariant Subspace [Akar, Sohraby]
44%
'LR' : Logaritmic Reduction [Latouche, Ramaswami]
45%
'NI' : Newton Iteration
47% MaxNumComp: Maximum number of components for the vectors containig
48% the performance measure.
50% Verbose: When set to 1, the progress of the computation
is printed
53% Optfname: Optional parameters for the underlying function fname.
54% These parameters are included in a cell with one entry holding
55% the name of the parameter and the next entry the parameter
56% value. In this function, fname can be equal to:
57%
'QBD_CR' : Options for Cyclic Reduction [Bini, Meini]
58%
'QBD_FI' : Options for Functional Iterations [Neuts]
59%
'QBD_IS' : Options for Invariant Subspace [Akar, Sohraby]
60%
'QBD_LR' : Options for Logaritmic Reduction [Latouche, Ramaswami]
61%
'QBD_NI' : Options for Newton Iteration
85OptionValues{1}=[
'Direct ';
104for i=1:size(OptionNames,1)
105 options.(deblank(OptionNames(i,:)))=[];
109options.Mode='SylvesCR';
110options.MaxNumComp = 1000;
112options.OptQBD_CR=cell(0);
113options.OptQBD_FI=cell(0);
114options.OptQBD_IS=cell(0);
115options.OptQBD_LR=cell(0);
116options.OptQBD_NI=cell(0);
120 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
121 'the service rate mu has to be numeric');
124 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
125 'the number of servers c has to be numeric');
129 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
130 'the service rate mu has to be real');
133 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
134 'the number of servers c has to be real');
136if (ceil(c)-floor(c)>0)
137 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
138 'the number of servers c has to be an integer');
142 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
143 'the service rate mu has to be strictly positive');
146 error('MATLAB:Q_CT_MAP_M_C_ParsePara:InvalidInput',...
147 'the number of servers c has to be strictly positive');
150Q_CT_MAP_ParsePara(D0,'D0',D1,'D1')
153% Parse Optional Parameters
154options=Q_ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
155% Check for unused parameter
156Q_CheckUnusedParaQBD(options);
159% Test the load of the queue
166 error('MATLAB:Q_CT_MAP_M_C:LoadExceedsOne',...
167 'The load %d of the system exceeds one',load);
173A1 = D0 - c*mu*eye(m);
177if (strfind(options.Mode,'FI')>0)
178 [G,R]=QBD_FI(A0,A1,A2,options.OptQBD_FI{:});
179elseif (strfind(options.Mode,
'LR')>0)
180 [G,R]=QBD_LR(A0,A1,A2,options.OptQBD_LR{:});
181elseif (strfind(options.Mode,
'IS')>0)
182 [G,R]=QBD_IS(A0,A1,A2,options.OptQBD_IS{:});
183elseif (strfind(options.Mode,
'NI')>0)
184 [G,R]=QBD_NI(A0,A1,A2,options.OptQBD_NI{:});
186 [G,R]=QBD_CR(A0,A1,A2,options.OptQBD_CR{:});
189%Gaver-Jacobs-Latouche LD-QBD
195 invC{i} = inv(-D0+(i-1)*mu*eye(m) - (i-1)*mu*invC{i-1}*D1);
198 piGJL((c-1)*m+1:c*m) = stat(D0-(c-1)*mu*eye(m) + R*A0 + (c-1)*mu*invC{c-1}*D1 + eye(m));
200 piGJL((i-1)*m+1:i*m) = piGJL(i*m+1:(i+1)*m)*i*mu*invC{i};
203 piGJL(1:m) = stat(D0 + R*A0 + eye(m));
205K = sum(piGJL(1:(c-1)*m)) + piGJL((c-1)*m+1:c*m)*sum(inv(eye(m)-R),2);
208piC1 = piGJL((c-1)*m+1:c*m);
213while (sumpi < 1-10^(-10) && numit < 1+options.MaxNumComp-c)
214 piC1(numit+1,1:m)=piC1(numit,:)*R;
216 sumpi=sumpi+sum(piC1(numit,:));
217 if (~mod(numit,options.Verbose))
218 fprintf(
'Accumulated mass after %d iterations: %d\n',numit,sumpi);
223piC1=reshape(piC1
',1,[]);
224piT = [piGJL(1:(c-1)*m) piC1];
226% Queue length distribution
229 ql(i) = sum(piGJL((i-1)*m+1:i*m));
234% Waiting time distribution
236 % a) Probability waiting = 0 and alpha vector
237 prob_zero=sum(reshape(piGJL(1:c*m),m,c)
'*sum(D1,2));
238 prob_zero=prob_zero/sum(reshape(piT,m,size(piT,2)/m)'*sum(D1,2));
239 temp=piGJL((c-1)*m+1:c*m)*(eye(m)-R)^(-1)*D1;
240 alpha_vec=temp/sum(temp);
242 % b) Ph representation
243 % Compute Sojourn and Waiting time
245 Tnew=-A0; % A0=eye(m)*mu*c
246 if (strfind(options.Mode,
'Direct')>0)
247 while(max(max(abs(Told-Tnew)))>10^(-10))
249 L=-reshape(eye(m),1,m^2)*(kron(Tnew
',eye(m))+...
250 kron(eye(m),D0))^(-1);
251 Tnew=-A0+reshape(L,m,m)'*D1*mu*c;
255 [U,Tr]=schur(D0,'complex
');
257 while(max(max(abs(Told-Tnew)))>10^(-10))
259 L=Q_Sylvest(U,Tr,Tnew);
266 nonz=find(theta_tot>0);
267 theta_tot_red=theta_tot(nonz);
270 Smat=diag(theta_tot_red)^(-1)*Tnew
'*diag(theta_tot_red);
273 % alpha vector of PH representation of Waiting time
274 rho_vec=sum(Tnew+A0,2);
275 wait_alpha=alpha_vec.*rho_vec'/(alpha_vec*rho_vec);
276 wait_alpha=(1-prob_zero)*wait_alpha(nonz);