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 if ~all(isfinite(mu)) % first retry with -1/2
37 c = -0.5*ones(1,M);
38 mu = pfqn_fnc(alpha,c);
39 end
40 dt = 0;
41 it = 0;
42 while ~all(isfinite(mu)) % randomize c if need be but unlikely
43 it = it +1;
44 dt = dt + 0.05;
45 % c must stay a 1xM vector: the recursive call indexes c(ist) per
46 % station, so assigning a scalar here made this retry path fail with
47 % "Index exceeds array bounds" for any M > 1.
48 c = (-1/2+dt)*ones(1,M);
49 mu = pfqn_fnc(alpha,c);
50 if (-1/2+dt) >= 2
51 break
52 end
53 end
54 return
55end
56N = length(alpha(1,:));
57mu = zeros(M,N);
58for ist=1:M
59 mu(ist,1) = alpha(ist,1)/(1+c(ist));
60 alphanum = sparse(zeros(N,N));
61 alphaden = sparse(zeros(N,N));
62 for n=2:N
63 alphanum(n,1) = alpha(ist,n);
64 alphaden(n,1) = alpha(ist,n-1);
65 for k=2:(n-1)
66 alphanum(n,k) = alphanum(n,k-1) * alpha(ist,n-k+1);
67 alphaden(n,k) = alphaden(n,k-1) * alpha(ist,n-k);
68 end
69 end
70 for n=2:N
71 rho = 0;
72 muden = 1;
73 for k=1:(n-1)
74 muden = muden * mu(ist,k);
75 rho = rho+(alphanum(n,k)-alphaden(n,k)) / muden;
76 end
77 mu(ist,n) = alphanum(n,n-1)*alpha(ist,1)/muden;
78 mu(ist,n) = mu(ist,n)/(1-rho);
79 end
80end
81mu(isnan(mu)) = Inf;
82mu(abs(mu)>1e15) = Inf;
83for ist=1:M
84 if any(isinf(mu(ist,:)))
85 s = min(find(isinf(mu(ist,:))));
86 mu(ist,s:end)=Inf;
87 end
88end
89%mu(mu==0) = Inf;
90end
Definition Station.m:245