1function [ql,wait,soj]=Q_DT_MAP_MAP_1(C0,C1,D0,D1,varargin)
2% [ql,wait,soj] = Q_DT_MAP_MAP_1(C0,C1,D0,D1) computes the Queue length,
3% Sojourn time and Waiting time distribution of a discrete-time
7% * MAP arrival process (with m_a states)
8% the m_axm_a matrices C0 and C1 characterize MAP arrival process
10% * MAP service process (with m_s states)
11% the m_sxm_s matrices D0 and D1 characterize MAP service process
14% * Queue length distribution,
15% ql(i) = Prob[(i-1) customers in the queue]
16% * Waiting time distribution,
17% wait(i) = Prob[a customer has waiting time = (i-1)]
18% * Sojourn time distribution,
19% soj(i) = Prob[a customer has sojourn time = (i-1)]
22% Mode: The underlying function to compute the R matrix of the
23% underlying QBD can be selected using the following
24% parameter values (default:
'CR')
25%
'CR' : Cyclic Reduction [Bini, Meini]
26%
'FI' : Functional Iterations [Neuts]
27%
'IS' : Invariant Subspace [Akar, Sohraby]
28%
'LR' : Logaritmic Reduction [Latouche, Ramaswami]
29%
'NI' : Newton Iteration
31% MaxNumComp: Maximum number of components for the vectors containig
32% the performance measure.
34% Verbose: When set to 1, the computation progress
is printed
37% Optfname: Optional parameters for the underlying function fname.
38% These parameters are included in a cell with one entry holding
39% the name of the parameter and the next entry the parameter
40% value. In this function, fname can be equal to:
41%
'QBD_CR' : Options for Cyclic Reduction [Bini, Meini]
42%
'QBD_FI' : Options for Functional Iterations [Neuts]
43%
'QBD_IS' : Options for Invariant Subspace [Akar, Sohraby]
44%
'QBD_LR' : Options for Logaritmic Reduction [Latouche, Ramaswami]
45%
'QBD_NI' : Options for Newton Iteration
47% USES: QBD Solver and QBD_pi of the SMCSolver tool
76for i=1:size(OptionNames,1)
77 options.(deblank(OptionNames(i,:)))=[];
82options.MaxNumComp = 1000;
84options.OptQBD_CR=cell(0);
85options.OptQBD_FI=cell(0);
86options.OptQBD_IS=cell(0);
87options.OptQBD_LR=cell(0);
88options.OptQBD_NI=cell(0);
91Q_DT_MAP_ParsePara(C0,'C0',C1,'C1');
92Q_DT_MAP_ParsePara(D0,'D0',D1,'D1');
94% Parse Optional Parameters
95options=Q_ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
97% Parse Optional Parameters
98Q_CheckUnusedParaQBD(options);
104avga = stat(C)*C1*ones(ma,1);
110avgs = piD*D1*ones(ms,1);
115 error('MATLAB:Q_DT_MAP_MAP_1:LoadExceedsOne',...
116 'The load %d of the system exceeds one',rho);
119% Compute classic QBD blocks A0, A1 and A2
121A0 = kron(C0,D0)+kron(C1,D1);
124B0 = kron(C0,eye(ms));
125B1 = kron(C1,eye(ms));
127if (strfind(options.Mode,'FI')>0)
128 [G,R]=QBD_FI(Am1,A0,A1,options.OptQBD_FI{:});
129elseif (strfind(options.Mode,
'LR')>0)
130 [G,R]=QBD_LR(Am1,A0,A1,options.OptQBD_LR{:});
131elseif (strfind(options.Mode,
'IS')>0)
132 [G,R]=QBD_IS(Am1,A0,A1,options.OptQBD_IS{:});
133elseif (strfind(options.Mode,
'NI')>0)
134 [G,R]=QBD_NI(Am1,A0,A1,options.OptQBD_NI{:});
136 [G,R]=QBD_CR(Am1,A0,A1,options.OptQBD_CR{:});
139stv = QBD_pi(Bm1,B0,R,
'Boundary',[B1; A0+R*Am1],
'MaxNumComp',options.MaxNumComp,
'Verbose',options.Verbose);
141% Compute queue length distribution
142ql = zeros(1,size(stv,2)/mtot);
144 ql(i) = sum(stv((i-1)*mtot+1:i*mtot));
147% Compute Waiting & Sojourn time distribution
149 % 1. (number in queue, service phase) after arrival
150 stva=reshape(stv,mtot,size(stv,2)/mtot)';
151 stva=stva(2:end,:)*kron(sum(C1,2),D1)+...
152 [stva(1,:)*kron(sum(C1,2),eye(ms)); ...
153 stva(2:end-1,:)*kron(sum(C1,2),D0)];
154 stva=stva/sum(sum(stva));
156 stva=reshape(stva',1,len*ms);
157 % 2. some memory preallocation
158 wait=zeros(1,len*2*ceil(1/avgs));
159 soj=zeros(1,len*2*ceil(1/avgs));
161 temp=zeros(ms*len,1);
162 temp(1:ms)=sum(D1,2);
163 wait(1)=sum(stva(1:ms),2); % waiting time = 0
164 soj(1)=0; % sojourn time = 0
166 while (min(sum(wait),sum(soj))<1-10^(-10))
167 wait(j)=stva(ms+1:i*ms)*temp(1:(i-1)*ms);
168 soj(j)=stva(1:(i-1)*ms)*temp(1:(i-1)*ms);
169 temp=reshape(temp,ms,len);
170 temp(:,1:i)=D0*[temp(:,1:i-1) zeros(ms,1)]+D1*[zeros(ms,1) temp(:,1:i-1)];
171 temp=reshape(temp,ms*len,1);
175 wait=wait(1:max(find(wait>10^(-10))));
176 soj=soj(1:max(find(soj>10^(-10))));