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
32if nargin<5
33 S=1; % single server per queueing station, as the docstring advertises
34end
35atol = GlobalConstants.FineTol;
36[~,L,N,Z,lG0] = pfqn_nc_sanitize(zeros(1,R),L,N,Z,atol);
37% R must be re-read here: sanitize DROPS zero-population and zero-demand
38% classes, so the pre-sanitize R above overruns the shortened L, N and Z in
39% the loop below. Reachable on ordinary input, since a zero-population class
40% is a normal thing to hand a solver.
41R = size(L,2);
42Nt = sum(N);
43if m>1
44 mu = pfqn_mu_ms(Nt,m,S);
45else
46 mu = min(S,1:Nt);
47end
48
49h = zeros(Nt+1,1); h(Nt+1,1)=1;
50scale = zeros(Nt,1);
51nt = 0;
52for r=1:R
53 Tr = Z(r)*eye(Nt+1) + diag(L(r)*(Nt:-1:1)./mu(Nt:-1:1),1);
54 for nr=1:N(r)
55 nt = nt + 1;
56 h = Tr/nr * h;
57 scale(nt) = abs(sum(sort(h)));
58 h = abs(h)/scale(nt); % rescale so that |h|=1
59 end
60end
61
62lG = lG0 + sum(log(scale));
63G = exp(lG);
64prob = h(end:-1:1)./G;
65prob = prob/sum(prob);
66end