3 % @file pfqn_gldsingle.m
4 % @brief Exact normalizing constant
for single-
class load-dependent models.
10 % @brief Exact normalizing constant
for single-
class load-dependent models.
11 % @fn pfqn_gldsingle(L, N, mu, options)
12 % @param L Service demand vector (Mx1).
13 % @param N Population (scalar).
14 % @param mu Load-dependent rate matrix (MxN).
15 % @param options Solver options.
16 % @
return lG Logarithm of normalizing constant.
17 % @
return G Normalizing constant.
20function [lG,G]=pfqn_gldsingle(L,N,mu,options)
21% G=PFQN_GLDSINGLE(L,N,MU)
29 line_error(mfilename,
'multiclass model detected. pfqn_gldsingle is for single class models.');
31Nscal = N(1); % codegen: ensure scalar loop bound
33% Logarithms are only defined
for this recursion when
the demands are real and
34% non-negative and
the rates are real and positive (Inf allowed: it zeroes
the
35% term). pfqn_rd calls this function with load-dependent rates beta that may be
36% negative, which makes
the intermediate g negative and log(G) complex (hence
37%
the real() wrapper at its call site), so that case keeps
the linear-scale
39useLog = isreal(L) && isreal(mu) && all(L(:)>=0) && all(mu(:)>0);
42 % pfqn_ncld normalizes
the demands into [0,1] before calling, which makes
43 %
the delay contribution of order 1/Nscal! and drives g below realmin
for
44 % moderate populations (e.g. Nscal>=190
for a Delay+multiserver layer). In
45 % linear scale g then underflows to exactly 0 and log(G) returns -Inf,
46 % silently propagating NaN throughputs to
the caller. Logarithms keep every
47 % intermediate in range;
the two recursion terms are combined by a pairwise
49 lg = -Inf(M+1, Nscal+1, Nscal+2);
50 % lg(0+1,n+1,1+1) stays -Inf for n>=1: no station can hold n>=1 jobs.
51 lL = log(L); % -Inf where
the demand
is zero
52 lmu = log(mu); % +Inf where
the rate
is infinite, zeroing
the term
55 lg(m +1,0 +1,tm +1)=0; % log(1): zero jobs
59 a = lg(m-1 +1, n +1, 1 +1);
60 b = lL(m) + lg(m +1, n-1 +1, tm+1 +1) - lmu(m,tm);
61 % pairwise log-sum-exp of a and b, stable when either
is -Inf
64 lg(m +1, n +1, tm +1) = a;
66 lg(m +1, n +1, tm +1) = a + log1p(exp(b-a));
70 lg(m +1, n +1, tm +1) = b;
72 lg(m +1, n +1, tm +1) = b + log1p(exp(a-b));
78 lG = lg(M +1,Nscal +1,1 +1);
81 g = zeros(M+1, Nscal+1, Nscal+2);
91 g(m +1, n +1, tm +1)= g(m-1 +1, n +1, 1 +1)+L(m)*g(m +1, n-1 +1, tm+1 +1)/mu(m,tm);
95 G = g(M +1,Nscal +1,1 +1);