4 % @brief Logistic expansion (LE) asymptotic approximation
for normalizing constant.
10 % @brief Logistic expansion (LE) asymptotic approximation
for normalizing constant.
11 % @fn pfqn_le(L, N, Z)
12 % @param L Service demand matrix (MxR).
13 % @param N Population vector (1xR).
14 % @param Z Think time vector (1xR).
15 % @
return Gn Estimated normalizing constant.
16 % @
return lGn Logarithm of normalizing constant.
19function [Gn,lGn]=pfqn_le(L,N,Z)
20% [GN,LGN]=PFQN_LE(L,N,Z)
22% PFQN_LE Asymptotic solution of closed product-form queueing networks by
25% [Gn,lGn]=pfqn_le(L,N,Z)
27% L : MxR demand matrix. L(i,r)
is the demand of
class-r at queue i
28% N : 1xR population vector. N(r)
is the number of jobs in
class r
29% Z : 1xR think time vector. Z(r)
is the total think time of
class r
32% Gn : estimated normalizing constat
33% lGn: logarithm of Gn. If Gn exceeds the floating-point range, only lGn
34% will be correctly estimated.
37% G. Casale. Accelerating performance inference over closed systems by
38% asymptotic methods. ACM SIGMETRICS 2017.
44if isempty(L) || isempty(N) || sum(N)==0 || sum(L(:))<1e-4
45 lGn = - sum(factln(N)) + sum(N.*log(sum(Z,1)));
47elseif nargin<3%~exist(
'Z',
'var')
48 umax=pfqn_le_fpi(L,N);
49 A=pfqn_le_hessian(L,N,umax'); % slightly faster than pfqn_le_hessianZ
52 S=S+N(r)*log(umax'*L(:,r));
54 lGn = multinomialln([N,M-1]) + factln(M-1) + (M-1)*log(sqrt(2*pi)) - log(sqrt(det(A))) + sum(log(umax)) + S;
57 [umax,vmax]=pfqn_le_fpiZ(L,N,Z);
58 A=pfqn_le_hessianZ(L,N,Z,umax',vmax);
61 S=S+N(r)*log(Z(r)+vmax*umax'*L(:,r));
63 lGn = -sum(factln(N)) -vmax + M*log(vmax) + M*log(sqrt(2*pi)) - log(sqrt(det(A))) + sum(log(umax)) + S;
68function [u,d]=pfqn_le_fpi(L,N)
69% [U,D]=PFQN_LE_FPI(L,N)
71% find location of mode of gaussian
77while norm(u-u_1,1)>1e-10
82 u(i)=u(i)+N(r)/(sum(N)+M)*L(i,r)*u_1(i)/(u_1'*L(:,r));
85 d=[d; abs(u-u_1)']; %
#ok<AGROW>
89function [u,v,d]=pfqn_le_fpiZ(L,N,Z)
90% [U,V,D]=PFQN_LE_FPIZ(L,N,Z)
92% find location of mode of gaussian
101while norm(u-u_1,1)>1e-10
107 u(ist)=u(ist)+(N(r)/eta)*(Z(r)+v*L(ist,r))*u_1(ist)/(Z(r)+v*u_1
'*L(:,r));
112 xi(r)=N(r)/(Z(r)+v*u_1(:)'*L(:,r));
118 d=[d; abs(u-u_1)
'+abs(v-v_1)]; %#ok<AGROW>
123function hu=pfqn_le_hessian(L,N,u0)
124% HU=PFQN_LE_HESSIAN(L,N,U0)
126% find hessian of gaussian
133 hu(i,j)=-(Ntot+M)*u0(i)*u0(j);
135 hu(i,j)=hu(i,j)+N(r)*L(i,r)*L(j,r)*(u0(i)*u0(j))/(u0*L(:,r))^2;
138 hu(i,j)=(Ntot+M)*u0(i)*sum(allbut(u0,i));
140 hu(i,j)=hu(i,j)-N(r)*L(i,r)*u0(i)*(allbut(u0,i)*L(allbut(1:M,i),r))/(u0*L(:,r))^2;
147function A=pfqn_le_hessianZ(L,N,Z,u,v)
148% A=PFQN_LE_HESSIANZ(L,N,Z,U,V)
150% find hessian of gaussian
156 csi(r)=N(r)/(Z(r)+v*u*L(:,r));
161 Lhat(k,r)=Z(r)+v*L(k,r);
168 A(i,j)=-eta*u(i)*u(j);
170 A(i,j)=A(i,j)+csi(r)^2*Lhat(i,r)*Lhat(j,r)*(u(i)*u(j))/N(r);
176 A(i,i)=-sum(allbut(A(i,:),i));
181 A(K,K)=A(K,K)-(csi(r)^2/N(r))*Z(r)*u*L(:,r);
187 A(i,K)=A(i,K)+v*u(i)*((csi(r)^2/N(r))*Lhat(i,r)*(u*L(:,r))-csi(r)*L(i,r));
193function y=allbut(y,xset)
196y=y(setdiff(1:length(y),xset));
199function mln=multinomialln(n)
200% MLN=MULTINOMIALLN(N)
202mln = factln(sum(n))- sum(factln(n));