LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
m3pp2m_interleave.m
1function s = m3pp2m_interleave(m3pps)
2% Computes the interleaved MMAP obtained by multiple M3PP(2,m).
3
4L = length(m3pps);
5
6symbolic = 0;
7for i = 1:L
8 if map_issym(m3pps{i})
9 symbolic = 1;
10 break;
11 end
12end
13
14if symbolic
15 r = sym(zeros(2,L));
16else
17 r = zeros(2,L);
18end
19r(1,L) = m3pps{L}{1}(1,2);
20for i = (L-1):-1:1
21 r(1,i) = m3pps{i}{1}(1,2) - sum(r(1,(i+1):end));
22end
23r(2,1) = m3pps{1}{1}(2,1);
24for i = 2:L
25 r(2,i) = m3pps{i}{1}(2,1) - sum(r(2,1:(i-1)));
26end
27
28M = 0;
29for i = 1:L
30 M = M + size(m3pps{i},2) - 2;
31end
32
33n = 2+(L-1);
34s = cell(1,2+M);
35for i = 1:n
36 for j = 1:n
37 if j > i
38 s{1}(i,j) = r(1,j-1);
39 elseif j < i
40 s{1}(i,j) = r(2,j);
41 end
42 end
43end
44% compute D1c, c = (i-1)*2+j
45c = 1;
46for i = 1:L % for each M3PP[2]
47 m = size(m3pps{i},2)-2;
48 for j = 1:m % for each class in the i-th M3PP[m]
49 if symbolic
50 s{2+c} = sym(zeros(n,n));
51 else
52 s{2+c} = zeros(n,n);
53 end
54 for h = 1:n
55 % set transition rates
56 if h <= i
57 s{2+c}(h,h) = m3pps{i}{2+j}(1,1);
58 else
59 s{2+c}(h,h) = m3pps{i}{2+j}(2,2);
60 end
61 end
62 c = c + 1;
63 end
64end
65% compute D1
66if symbolic
67 s{2} = sym(zeros(n,n));
68else
69 s{2} = zeros(n,n);
70end
71for i = 1:M
72 s{2} = s{2} + s{2+i};
73end
74% compute diagonal of D0
75for h = 1:n
76 s{1}(h,h) = -sum(s{1}(h,:)+s{2}(h,:));
77end
78
79end