4 % @brief CoMoM (Convolution Method of Moments)
for finite repairman model.
10 % @brief CoMoM (Convolution Method of Moments)
for finite repairman model.
11 % @fn pfqn_comomrm(L, N, Z, m, atol)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @param Z Think time vector.
15 % @param m Replication factor (
default: 1).
16 % @param atol Absolute tolerance for numerical computations.
17 % @return lG Logarithm of normalizing constant.
18 % @return lGbasis Logarithm of basis functions.
21function [lG,lGbasis]=pfqn_comomrm(L,N,Z,m,atol)
22% comom for a finite repairment model
25 line_error(mfilename,
'The solver accepts at most a single queueing station.')
31[~,L,N,Z,lG0] = pfqn_nc_sanitize(lambda,L,N,Z,atol);
32zerothinktimes=find(Z<1e-6);
36 nvec(zerothinktimes) = N(:,zerothinktimes);
38 % these are trivial models with a single queueing station with demands all equal to one and think time 0
39 lh(end+1,1) = (factln(sum(nvec)+m+1-1)-sum(factln(nvec)));
40 for s=find(zerothinktimes)
41 nvec_s = oner(nvec,s);
42 lh(end+1,1) = (factln(sum(nvec_s)+m+1-1)-sum(factln(nvec_s)));
44 lh(end+1,1) = (factln(sum(nvec)+m-1)-sum(factln(nvec)));
45 for s=find(zerothinktimes)
46 nvec_s = oner(nvec,s);
47 lh(end+1,1) = (factln(sum(nvec_s)+m-1)-sum(factln(nvec_s)));
53if length(zerothinktimes)==R
55 lG = lG0 + log(h(end-R));
58 scale = ones(1,sum(N));
62 for r=(length(zerothinktimes)+1):R
66 if r> length(zerothinktimes)+1
68 hr(1:(r-1)) = h(1:(r-1));
69 hr((r+1):(2*r-1)) = h(((r-1)+1):2*(r-1));
73 h(r)=h_1(1)/scale(nt);
74 h(end)=h_1((r-1)+1)/scale(nt);
79 % Class-1..(R-1) PCs for G
85 B2r = [m*L(1,r)*eye(r), Z(r)*eye(r)];
86 % explicit formula for inv(C)
90 % explicit formula for F1r
91 F1r = zeros(2*r); F1r(1,1)=1;
92 % F2r by the definition
93 F2r = [-iC*A12*B2r; B2r];
96 h = (F1r+F2r/nvec(r))*h_1;
98 scale(nt) = abs(sum(sort(h)));
99 h = abs(h)/scale(nt); % rescale so that |h|=1
103 % unscale and return the log of the normalizing constant
104 lG = lG0 + log(h(end-(R-1))) + sum(log(scale));
105 lGbasis = log(h) + sum(log(scale));