4 % @brief Cubature method
for normalizing constant
using Grundmann-Moeller rules.
10 % @brief Cubature method
for normalizing constant
using Grundmann-Moeller rules.
11 % @fn pfqn_cub(L, N, Z, order, atol)
12 % @param L Service demand matrix (MxR).
13 % @param N Population vector (1xR).
14 % @param Z Think time vector (1xR).
15 % @param order Degree of cubature rule (
default: ceil((sum(N)-1)/2)).
16 % @param atol Absolute tolerance (default: 1e-8).
17 % @return Gn Estimated normalizing constant.
18 % @return lGn Logarithm of normalizing constant.
21function [Gn,lGn]=pfqn_cub(L,N,Z,order,atol)
22% [GN,LGN]=PFQN_CUB(L,N,Z,ORDER,TOL)
24% PFQN_GM Exact and approximate solution of closed product-form queueing
25% networks by Grundmann-Moeller cubature rules
27% [Gn,lGn]=pfqn_gm(L,N,Z,S)
29% L : MxR demand matrix. L(i,r)
is the demand of class-r at queue i
30% N : 1xR population vector. N(r)
is the number of jobs in class r
31% Z : 1xR think time vector. Z(r)
is the total think time of class r
32% S : degree of the cubature rule. Exact if S=ceil((sum(N)-1)/2).
33% atol: max absolute distance from zero to declare that a variable
is zero
36% Gn : estimated normalizing constat
37% lGn: logarithm of Gn. If Gn exceeds the floating-point range, only lGn
38% will be correctly estimated.
41% G. Casale. Accelerating performance inference over closed systems by
42% asymptotic methods. ACM SIGMETRICS 2017.
47if isempty(L) || isempty(N) || sum(N)==0
52 order=ceil((sum(N)-1)/2);
58if nargin<3 || sum(Z)<atol %~exist(
'Z',
'var')
61 f=@(x) ([x(:);1-sum(x)]'*L);
62 h=@(x) beta.*log(f(x));
63 [~,Q,~]=simplexquad(@(x) prod(exp(Nt*h(x))),M-1,order,atol);
64 Gn=Q*exp(gammaln(1+sum(N)+M-1)-sum(gammaln(1+N)));
75 h = @(x) beta.*log(([x(:);1-sum(x)]'*Lv));
76 [~,Q] = simplexquad(@(x) exp(sum(Nt*h(x))),M-1,order,atol);
77 dG = exp(-v)*v^(M-1)*Q(end)*dv;
83 Gn = Gn * exp(-sum(factln(N)));
88function [I,Q,nv]=simplexquad(f,n,order,tol)
89% [I,Q,NV]=SIMPLEXQUAD(F,N,ORDER,TOL)
91[Q,nv]=grnmol(@(x)f(x),eye(n,n+1),order,tol);
95function [Q,nv] = grnmol( f, V, s, tol)
96% [Q,NV] = GRNMOL( F, V, S , TOL)
100% computes approximation to the integral of f over an s-simplex
101% with vertices as columns of V, an n x (n+1) matrix, using
102% order 1, 2, ..., s (degree 2s+1) Grundmann-Moler rules.
103% Output Q
is a vector approximations of degree 1, 3, ... 2s+1.
104% Example: % final two results should be 2/(11x10x9x8x7x6)
105% n = 4; grnmol(@(x)x(1)^2*x(n)^5,eye(n,n+1),4)
107% "Invariant Integration Formulas for the N-Simplex by
108% Combinatorial Methods", A. Grundmann and H. M. Moller,
109% SIAM J Numer. Anal. 15(1978), pp. 282-290
111[n,~] = size(V); % n
is the dimension
112d = 0; % order of the polynomial
115Vol = 1/factorial((n));%abs(det(V(:,1:n)-V(:,np)*ones(1,n)))/prod(mp([1:n]));
123 Qs = Qs + f(V*[alz; al]/m);
131 alz = alz + al(j) + 1;
141 p = 2/(prod(2*[n+1:m])); %
#ok<NBRAK1>
143 Q(d) = Q(d) + ((m+2-2*i))^(2*d-1)*p*Qv(d+1-i);
146 if d > s || (d>1 && abs(Q(d)-Q(d-1))<tol*Q(d-1))