4 % @brief Knessl-Tier asymptotic expansion
for normalizing constant.
10 % @brief Knessl-Tier asymptotic expansion
for normalizing constant.
11 % @fn pfqn_kt(L, N, Z)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @param Z Think time vector (
default: zeros).
15 % @return G Normalizing constant.
16 % @return lG Logarithm of normalizing constant.
17 % @return X System throughput.
18 % @return Q Mean queue lengths.
21function [G,lG,X,Q]=pfqn_kt(L,N,Z)
22% Knessl-Tier asymptotic expansion, fixed to include
the IS/think-time term
23% (defect G18) and to evaluate
the exponent at
the exact saddle point.
25% Derivation. In LINE
's convention the generating function of G over the
27% sum_N G(N) prod_r u_r^N_r = exp(sum_r Z_r u_r) prod_k (1-sum_r L_kr u_r)^-1
28% so Cauchy extraction and steepest descent on
29% F(u) = sum_r Z_r u_r - sum_k log(1-U_k) - sum_r N_r log u_r, U_k = L(k,:)*u
31% G ~ (2 pi)^{-R/2} det(H)^{-1/2} exp(F(u*)) / prod_r u*_r
32% H_rs = delta_rs N_r/u_r^2 + sum_k L_kr L_ks/(1-U_k)^2
33% where u* solves N_r = u_r Z_r + sum_k u_r L_kr/(1-U_k) (asymptotic MVA
34% fixed point). This is Knessl-Tier Result 2 rewritten in LINE's convention:
35% their rho_k absorbs
the think rate and
the factor exp(sum_r Z_r u_r)
is
36% contained in Psi(1,y*) via
the M!/(M-n)! Stirling terms. Stock pfqn_kt
37% dropped
the linear think term (it
is absent from both
the exponent and
the
38% Hessian) and evaluated
the exponent at
the AQL throughput.
39if isempty(L) || isempty(N) || sum(N)==0
49[Morig,Rorig] = size(L); %#ok<ASGLU>
50% fix self-looping customers as they would yield Uk=1
53 isslc =
false(1,Rorig);
58 L = [L; repmat(L(ist,:),N(r),1)];
60 slcdemandfactor = N(r)*log(L(ist,r));
71 [X,Q] = pfqn_bs(L,N,Z);
73 [X,Q] = pfqn_aql(L,N,Z);
75% Solve
the saddle-point equations by damped Newton, starting from X:
76% g_r(u) = u_r*(Z_r + sum_k L_kr/(1-U_k)) - N_r = 0
81 u = u * (1-1e-6)/max(Uk);
87 g = u.*(Zc + L
'*D) - Nc;
88 if norm(g) <= 1e-12*Ntot
92 J = diag(Zc + L'*D) + (u*ones(1,R)).*(L
'*(D.^2.*L));
95 while any(u+alpha*du <= 0) || max(L*(u+alpha*du)) >= 1
108if converged && norm(u.*(Zc + L'*D) - Nc) <= 1e-8*Ntot
109 us = u; % exact saddle point
111 us = X(:); % fallback: AQL/BS throughput (stationarity limits
the damage)
113% Assemble
the expansion at us
115D = 1./max(GlobalConstants.FineTol, 1-Uk);
116H = diag(Nc./us.^2) + L
'*((D.^2).*L);
117F = Zc'*us - sum(log(max(GlobalConstants.FineTol,1-Uk))) - Nc
'*log(us);
118lG = F - sum(log(us)) - (R/2)*log(2*pi) - 0.5*log(det(H)) + slcdemandfactor;