LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_comomrm_ld.m
1%{
2%{
3 % @file pfqn_comomrm_ld.m
4 % @brief CoMoM for repairman model with load-dependent service rates.
5%}
6%}
7
8%{
9%{
10 % @brief CoMoM for repairman model with load-dependent service rates.
11 % @fn pfqn_comomrm_ld(L, N, Z, mu, options)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @param Z Think time vector.
15 % @param mu Load-dependent rate matrix (MxNt matrix).
16 % @param options Solver options.
17 % @return G Normalizing constant.
18 % @return lG Logarithm of normalizing constant.
19 % @return prob State probability distribution.
20%}
21%}
22function [G,lG,prob] = pfqn_comomrm_ld(L,N,Z,mu, options)
23% S: number of servers at the queueing stations
24N = ceil(N);
25atol = options.tol;
26[M,R] = size(L);
27Nt = sum(N);
28Z = sum(Z,1);
29if sum(Z) < GlobalConstants.Zero
30 zset = false(M,1);
31 for ist=1:M
32 if norm(mu(ist,:)-(1:Nt),2) < atol
33 zset(ist) = true;
34 end
35 end
36 Z = L(zset,:);
37 mu(zset,:)=[];
38 L(zset,:)=[];
39end
40
41if sum(L) < GlobalConstants.Zero
42 % model has only delays so it is trivial
43 [G,lG] = pfqn_ca(L,N,Z);
44 prob = zeros(sum(N)+1,1);
45 prob(end)=1;
46 return
47end
48if nargin<4
49 m=1;
50end
51[~,L,N,Z,lG0] = pfqn_nc_sanitize(zeros(1,R),L,N,Z,atol);
52[M,R] = size(L);
53if isempty(Z)
54 if isempty(L)
55 lG=lG0;
56 G = exp(lG);
57 prob = zeros(Nt+1,1); prob(1)=1;
58 return
59 end
60 Z = zeros(1,R);
61elseif isempty(L)
62 L = zeros(1,R);
63end
64if M == 0
65 G=exp(lG0);
66 lG = lG0;
67 prob = zeros(sum(N)+1,1);
68 prob(end)=1;
69 return
70end
71
72if M~=1
73 line_error(mfilename,'The solver accepts at most a single queueing station.')
74end
75
76h = sparse(zeros(Nt+1,1)); h(Nt+1,1)=1;
77scale = zeros(Nt,1);
78nt = 0;
79for r=1:R
80 Tr = Z(r)*speye(Nt+1) + diag(sparse(L(r)*(Nt:-1:1)./mu(Nt:-1:1)),1);
81 for nr=1:N(r)
82 nt = nt + 1;
83 h = Tr/nr * h;
84 scale(nt) = abs(sum(sort(h))); % sort minimizes numerical issues
85 h = abs(h)/scale(nt); % rescale so that |h|=1
86 end
87end
88
89lG = lG0 + sum(log(scale));
90G = exp(lG);
91prob = h(end:-1:1)./G;
92prob = prob/sum(prob);
93end