LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_fnc.m
1%{
2%{
3 % @file pfqn_fnc.m
4 % @brief Generate load-dependent rates for functional server model f(n)=n+c.
5%}
6%}
7
8%{
9%{
10 % @brief Generate load-dependent rates for functional server model f(n)=n+c.
11 % @fn pfqn_fnc(alpha, c)
12 % @param alpha Rate parameters (Mx N matrix).
13 % @param c Constant offset parameter (default: auto-determined).
14 % @return mu Load-dependent service rates.
15 % @return c Determined offset constant.
16%}
17%}
18function [mu,c] = pfqn_fnc(alpha,c)
19% generate rates for functional server f(n)=n+c
20M = size(alpha,1);
21if size(alpha,2) == 0
22 % No rate columns: the caller shifted a single-column mu with
23 % pfqn_mushift, which returns M x (N-1) and so yields zero columns when the
24 % total population is 1. There is no functional-server rate to build, and
25 % the population-N-1 subproblems the caller then forms are empty (G = 1).
26 % Without this guard alpha(ist,1) below indexes an empty array and
27 % SolverNC(model,'method','exact') fails on EVERY closed model whose total
28 % population is 1.
29 mu = zeros(M,0);
30 c = zeros(1,M);
31 return
32end
33if nargin<2
34 c = zeros(1,M);
35 mu = pfqn_fnc(alpha,c);
36 % all(isfinite(mu)) reduces per COLUMN for M>1, so the ladder fired only
37 % when EVERY population column held a non-finite rate; the intent is any.
38 if any(~isfinite(mu(:))) % first retry with -1/2
39 c = -0.5*ones(1,M);
40 mu = pfqn_fnc(alpha,c);
41 end
42 dt = 0;
43 it = 0;
44 while any(~isfinite(mu(:))) % randomize c if need be but unlikely
45 it = it +1;
46 dt = dt + 0.05;
47 % c must stay a 1xM vector: the recursive call indexes c(ist) per
48 % station, so assigning a scalar here made this retry path fail with
49 % "Index exceeds array bounds" for any M > 1.
50 c = (-1/2+dt)*ones(1,M);
51 mu = pfqn_fnc(alpha,c);
52 if (-1/2+dt) >= 2
53 break
54 end
55 end
56 return
57end
58N = length(alpha(1,:));
59mu = zeros(M,N);
60for ist=1:M
61 mu(ist,1) = alpha(ist,1)/(1+c(ist));
62 alphanum = sparse(zeros(N,N));
63 alphaden = sparse(zeros(N,N));
64 for n=2:N
65 alphanum(n,1) = alpha(ist,n);
66 alphaden(n,1) = alpha(ist,n-1);
67 for k=2:(n-1)
68 alphanum(n,k) = alphanum(n,k-1) * alpha(ist,n-k+1);
69 alphaden(n,k) = alphaden(n,k-1) * alpha(ist,n-k);
70 end
71 end
72 for n=2:N
73 rho = 0;
74 muden = 1;
75 for k=1:(n-1)
76 muden = muden * mu(ist,k);
77 rho = rho+(alphanum(n,k)-alphaden(n,k)) / muden;
78 end
79 mu(ist,n) = alphanum(n,n-1)*alpha(ist,1)/muden;
80 mu(ist,n) = mu(ist,n)/(1-rho);
81 end
82end
83mu(isnan(mu)) = Inf;
84mu(abs(mu)>1e15) = Inf;
85for ist=1:M
86 if any(isinf(mu(ist,:)))
87 s = min(find(isinf(mu(ist,:))));
88 mu(ist,s:end)=Inf;
89 end
90end
91%mu(mu==0) = Inf;
92end