LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_comomrm_ms.m
1%{
2%{
3 % @file pfqn_comomrm_ms.m
4 % @brief CoMoM for multiserver repairman model.
5%}
6%}
7
8%{
9%{
10 % @brief CoMoM for multiserver repairman model.
11 % @fn pfqn_comomrm_ms(L, N, Z, m, S)
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 S Number of servers at queueing stations.
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_ms(L,N,Z,m,S)
23% m: replication factor
24% S: number of servers at the queueing stations
25[M,R] = size(L);
26if M~=1
27 line_error(mfilename,'The solver accepts at most a single queueing station.')
28end
29if nargin<4
30 m=1;
31end
32atol = GlobalConstants.FineTol;
33[~,L,N,Z,lG0] = pfqn_nc_sanitize(zeros(1,R),L,N,Z,atol);
34Nt = sum(N);
35if m>1
36 mu = pfqn_mu_ms(Nt,m,S);
37else
38 mu = min(S,1:Nt);
39end
40
41h = zeros(Nt+1,1); h(Nt+1,1)=1;
42scale = zeros(Nt,1);
43nt = 0;
44for r=1:R
45 Tr = Z(r)*eye(Nt+1) + diag(L(r)*(Nt:-1:1)./mu(Nt:-1:1),1);
46 for nr=1:N(r)
47 nt = nt + 1;
48 h = Tr/nr * h;
49 scale(nt) = abs(sum(sort(h)));
50 h = abs(h)/scale(nt); % rescale so that |h|=1
51 end
52end
53
54lG = lG0 + sum(log(scale));
55G = exp(lG);
56prob = h(end:-1:1)./G;
57prob = prob/sum(prob);
58end