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
7% * MAP arrival process (with m_a states)
8% the m_axm_a matrices C0 and C1 characterize the MAP arrival process
10% * MAP service process (with m_s states)
11% the m_sxm_s matrices D0 and D1 characterize the MAP service process
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)
21% USES: QBD Solver and QBD_pi from SMCSolver and Q_Sylvest
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
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
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
49% MaxNumComp: Maximum number of components for the vectors containig
50% the performance measure.
52% Verbose: When set to 1, the computation progress
is printed
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
87OptionValues{1}=[
'Direct ';
105for i=1:size(OptionNames,1)
106 options.(deblank(OptionNames(i,:)))=[];
110options.Mode='SylvesCR';
111options.MaxNumComp = 1000;
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);
120Q_CT_MAP_ParsePara(C0,'C0',C1,'C1')
121Q_CT_MAP_ParsePara(D0,'D0',D1,'D1')
123% Parse Optional Parameters
124options=Q_ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
125% Check for unused parameter
126Q_CheckUnusedParaQBD(options);
134% Test the load of the queue
144 error('MATLAB:Q_CT_MAP_MAP_1:LoadExceedsOne',...
145 'The load %d of the system exceeds one',load);
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));
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{:});
164 [G,R]=QBD_CR(Am1,A0,A1,options.OptQBD_CR{:});
167stv = QBD_pi(Am1,B0,R,
'MaxNumComp',options.MaxNumComp,
'Verbose',options.Verbose);
169ql = zeros(1,size(stv,2)/(mtot));
171 ql(i) = sum(stv((i-1)*mtot+1:i*mtot));
175% Compute Sojourn and Waiting time PH representation
179 % Compute T iteratively
180 Told=zeros(mtot,mtot);
181 eyeD0=kron(eye(ma),D0);
182 C0eye=kron(C0,eye(ms));
184 if (strfind(options.Mode,'Direct')>0)
185 eyeC0eye=kron(eye(mtot),C0eye);
186 while(max(max(abs(Told-Tnew)))>10^(-10))
188 L=-reshape(eye(mtot),1,mtot^2)*(kron(Tnew',eye(mtot))+...
190 Tnew=eyeD0+reshape(L,mtot,mtot)'*LM;
192 L=reshape(L,mtot,mtot)';
194 [U,Tr]=schur(C0,'complex');
198 while(max(max(abs(Told-Tnew)))>10^(-10))
200 L=Q_Sylvest(U,Tr,Tnew);
206 theta_tot=kron(pi_a*C1,pi_s/mu)/load;
207 nonz=find(theta_tot>0);
208 theta_tot_red=theta_tot(nonz);
211 Smat=diag(theta_tot_red)^(-1)*Tnew'*diag(theta_tot_red);
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);
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);