1% Ret = MMAPPH1FCFS(D, sigma, S, ...)
3% Returns various performane measures of a
MMAP[K]/PH[K]/1
4% first-come-first-serve queue, see [1]_.
8% D : list of matrices of shape (N,N), length (K+1)
9% The D0...DK matrices of the arrival process.
10% sigma : list of row vectors, length (K)
11% The list containing the initial probability vectors of the service
12% time distributions of the various customer types. The length of the
13% vectors does not have to be the same.
14% S : list of square matrices, length (K)
15% The transient generators of the phase type distributions representing
16% the service time of the jobs belonging to various types.
18% The rest of the function parameters specify the options
19% and the performance measures to be computed.
21% The supported performance measures and options in
this
24% +----------------+--------------------+----------------------------------------+
25% | Parameter name | Input parameters | Output |
26% +================+====================+========================================+
27% |
"ncMoms" | Number of moments | The moments of the number of customers |
28% +----------------+--------------------+----------------------------------------+
29% |
"ncDistr" | Upper limit K | The distribution of the number of |
30% | | | customers from level 0 to level K-1 |
31% +----------------+--------------------+----------------------------------------+
32% |
"stMoms" | Number of moments | The sojourn time moments |
33% +----------------+--------------------+----------------------------------------+
34% |
"stDistr" | A vector of points | The sojourn time distribution at the |
35% | | | requested points (cummulative, cdf) |
36% +----------------+--------------------+----------------------------------------+
37% |
"stDistrME" | None | The vector-matrix parameters of the |
38% | | | matrix-exponentially distributed |
39% | | | sojourn time distribution |
40% +----------------+--------------------+----------------------------------------+
41% |
"stDistrPH" | None | The vector-matrix parameters of the |
42% | | | matrix-exponentially distributed |
43% | | | sojourn time distribution, converted |
44% | | | to a continuous PH representation |
45% +----------------+--------------------+----------------------------------------+
46% |
"prec" | The precision | Numerical precision used as a stopping |
47% | | | condition when solving the Riccati |
49% +----------------+--------------------+----------------------------------------+
50% |
"classes" | Vector of integers | Only the performance measures |
51% | | | belonging to these
classes are |
52% | | | returned. If not given, all
classes |
53% | | | are analyzed. |
54% +----------------+--------------------+----------------------------------------+
56% (The quantities related to the number of customers in
57% the system include the customer in the server, and the
58% sojourn time related quantities include the service
63% Ret : list of the performance measures
64% Each entry of the list corresponds to a performance
65% measure requested. Each entry
is a matrix, where the
66% columns belong to the various job types.
67% If there
is just a single item,
68% then it
is not put into a list.
72% .. [1] Qiming He,
"Analysis of a continuous time
73% SM[K]/PH[K]/1/FCFS queue: Age process, sojourn times,
74% and queue lengths", Journal of Systems Science and
75% Complexity, 25(1), pp 133-155, 2012.
77function varargout = MMAPPH1FCFS(D, sigma, S, varargin)
85 for i=1:length(varargin)
86 if strcmp(varargin{i},
'prec')
87 precision = varargin{i+1};
88 eaten = [eaten, i, i+1];
89 elseif strcmp(varargin{i},
'classes')
91 eaten = [eaten, i, i+1];
95 global BuToolsCheckInput;
97 if isempty(BuToolsCheckInput)
98 BuToolsCheckInput =
true;
101 if BuToolsCheckInput && ~CheckMMAPRepresentation(D)
102 error(
'MMAPPH1FCFS: The arrival process is not a valid MMAP representation!');
107 if ~CheckPHRepresentation(sigma{k},S{k})
108 error(
'MMAPPH1FCFS: the vector and matrix describing the service times is not a valid PH representation!');
113 % Various properties of the arrival and service processes
121 theta = CTMCSolve(D0+Da);
128 lambda(k) = sum(theta*D{k+1});
129 beta{k} = CTMCSolve(S{k} - sum(S{k},2)*sigma{k});
130 mu(k) = sum(beta{k}*(-S{k}));
131 Nsk(k) = size(S{k},1);
132 ro = ro + lambda(k)/mu(k);
134 alpha = theta*Da/sum(lambda);
143 sv{1} = -sum(S{1},2);
147 sa{q} = zeros(1,length(sigma{1}));
148 ba{q} = zeros(1,length(beta{1}));
149 sv{q} = zeros(length(sigma{1}),1);
153 Sa = blkdiag (Sa, S{k});
156 sa{q} = [sa{q} sigma{k}];
157 ba{q} = [ba{q} beta{k}];
158 sv{q} = [sv{q}; -sum(S{k},2)];
160 sa{q} = [sa{q} zeros(size(sigma{k}))];
161 ba{q} = [ba{q} zeros(size(beta{k}))];
162 sv{q} = [sv{q}; zeros(length(sigma{k}),1)];
167 iVec = kron(D{2},sa{1});
169 iVec = iVec + kron(D{k+1},sa{k});
174 % step 1. solve the age process of the queue
175 % ==========================================
177 % solve Y0 and calculate T
178 Y0 = FluidFundamentalMatrices (kron(Ia,Sa), kron(Ia,-sum(Sa,2)), iVec, D0,
'P', precision);
179 T = kron(Ia,Sa) + Y0 * iVec;
181 % calculate pi0 and v0
182 pi0 = zeros(1,size(T,1));
184 pi0 = pi0 + kron(theta*D{k+1},ba{k}/mu(k));
191 % step 2. calculate performance measures
192 % ======================================
196 clo = iT*kron(oa,sv{k});
197 while argIx<=length(varargin)
198 if any(ismember(eaten, argIx))
201 elseif strcmp(varargin{argIx},
'stMoms')
202 numOfSTMoms = varargin{argIx+1};
203 rtMoms = zeros(1,numOfSTMoms);
205 rtMoms(m) = factorial(m) * pi0 * iT^m * clo / (pi0*clo);
209 elseif strcmp(varargin{argIx},
'stDistr')
210 stCdfPoints = varargin{argIx+1};
213 pr = 1 - pi0 * expm(T*t) * clo / (pi0*clo);
218 elseif strcmp(varargin{argIx},
'stDistrME')
219 Bm = SimilarityMatrixForVectors(clo/(pi0*clo),ones(N*Ns,1));
225 elseif strcmp(varargin{argIx},
'stDistrPH')
228 nz = ix(vv>precision);
229 delta = diag(vv(nz));
230 cl = -T*clo/(pi0*clo);
231 alpha = cl(nz,:)
'*delta;
232 A = inv(delta)*T(nz,nz)'*delta;
235 elseif strcmp(varargin{argIx},
'ncDistr')
236 numOfQLProbs = varargin{argIx+1};
238 values = zeros(1,numOfQLProbs);
240 jm(sum(Nsk(1:k-1))+1:sum(Nsk(1:k)),:) = 1;
242 jmc(sum(Nsk(1:k-1))+1:sum(Nsk(1:k)),:) = 0;
243 LmCurr = lyap(T, kron(D0+Da-D{k+1},Is), eye(N*Ns));
244 values(1) = 1-ro+pi0*LmCurr*kron(oa,jmc);
245 for i=1:numOfQLProbs-1
247 LmCurr = lyap(T, kron(D0+Da-D{k+1},Is), LmPrev*kron(D{k+1},Is));
248 values(i+1) = pi0*LmCurr*kron(oa,jmc) + pi0*LmPrev*kron(oa,jm);
251 elseif strcmp(varargin{argIx},
'ncMoms')
252 numOfQLMoms = varargin{argIx+1};
254 jm(sum(Nsk(1:k-1))+1:sum(Nsk(1:k)),:) = 1;
255 ELn = {lyap(T, kron(D0+Da,Is), eye(N*Ns))};
256 qlMoms = zeros(1,numOfQLMoms);
261 Btag = Btag + bino * ELn{i+1};
262 bino = bino * (n-i) / (i+1);
264 ELn{n+1} = lyap(T, kron(D0+Da,Is), Btag*kron(D{k+1},Is));
265 qlMoms(n) = sum(pi0*ELn{n+1}) + pi0*Btag*kron(oa,jm);
270 error ([
'MMAPPH1FCFS: Unknown parameter ' varargin{argIx}])