1% Ret = FluFluQueue(Qin, Rin, Qout, Rout, srv0stop, ...)
3% Returns various performane measures of a fluid queue
4% with independent fluid arrival and service processes.
6% Two types of boundary behavior
is available. If
7% srv0stop=
false, the output process evolves continuously
8% even
if the queue
is empty. If srv0stop=
true, the
9% output process slows down
if there
is fewer fluid in
10% the queue than it can serve. If the queue
is empty
11% and the fluid input rate
is zero, the output process
12% freezes till fluid arrives.
16% Qin : matrix, shape (N,N)
17% The generator of the background Markov chain
18% corresponding to the input process
19% Rin : matrix, shape (N,N)
20% Diagonal matrix containing the fluid input rates
21% associated to the states of the input background
23% Qout : matrix, shape (N,N)
24% The generator of the background Markov chain
25% corresponding to the output process
26% Rout : matrix, shape (N,N)
27% Diagonal matrix containing the fluid output rates
28% associated to the states of the input background
31% If
true, the service output process slows down
if
32% there
is fewer fluid in the queue than it can
33% serve. If
false, the output process evolves
36% The rest of the function parameters specify the options
37% and the performance measures to be computed.
39% The supported performance measures and options in
this
42% +----------------+--------------------+--------------------------------------+
43% | Parameter name | Input parameters | Output |
44% +================+====================+======================================+
45% |
"flMoms" | Number of moments | The moments of the fluid level |
46% +----------------+--------------------+--------------------------------------+
47% |
"flDistr" | A vector of points | The fluid level distribution at |
48% | | | the requested points (cdf) |
49% +----------------+--------------------+--------------------------------------+
50% |
"flDistrME" | None | The vector-matrix parameters of the |
51% | | | matrix-exponentially distributed |
52% | | | fluid level distribution |
53% +----------------+--------------------+--------------------------------------+
54% |
"flDistrPH" | None | The vector-matrix parameters of the |
55% | | | matrix-exponentially distributed |
56% | | | fluid level distribution, converted |
57% | | | to a PH representation |
58% +----------------+--------------------+--------------------------------------+
59% |
"stMoms" | Number of moments | The sojourn time moments of fluid |
61% +----------------+--------------------+--------------------------------------+
62% |
"stDistr" | A vector of points | The sojourn time distribution at the |
63% | | | requested points (cummulative, cdf) |
64% +----------------+--------------------+--------------------------------------+
65% |
"stDistrME" | None | The vector-matrix parameters of the |
66% | | | matrix-exponentially distributed |
67% | | | sojourn time distribution |
68% +----------------+--------------------+--------------------------------------+
69% |
"stDistrPH" | None | The vector-matrix parameters of the |
70% | | | matrix-exponentially distributed |
71% | | | sojourn time distribution, converted |
72% | | | to a PH representation |
73% +----------------+--------------------+--------------------------------------+
74% |
"prec" | The precision | Numerical precision to check
if the |
75% | | | input
is valid and it
is also used |
76% | | | as a stopping condition when solving |
77% | | | the Riccati equation |
78% +----------------+--------------------+--------------------------------------+
82% Ret : list of the performance measures
83% Each entry of the list corresponds to a performance
84% measure requested. If there
is just a single item,
85% then it
is not put into a list.
89%
"flDistrME" and
"stDistrME" behave much better numerically than
90%
"flDistrPH" and
"stDistrPH".
94% .. [1] Horvath G, Telek M,
"Sojourn times in fluid queues
95% with independent and dependent input and output
96% processes PERFORMANCE EVALUATION 79: pp. 160-181, 2014.
98function varargout = FluFluQueue(Qin, Rin, Qout, Rout, srv0stop, varargin)
105 for i=1:length(varargin)
106 if strcmp(varargin{i},'prec')
107 prec = varargin{i+1};
108 eaten = [eaten, i, i+1];
109 elseif length(varargin{i})>2 && strcmp(varargin{i}(1:2),'st')
111 elseif length(varargin{i})>2 && strcmp(varargin{i}(1:2),'fl')
116 global BuToolsCheckInput;
118 if isempty(BuToolsCheckInput)
119 BuToolsCheckInput = true;
121 global BuToolsCheckPrecision;
123 if BuToolsCheckInput && ~CheckGenerator(Qin,false)
124 error('FluFlu: Generator matrix Qin is not Markovian!');
126 if BuToolsCheckInput && ~CheckGenerator(Qout,false)
127 error('FluFlu: Generator matrix Qout is not Markovian!');
129 if BuToolsCheckInput && (any(diag(Rin)<-BuToolsCheckPrecision) || any(diag(Rout)<-BuToolsCheckPrecision))
130 error('FluFlu: Fluid rates Rin and Rout must be non-negative !');
133 Iin = eye(size(Qin));
134 Iout = eye(size(Qout));
137 Q = kron(Qin,Iout)+kron(Iin,Qout);
139 Q0 = kron(Qin,Iout)+kron(Rin, pinv(Rout)*Qout);
143 [mass0, ini, K, clo] = GeneralFluidSolve (Q, kron(Rin,Iout)-kron(Iin,Rout), Q0, prec);
146 Rh = kron(Rin,Iout) - kron(Iin,Rout);
147 Qh = kron(Qin, Rout) + kron(Rin, Qout);
148 [massh, inih, Kh, cloh] = GeneralFluidSolve (Qh, Rh, [], prec);
150 % sojourn time density in case of
151 % srv0stop = false: inih*expm(Kh*x)*cloh*kron(Rin,Iout)/lambda
152 % srv0stop = true: inih*expm(Kh*x)*cloh*kron(Rin,Rout)/lambda/mu
154 lambda = sum(CTMCSolve(Qin)*Rin);
155 mu = sum(CTMCSolve(Qout)*Rout);
160 while argIx<=length(varargin)
161 if any(ismember(eaten, argIx))
164 elseif strcmp(varargin{argIx},'flDistrPH')
166 Delta = diag(linsolve(K',-ini')); % Delta = diag (ini*inv(-K));
167 A = inv(Delta)*K'*Delta;
168 alpha = sum(clo,2)'*Delta;
171 elseif strcmp(varargin{argIx},'flDistrME')
173 B = SimilarityMatrixForVectors(inv(-K)*sum(clo,2), ones(size(K,1),2));
179 elseif strcmp(varargin{argIx},'flMoms')
180 numOfMoms = varargin{argIx+1};
182 moms = zeros(1,numOfMoms);
185 moms(m) = factorial(m)*sum(ini*iK^(m+1)*clo);
188 elseif strcmp(varargin{argIx},'flDistr')
189 points = varargin{argIx+1};
191 values = zeros(size(points));
193 for p=1:length(points)
194 values(p) = sum(mass0) + sum(ini*(eye(size(K,1))-expm(K*points(p)))*iK*clo);
197 elseif strcmp(varargin{argIx},'stDistrPH')
198 % convert result to PH representation
199 Delta = diag(linsolve(Kh',-inih')); % Delta = diag (inih*inv(-Kh));
200 A = inv(Delta)*Kh'*Delta;
202 alpha = sum(Delta*cloh*kron(Rin,Iout)/lambda,2)';
204 alpha = sum(Delta*cloh*kron(Rin,Rout)/lambda/mu,2)';
208 elseif strcmp(varargin{argIx},'stDistrME')
209 % convert result to ME representation
211 B = SimilarityMatrixForVectors(sum(cloh*kron(Rin,Iout)/lambda,2), ones(size(Kh,1),1));
213 B = SimilarityMatrixForVectors(sum(cloh*kron(Rin,Rout)/lambda/mu,2), ones(size(Kh,1),1));
217 alpha = inih*inv(-Kh)*iB;
220 elseif strcmp(varargin{argIx},'stMoms')
221 numOfMoms = varargin{argIx+1};
223 moms = zeros(1,numOfMoms);
225 kclo = cloh*kron(Rin,Rout)/lambda/mu;
227 kclo = cloh*kron(Rin,Iout)/lambda;
231 moms(m) = factorial(m)*sum(inih*iKh^(m+1)*kclo);
234 elseif strcmp(varargin{argIx},'stDistr')
235 points = varargin{argIx+1};
237 values = zeros(size(points));
239 kclo = cloh*kron(Rin,Rout)/lambda/mu;
241 kclo = cloh*kron(Rin,Iout)/lambda;
244 for p=1:length(points)
245 values(p) = 1-sum(inih*expm(Kh*points(p))*iKh*kclo);
249 error (['FluFluQueue: Unknown parameter ' varargin{argIx}])