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
76while norm(u-u_1,1)>1e-10
81 u(i)=u(i)+N(r)/(sum(N)+M)*L(i,r)*u_1(i)/(u_1'*L(:,r));
84 d(end+1,:)=abs(u-u_1)';
88function [u,v,d]=pfqn_le_fpiZ(L,N,Z)
89% [U,V,D]=PFQN_LE_FPIZ(L,N,Z)
91% find location of mode of gaussian
99while norm(u-u_1,1)>1e-10
105 u(ist)=u(ist)+(N(r)/eta)*(Z(r)+v*L(ist,r))*u_1(ist)/(Z(r)+v*u_1
'*L(:,r));
109 xi(r)=N(r)/(Z(r)+v*u_1(:)'*L(:,r));
115 d(end+1,:)=abs(u-u_1)
'+abs(v-v_1);
120function hu=pfqn_le_hessian(L,N,u0)
121% HU=PFQN_LE_HESSIAN(L,N,U0)
123% find hessian of gaussian
130 hu(i,j)=-(Ntot+M)*u0(i)*u0(j);
132 hu(i,j)=hu(i,j)+N(r)*L(i,r)*L(j,r)*(u0(i)*u0(j))/(u0*L(:,r))^2;
135 hu(i,j)=(Ntot+M)*u0(i)*sum(allbut(u0,i));
137 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;
144function A=pfqn_le_hessianZ(L,N,Z,u,v)
145% A=PFQN_LE_HESSIANZ(L,N,Z,U,V)
147% find hessian of gaussian
153 csi(r)=N(r)/(Z(r)+v*u*L(:,r));
158 Lhat(k,r)=Z(r)+v*L(k,r);
165 A(i,j)=-eta*u(i)*u(j);
167 A(i,j)=A(i,j)+csi(r)^2*Lhat(i,r)*Lhat(j,r)*(u(i)*u(j))/N(r);
173 A(i,i)=-sum(allbut(A(i,:),i));
178 A(K,K)=A(K,K)-(csi(r)^2/N(r))*Z(r)*u*L(:,r);
184 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));
190function y=allbut(y,xset)
193y=y(setdiff(1:length(y),xset));
196function mln=multinomialln(n)
197% MLN=MULTINOMIALLN(N)
199mln = factln(sum(n))- sum(factln(n));