1% Ret = QBDQueue(B, L, F, L0, ...)
3% Returns various performane measures of a continuous time
6% QBD queues have a background continuous time Markov chain
7% with generator Q whose the transitions can be partitioned
8% into three sets: transitions accompanied by an arrival
9% of a
new job (F, forward), transitions accompanied by
10% the service of the current job in the server (B,
11% backward) and internal transitions (L, local).
12% Thus we have Q=B+L+F. L0
is the matrix of local
13% transition rates
if the queue
is empty.
17% B : matrix, shape(N,N)
18% Transitions of the background process accompanied by
19% the service of the current job in the server
20% L : matrix, shape(N,N)
21% Internal transitions of the background process
22% that
do not generate neither arrival nor service
23% F : matrix, shape(N,N)
24% Transitions of the background process accompanied by
25% an arrival of a
new job
26% L0 : matrix, shape(N,N)
27% Internal transitions of the background process when
28% there are no jobs in the queue
30% The rest of the function parameters specify the options
31% and the performance measures to be computed.
33% The supported performance measures and options in
this
36% +----------------+--------------------+----------------------------------------+
37% | Parameter name | Input parameters | Output |
38% +================+====================+========================================+
39% |
"ncMoms" | Number of moments | The moments of the number of customers |
40% +----------------+--------------------+----------------------------------------+
41% |
"ncDistr" | Upper limit K | The distribution of the number of |
42% | | | customers from level 0 to level K-1 |
43% +----------------+--------------------+----------------------------------------+
44% |
"ncDistrMG" | None | The vector-matrix parameters of the |
45% | | | matrix-geometric distribution of the |
46% | | | number of customers in the system |
47% +----------------+--------------------+----------------------------------------+
48% |
"ncDistrDPH" | None | The vector-matrix parameters of the |
49% | | | matrix-geometric distribution of the |
50% | | | number of customers in the system, |
51% | | | converted to a discrete PH |
52% | | | representation |
53% +----------------+--------------------+----------------------------------------+
54% |
"stMoms" | Number of moments | The sojourn time moments |
55% +----------------+--------------------+----------------------------------------+
56% |
"stDistr" | A vector of points | The sojourn time distribution at the |
57% | | | requested points (cummulative, cdf) |
58% +----------------+--------------------+----------------------------------------+
59% |
"stDistrME" | None | The vector-matrix parameters of the |
60% | | | matrix-exponentially distributed |
61% | | | sojourn time distribution |
62% +----------------+--------------------+----------------------------------------+
63% |
"stDistrPH" | None | The vector-matrix parameters of the |
64% | | | matrix-exponentially distributed |
65% | | | sojourn time distribution, converted |
66% | | | to a continuous PH representation |
67% +----------------+--------------------+----------------------------------------+
68% |
"prec" | The precision | Numerical precision used as a stopping |
69% | | | condition when solving the |
70% | | | matrix-quadratic equation |
71% +----------------+--------------------+----------------------------------------+
73% (The quantities related to the number of customers in
74% the system include the customer in the server, and the
75% sojourn time related quantities include the service
80% Ret : list of the performance measures
81% Each entry of the list corresponds to a performance
82% measure requested. If there
is just a single item,
83% then it
is not put into a list.
87%
"ncDistrMG" and
"stDistrMG" behave much better numerically than
88%
"ncDistrDPH" and
"stDistrPH".
90function varargout = QBDQueue(B, L, F, L0, varargin)
96 for i=1:length(varargin)
97 if strcmp(varargin{i},
'prec')
99 eaten = [eaten, i, i+1];
100 elseif length(varargin{i})>2 && strcmp(varargin{i}(1:2),
'st')
105 global BuToolsCheckInput;
107 if isempty(BuToolsCheckInput)
108 BuToolsCheckInput = true;
111 if BuToolsCheckInput && ~CheckGenerator(B+L+F)
112 error('QBDQueue: The matrix sum (B+L+F)
is not a valid generator of a Markov chain!');
115 if BuToolsCheckInput && ~CheckGenerator(L0+F)
116 error('QBDQueue: The matrix sum (L0+F)
is not a valid generator of a Markov chain!');
119 [pi0, R] = QBDSolve (B, L, F, L0, prec);
126 eta = pi0*F*inv(I-Rh);
128 z = reshape(I,N*N,1);
133 while argIx<=length(varargin)
134 if any(ismember(eaten, argIx))
137 elseif strcmp(varargin{argIx},
'ncDistrDPH')
138 % transform it to DPH
139 alpha = pi0*R*inv(eye(N)-R);
140 A = inv(diag(alpha))*R
'*diag(alpha);
143 elseif strcmp(varargin{argIx},'ncDistrMG
')
145 B = SimilarityMatrixForVectors(sum(inv(I-R)*R,2), ones(N,1));
151 elseif strcmp(varargin{argIx},'ncMoms
')
152 numOfMoms = varargin{argIx+1};
154 moms = zeros(1,numOfMoms);
157 moms(m) = factorial(m)*sum(pi0*iR^(m+1)*R^m);
159 Ret{end+1} = MomsFromFactorialMoms(moms);
160 elseif strcmp(varargin{argIx},'ncDistr
')
161 numOfQLProbs = varargin{argIx+1};
163 values = zeros(1,numOfQLProbs);
164 values(1) = sum(pi0);
166 for p=1:numOfQLProbs-1
168 values(p+1) = sum(pi0*RPow);
171 elseif strcmp(varargin{argIx},'stDistrPH
')
172 % transform to ph distribution
176 A = kron(L+F,I(nz,nz)) + kron(B,inv(Delta(nz,nz))*Rh(nz,nz)'*Delta(nz,nz));
177 alpha = z
'*kron(I,Delta(:,nz));
180 elseif strcmp(varargin{argIx},'stDistrME
')
181 % transform it such that the closing vector is a vector of ones
182 % this is the way butools accepts ME distributions
183 Bm = SimilarityMatrixForVectors(z,ones(length(z),1));
185 A = Bm * (kron(L'+F
',I) + kron(B',Rh)) * Bmi;
186 alpha = kron(ones(1,N), eta) * Bmi;
189 elseif strcmp(varargin{argIx},
'stMoms')
190 numOfMoms = varargin{argIx+1};
192 moms = zeros(1,numOfMoms);
193 Z = kron(L
'+F',I)+kron(B
',Rh);
196 moms(m) = factorial(m)*sum(kron(ones(1,N), eta)*iZ^(m+1)*(-Z)*z);
199 elseif strcmp(varargin{argIx},'stDistr
')
200 points = varargin{argIx+1};
202 values = zeros(size(points));
203 Z = kron(L'+F
',I)+kron(B',Rh);
204 for p=1:length(points)
205 values(p) = 1-sum(kron(ones(1,N), eta)*expm(Z*points(p))*z);
209 error ([
'QBDQueue: Unknown parameter ' varargin{argIx}])