LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_mwrbb.m
1%{
2 % @brief Majumdar-Woodside robust box bounds on throughput for closed
3 % multiclass queueing networks with mixed scheduling disciplines.
4 %
5 % @details
6 % Computes distribution-insensitive (NBUE) upper and lower bounds on the
7 % per-class system throughput of a closed multiclass queueing network, as
8 % defined by Majumdar and Woodside, "Robust bounds and throughput guarantees
9 % for closed multiclass queueing networks", Performance Evaluation 32 (1998)
10 % 101-136. The upper bound intersects the no-contention bound (eq. 2) with
11 % the utilization-based bound (eq. 3) and is independent of the scheduling
12 % discipline. The lower bound is the multiclass throughput guarantee of
13 % Theorem 2 (eq. 15): X_c >= N_c / (Z_c + sum_k V_kc (S_kc + d_kc^+)), where
14 % the per-visit queueing delay bound d_kc^+ depends on the discipline at
15 % station k -- FIFO (Theorem 1 / eq. 6, via Lemma 1), processor sharing
16 % (Lemma 2), preemptive priority (Lemma 3) and non-preemptive priority
17 % (Lemmas 4-5). The coupled inequalities are resolved by the interval-
18 % narrowing fixed point that reproduces the BNR-Prolog robust box bounds;
19 % for a single FIFO class it reduces to the Muntz-Wong asymptotic bounds.
20 %
21 % Bounds are insensitive to the service-time distributions (only NBUE is
22 % assumed) and to routing dependencies; only the mean visits V, mean service
23 % demands S, populations N, think times Z, per-station disciplines and per-
24 % class priorities are required. The think time Z aggregates the pure-delay
25 % (infinite-server) stations; only queueing stations are passed in V,S.
26 %
27 % @par Syntax:
28 % @code
29 % [Xlo,Xup,Wlo] = pfqn_mwrbb(V,S,N,Z,sched,prio)
30 % @endcode
31 %
32 % @par Parameters:
33 % <table>
34 % <tr><th>Name<th>Description
35 % <tr><td>V<td>(K x C) mean visits of class c at queueing station k
36 % <tr><td>S<td>(K x C) mean service demand per visit of class c at station k
37 % <tr><td>N<td>(1 x C) population of class c
38 % <tr><td>Z<td>(1 x C) think time (pure delay) of class c
39 % <tr><td>sched<td>(K x 1) discipline code per station: 0=FIFO (default),
40 % 1=PS, 2=non-preemptive priority, 3=preemptive priority,
41 % 4=ABA full-contention (discipline-independent, P_cm=1)
42 % <tr><td>prio<td>(1 x C) class priority, lower value = higher priority
43 % (default: all equal). Used only at priority stations.
44 % </table>
45 %
46 % @par Returns:
47 % <table>
48 % <tr><th>Name<th>Description
49 % <tr><td>Xlo<td>(1 x C) lower bound on class throughput (Theorem 2)
50 % <tr><td>Xup<td>(1 x C) upper bound on class throughput (eqs. 2-3)
51 % <tr><td>Wlo<td>(K x C) per-visit residence time at station k for class c
52 % consistent with the lower throughput bound
53 % </table>
54%}
55function [Xlo,Xup,Wlo] = pfqn_mwrbb(V,S,N,Z,sched,prio)
56[K,C] = size(V);
57N = N(:).';
58if nargin < 4 || isempty(Z)
59 Z = zeros(1,C);
60end
61Z = Z(:).';
62if nargin < 5 || isempty(sched)
63 sched = zeros(K,1);
64end
65sched = sched(:);
66if nargin < 6 || isempty(prio)
67 prio = zeros(1,C);
68end
69prio = prio(:).';
70
71% no-contention upper bound on the cycle rate f_c = X_c/N_c (eqs. 1-2)
72fup = zeros(1,C);
73for c = 1:C
74 fup(c) = 1 / (Z(c) + sum(V(:,c).*S(:,c)));
75end
76flo = zeros(1,C);
77
78maxiter = 20000;
79tol = 1e-13;
80for it = 1:maxiter
81 fup_old = fup; flo_old = flo;
82
83 % utilization-based narrowing of the upper bounds (eq. 3)
84 for c = 1:C
85 cap = fup(c);
86 for k = 1:K
87 other = 0;
88 for m = 1:C
89 if m ~= c
90 other = other + N(m)*V(k,m)*S(k,m)*flo(m);
91 end
92 end
93 denomk = N(c)*V(k,c)*S(k,c);
94 if denomk > 0
95 cap = min(cap, (1 - other)/denomk);
96 end
97 end
98 fup(c) = min(fup(c), max(cap,0));
99 end
100
101 % lower-bound narrowing (Theorem 2, eq. 15). The higher-priority delay at
102 % a priority station carries a 1/f_c factor and is isolated algebraically
103 % as Bh so that f_c = (1 - Bh) / DEN.
104 for c = 1:C
105 [DEN,Bh] = mwrbb_denom(c,V,S,N,Z,fup,flo,sched,prio);
106 val = (1 - Bh)/DEN;
107 if val < 0, val = 0; end
108 flo(c) = max(flo(c), val);
109 end
110
111 if max(abs(fup-fup_old)) < tol && max(abs(flo-flo_old)) < tol
112 break;
113 end
114end
115
116Xlo = N .* flo;
117Xup = N .* fup;
118
119% per-visit residence at converged rates, consistent with the lower bound
120Wlo = zeros(K,C);
121for c = 1:C
122 for k = 1:K
123 if V(k,c) == 0
124 continue;
125 end
126 Wlo(k,c) = mwrbb_residence(k,c,V,S,N,fup,flo,sched,prio);
127 end
128end
129end
130
131% ------------------------------------------------------------------------
132% Lower-bound denominator DEN and isolated higher-priority work Bh for class c.
133function [DEN,Bh] = mwrbb_denom(c,V,S,N,Z,fup,flo,sched,prio)
134[K,C] = size(V);
135DEN = Z(c);
136Bh = 0;
137fc = flo(c);
138for k = 1:K
139 Vkc = V(k,c);
140 if Vkc == 0
141 continue;
142 end
143 d = sched(k);
144 if d == 3 || d == 2 % priority stations contribute to Bh
145 for m = 1:C
146 if prio(m) < prio(c)
147 Bh = Bh + N(m)*fup(m)*V(k,m)*S(k,m);
148 end
149 end
150 end
151 W = mwrbb_station_wrest(k,c,V,S,N,fup,fc,sched,prio);
152 DEN = DEN + Vkc*W;
153end
154end
155
156% ------------------------------------------------------------------------
157% Per-visit residence at station k for class c EXCLUDING the isolated higher-
158% priority (1/f_c) term. Includes own service and all bounded delay terms.
159function W = mwrbb_station_wrest(k,c,V,S,N,fup,fc,sched,prio)
160C = size(V,2);
161Vkc = V(k,c);
162Skc = S(k,c);
163d = sched(k);
164if d == 0 % FIFO (Theorem 1 / Lemma 1)
165 s = 0;
166 for m = 1:C
167 if fc*Vkc == 0, pcm = 1; else pcm = min(1,(fup(m)*V(k,m))/(fc*Vkc)); end
168 s = s + N(m)*S(k,m)*pcm;
169 end
170 W = s; % own service is the m=c term (= N_c S_kc)
171elseif d == 1 % processor sharing (Lemma 2)
172 dp = 0;
173 for m = 1:C
174 Ncont = N(m); if m == c, Ncont = N(c)-1; end
175 if fc*Vkc == 0, term = Skc; else term = min(Skc,(fup(m)*V(k,m)*S(k,m))/(fc*Vkc)); end
176 dp = dp + Ncont*term;
177 end
178 W = Skc + dp;
179elseif d == 4 % ABA full-contention (discipline-independent, P_cm = 1)
180 s = 0;
181 for m = 1:C
182 s = s + N(m)*S(k,m); % wait behind full service of all customers
183 end
184 W = s;
185else % preemptive (3) or non-preemptive (2) priority
186 dp = 0;
187 for m = 1:C
188 if prio(m) == prio(c) % equal priority (includes c)
189 Ncont = N(m); if m == c, Ncont = N(c)-1; end
190 if fc*Vkc == 0, pcm = 1; else pcm = min(1,(fup(m)*V(k,m))/(fc*Vkc)); end
191 dp = dp + Ncont*S(k,m)*pcm;
192 end
193 % higher-priority (prio<prio(c)) handled via Bh in mwrbb_denom
194 end
195 if d == 2 % non-preemptive: lower-priority water-filling
196 L = find(prio > prio(c));
197 if ~isempty(L)
198 [~,ord] = sort(S(k,L),'descend'); Ls = L(ord);
199 budget = 1;
200 for ii = 1:numel(Ls)
201 l = Ls(ii);
202 if fc*Vkc == 0, capr = Inf; else capr = (fup(l)*V(k,l))/(fc*Vkc); end
203 if N(l) <= 0, al = 0; else al = min(budget/N(l), capr); end
204 if al < 0, al = 0; end
205 dp = dp + N(l)*al*S(k,l);
206 budget = budget - N(l)*al;
207 if budget < 0, budget = 0; end
208 end
209 end
210 end
211 W = Skc + dp;
212end
213end
214
215% ------------------------------------------------------------------------
216% Full per-visit residence (including higher-priority delay) for reporting Q.
217function W = mwrbb_residence(k,c,V,S,N,fup,flo,sched,prio)
218C = size(V,2);
219fc = flo(c);
220Vkc = V(k,c);
221W = mwrbb_station_wrest(k,c,V,S,N,fup,fc,sched,prio);
222d = sched(k);
223if (d == 2 || d == 3) && fc*Vkc > 0
224 for m = 1:C
225 if prio(m) < prio(c)
226 W = W + N(m)*fup(m)*V(k,m)*S(k,m)/(fc*Vkc);
227 end
228 end
229end
230end
Definition Station.m:245