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% see _kb/03-api-layer.md (pfqn/ family: scaling, log-domain switches, dispatch gates)
34useLog = isreal(L) && isreal(mu) && all(L(:)>=0) && all(mu(:)>0);
37 % see _kb/03-api-layer.md (pfqn/ family: scaling, log-domain switches, dispatch gates)
38 lg = -Inf(M+1, Nscal+1, Nscal+2);
39 % lg(0+1,n+1,1+1) stays -Inf for n>=1: no station can hold n>=1 jobs.
40 lL = log(L); % -Inf where the demand
is zero
41 lmu = log(mu); % +Inf where the rate
is infinite, zeroing the term
44 lg(m +1,0 +1,tm +1)=0; % log(1): zero jobs
48 a = lg(m-1 +1, n +1, 1 +1);
49 b = lL(m) + lg(m +1, n-1 +1, tm+1 +1) - lmu(m,tm);
50 % pairwise log-sum-exp of a and b, stable when either
is -Inf
53 lg(m +1, n +1, tm +1) = a;
55 lg(m +1, n +1, tm +1) = a + log1p(exp(b-a));
59 lg(m +1, n +1, tm +1) = b;
61 lg(m +1, n +1, tm +1) = b + log1p(exp(a-b));
67 lG = lg(M +1,Nscal +1,1 +1);
70 g = zeros(M+1, Nscal+1, Nscal+2);
80 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);
84 G = g(M +1,Nscal +1,1 +1);