3 % @file pfqn_stdf_heur.m
4 % @brief Heuristic sojourn time distribution
for multiserver FCFS
nodes (McKenna 1987 variant).
10 % @brief Heuristic sojourn time distribution
for multiserver FCFS
nodes (McKenna 1987 variant).
11 % @fn pfqn_stdf_heur(L, N, Z, S, fcfsNodes, rates, tset)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @param Z Think time vector.
15 % @param S Number of servers per station.
16 % @param fcfsNodes Indices of FCFS
nodes to analyze.
17 % @param rates Service rates (MxR matrix).
18 % @param tset Time points
for CDF evaluation.
19 % @
return RD Cell array of sojourn time distributions {station,
class}.
22function
RD = pfqn_stdf_heur(L,N,Z,S,fcfsNodes,rates,tset)
23% Heuristic sojourn time distribution analysis at multiserver FCFS
nodes
24% based on a variant of the method in J. McKenna 1987 JACM
25stabilityWarnIssued =
false;
31 mu(k,n) = min(S(k),n);
35% when t==0 the hkc function
is not well defined
36tset(tset == 0) = GlobalConstants.FineTol;
40 if L(k,r) > GlobalConstants.FineTol
43 options = SolverNC.defaultOptions;
44 [~,lGr] = pfqn_comomrm_ld(L,Nr,Z,mu,options);
45 m = 2; [~,lGra] = pfqn_comomrm_ld(L,Nr,Z,pfqn_mu_ms(sum(N),m,S(k)),options);
48 Q1(k,s) = L(k,s)* exp(lGra-lGr);
52 [~,Q1,~,~,lGr,isNumStable] = pfqn_mvald(L,Nr,Z,mu);
55 hMAPr = cell(1,1+sum(N));
58 % the heuristic here is to use the average rates
59 hMAPr{1+n} = map_exponential(1/rates(k,r));
61 % the heuristic here is to use the rates per class
62 C = {map_exponential(1/rates(k,r))};
64 C = {C{:}, map_exponential(Q1(k,s)*(n-S(k)+1)/sum(Q1(k,:))/rates(k,s))};
66 hMAPr{1+n} = map_sumind(C);
68 hkc{r}(1:T,1+n) = map_cdf(hMAPr{1+n}, tset)';
72 if ~isNumStable && ~stabilityWarnIssued
73 stabilityWarnIssued =
true;
74 line_warning(mfilename,
'The computation of the sojourn time distribution is numerically unstable.\n');
76 RD{k,r} = zeros(length(tset),2);
77 RD{k,r}(:,2) = tset(:);
79 %%
this is the original code in the paper
83 % [~,~,~,~,lGk,isNumStable] = pfqn_mvald(L(setdiff(1:M,k),:),Nr-nvec,Z,mu(setdiff(1:M,k),:));
85 %
if ~isNumStable && ~stabilityWarnIssued
86 % stabilityWarnIssued =
true;
87 % line_warning(mfilename,
'The computation of the sojourn time distribution is numerically unstable');
91 % Gkrt(t) = Gkrt(t) + hkc(t,1+0) * exp(lGk);
93 % lFk = nvec*log(L(k,:))
' +factln(sum(nvec)) - sum(factln(nvec)) - sum(log(mu(k,1:sum(nvec))));
94 % Gkrt(t) = Gkrt(t) + hkc(t,1+sum(nvec)) * exp(lFk + lGk);
97 % nvec = pprod(nvec, Nr);
100 % RD{k,r}(1:T,1) = exp(lGkrt - lGr);
102 %% this is faster as it uses the recursive form for LD models
104 [~,~,~,~,lGk] = pfqn_mvald(L(setdiff(1:M,k),:),Nr,Z,mu(setdiff(1:M,k),:));
110 gammat(k,m) = mu(k,m) * hkc{r}(t,1+m-1) / hkc{r}(t,1+m);
112 gammak = mushift(gammat,k);
113 Hkrt(t) = hkc{r}(t,1+0) * exp(lGk); % nvec = 0
114 for s=1:R % nvec >= 1s
116 lYks_t = pfqn_rd(L,oner(Nr,s),Z,gammak);
117 %[~,~,~,~,lYks_t] = pfqn_mvald(L,oner(Nr,s),Z,gammak);
118 lYks_t = lYks_t(end);
119 Hkrt(t) = Hkrt(t) + (L(k,s) * hkc{r}(t,1+0) / gammat(k,1)) * exp(lYks_t); % nvec = 0
123 Hkrt(isnan(Hkrt)) = GlobalConstants.FineTol;
126 RD{k,r}(1:T,1) = exp(lHkrt - lGr);
138 A = A + x^j/factorial(j);
144function mushifted = mushift(mu,i)
145% shifts the service rate vector
149 mushifted(m,1:(N-1))=mu(m,2:N);
151 mushifted(m,1:(N-1))=mu(m,1:(N-1));