LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_sib.m
1%{
2%{
3 % @file pfqn_sib.m
4 % @brief Srinivasan (1985) Successively Improving Bounds (SIB) on cycle time
5 % and throughput for single-class product-form closed networks.
6%}
7%}
8
9function [Xlo,Xhi,Wlo,Whi] = pfqn_sib(L,N,Z,level)
10%{
11%{
12 % @brief Successively Improving Bounds (Srinivasan, "Successively Improving
13 % Bounds on Performance Measures for Product Form Queueing Networks",
14 % IEEE ToC 1987 / TR 85-2). Closed-form hierarchy of upper/lower bounds
15 % on the cycle time W(N) and throughput X(N) of a single-class closed
16 % network of fixed-rate (and delay) stations, based on the MVA relation
17 % W(N)=L*(1+phi(N-1)) with phi(K)=sum_m rho_m Q_m(K). Level 1 is the
18 % closed form of Thm 2.1; higher levels use the S_i power sums
19 % (S_i=sum_m rho_m^i) via Thms 3.5 (upper) and 3.6 (lower), tightening
20 % monotonically toward exact. Bounds are always at least as tight as the
21 % Balanced Job Bounds. O(M) to compute; level n needs S_2..S_{n+2}.
22 % @fn pfqn_sib(L, N, Z, level)
23 % @param L Fixed-rate service demand vector (M x 1). Delay demand goes in Z.
24 % @param N Total population (scalar, N>=2).
25 % @param Z Think time (scalar; added to the cycle-time bracket).
26 % @param level Bound level (>=1, default 3). Higher = tighter, more S_i terms.
27 % @return Xlo Lower bound on throughput X(N).
28 % @return Xhi Upper bound on throughput X(N).
29 % @return Wlo Lower bound on cycle time (residence + think) W(N).
30 % @return Whi Upper bound on cycle time W(N).
31%}
32%}
33
34L = L(:);
35if nargin < 3 || isempty(Z), Z = 0; end
36Z = sum(Z(:));
37if nargin < 4 || isempty(level), level = 3; end
38level = max(1, round(level));
39
40% see _kb/03-api-layer.md (pfqn/ family: scaling, log-domain switches, dispatch gates)
41if Z > 0
42 error('pfqn_sib:delayUnsupported', ...
43 'pfqn_sib supports Z=0 only (delay needs the Section-3.2 demand substitution, not yet implemented).');
44end
45
46Lsum = sum(L);
47rho = L/Lsum;
48rho_u = max(rho);
49% Power sums S_i, i=1..level+3 (S_1=1).
50imax = level+3;
51S = zeros(1,imax);
52for i = 1:imax
53 S(i) = sum(rho.^i);
54end
55S2 = S(2);
56
57% alpha_i coefficients (eq. 3.5-3.6), 0-indexed: alpha(k+1) = alpha_k.
58alpha = zeros(1,level+1);
59alpha(1) = S2; % alpha_0
60for i = 1:level
61 acc = 0;
62 for j = 0:i-1
63 acc = acc + S(i+1-j) * alpha(j+1);
64 end
65 alpha(i+1) = S(i+2) - acc; % alpha_i
66end
67
68 function v = phi_u1(K)
69 % Level-1 upper bound on phi(K) (Thm 3.5 with n=1 / eq. 3.18).
70 if K <= 0
71 v = 0;
72 elseif K == 1
73 v = S2; % phi(1) = sum rho_m^2 = S_2 (exact)
74 else
75 etaK = (K-1)/K; % was eta: this is a NESTED function, so assigning
76 % eta clobbered the parent's eta=(N-2)/(N-1) used
77 % in the Theorem-3.5 prefactor 0.5/eta below, and
78 % the SIB hierarchy went inert above level 1
79 % (levels 2..4 all returned the level-0 baseline,
80 % with level 2 LOOSER than level 1).
81 T1 = (K-1)*rho_u - 1;
82 v = 0.5/etaK * (T1 + sqrt(T1^2 + 4*(K-1)*S2));
83 end
84 end
85
86 function s = sigma(NN,i)
87 % eq. (3.22c): NN plays the role of (N-1); Dbar_{N-3}=1+phi_u1(N-3).
88 s = 0;
89 if i <= 0, return; end
90 Dbar = 1 + phi_u1(NN-2); % N-3 = (N-1)-2 = NN-2
91 pnum = 1;
92 for j = 1:i
93 pnum = pnum * (NN-1-(j-1)); % prod_{m=0}^{j-1}(N-2-m)
94 s = s + (rho_u*S(j+1) - S(j+2)) * pnum / Dbar^j;
95 end
96 end
97
98 function b = betaL(NN,i)
99 % eq. (3.23c): NN plays the role of (N-1).
100 b = 0;
101 if i <= 0, return; end
102 % term1: sum_{j=1}^{i-1} alpha_j prod_{m=2}^{j}((N-1-m)/Dbar_{N-1-m})
103 for j = 1:i-1
104 p = 1;
105 for m = 2:j
106 p = p * (NN-m)/(1 + phi_u1(NN-m));
107 end
108 b = b + alpha(j+1)*p;
109 end
110 % term2: alpha_i prod_{m=2}^{i}(...)(1 + (alpha_i/alpha_{i-1})(N-i-2)/(1+(N-i-2)alpha_0))
111 p = 1;
112 for m = 2:i
113 p = p * (NN-m)/(1 + phi_u1(NN-m));
114 end
115 Nim2 = NN-1-i-1; % N-i-2 = (NN+1)-i-2 = NN-i-1
116 corr = 1 + (alpha(i+1)/alpha(i)) * Nim2/(1 + Nim2*alpha(1));
117 b = b + alpha(i+1)*p*corr;
118 end
119
120% phi(N-1): NN = N-1.
121NN = N-1;
122% Section-2 baseline bounds (always valid).
123phi_lo = (N-1)*S2;
124T1s2 = (N-1)*rho_u - 1;
125phi_hi = 0.5*(T1s2 + sqrt(T1s2^2 + 4*(N-1)*S2));
126
127if N >= 3
128 % Section-3 level-n upper (Thm 3.5) and lower (Thm 3.6); take tightest valid.
129 eta = (N-2)/(N-1);
130 T1u = (N-2)*rho_u - 1;
131 su = sigma(NN, level-1);
132 phi_u_n = 0.5/eta * (T1u + sqrt(max(0, T1u^2 + 4*(N-2)*(S2 - su))));
133 phi_hi = min(phi_hi, phi_u_n);
134
135 T1l = (N-2)*S2 - 1;
136 bl = betaL(NN, level-1);
137 phi_l_n = (T1l + sqrt(max(0, T1l^2 + 4*(N-2)*(S2 + (N-2)*bl))))/(2*level);
138 phi_lo = max(phi_lo, phi_l_n);
139end
140
141% Guard validity of the bracket.
142phi_lo = max(0, phi_lo);
143if phi_hi < phi_lo
144 phi_hi = phi_lo;
145end
146
147% Cycle time and throughput. Delay Z adds to the cycle time.
148Wlo = Lsum*(1 + phi_lo) + Z;
149Whi = Lsum*(1 + phi_hi) + Z;
150Xlo = N/Whi; % larger cycle time -> lower throughput
151Xhi = N/Wlo;
152end