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 = zeros(1,R);
36 numZeroThinkTimes = numZeroThinkTimes + 1;
37 zerothinktimes(numZeroThinkTimes) = r;
42if numZeroThinkTimes > 0
43 for z = 1:numZeroThinkTimes
44 idx = zerothinktimes(z);
47 lh=zeros(2+2*numZeroThinkTimes,1);
49 % these are trivial models with a single queueing station with demands all equal to one and think time 0
50 lh(lhIdx,1) = (factln(sum(nvec)+m+1-1)-sum(factln(nvec)));
52 for z = 1:numZeroThinkTimes
53 s = zerothinktimes(z);
54 nvec_s = oner(nvec,s);
55 lh(lhIdx,1) = (factln(sum(nvec_s)+m+1-1)-sum(factln(nvec_s)));
58 lh(lhIdx,1) = (factln(sum(nvec)+m-1)-sum(factln(nvec)));
60 for z = 1:numZeroThinkTimes
61 s = zerothinktimes(z);
62 nvec_s = oner(nvec,s);
63 lh(lhIdx,1) = (factln(sum(nvec_s)+m-1)-sum(factln(nvec_s)));
70if numZeroThinkTimes==R
72 lG = lG0 + log(h(end-R));
75 scale = ones(1,sum(N));
79 for r=(numZeroThinkTimes+1):R
85 if r> numZeroThinkTimes+1
87 hr(1:(r-1)) = h(1:(r-1));
88 hr((r+1):(2*r-1)) = h(((r-1)+1):2*(r-1));
92 h(r)=h_1(1)/scale(nt);
93 h(end)=h_1((r-1)+1)/scale(nt);
99 % Class-1..(R-1) PCs for G
102 A12(1+s,1+s) = -Z(s);
105 B2r = [m*L(1,r)*eye(r), Z(r)*eye(r)];
106 % explicit formula for inv(C)
110 % explicit formula for F1r
111 F1r = zeros(2*r); F1r(1,1)=1;
112 % F2r by the definition
113 F2r = [-iC*A12*B2r; B2r];
116 h = (F1r+F2r/nvec(r))*h_1;
118 scale(nt) = abs(sum(sort(h)));
119 h = abs(h)/scale(nt); % rescale so that |h|=1
123 % unscale and return the log of the normalizing constant
124 lG = lG0 + log(h(end-(R-1))) + sum(log(scale));
125 lGbasis = log(h) + sum(log(scale));