1function SUP = mmap_super_safe(MMAPs, maxorder, method)
2% SUP = mmap_super_safe(MMAPs, maxorder)
3% Superposition of marked MAPS
8empty = cellfun(@isempty, MMAPs);
10% A component with an all-zero aggregate arrival matrix (D1 == 0) has zero
11% arrival rate: it contributes nothing to
the superposition. When such a
12% component carries more than one phase (e.g.
the transient slow phase of a
13% high-SCV APH fit that reaches a station
the flow never
visits), its phase
14% generator D0+D1
is absorbing, so map_scv/map_pie/map_prob -> ctmc_solve fail
15% with "no recurrent state". Canonicalize it to
the equivalent order-1 null
16% (matching
the marking
count), whose moments are well defined and whose
17% superposition
is an identity. Detection uses
the arrival-matrix norm, not
18% mmap_lambda, because mmap_lambda itself calls map_prob -> ctmc_solve.
19for iz = 1:numel(MMAPs)
20 if size(MMAPs{iz}{1},1) > 1 && norm(full(MMAPs{iz}{2}),1) < 1e-13
21 MMAPs{iz} = mmap_exponential(zeros(1,numel(MMAPs{iz})-2), 1);
24scv_unmarked = cellfun(@map_scv, MMAPs);
25[~,Iset]=sort(scv_unmarked); % sort flows with small scv first
27for i=Iset(:)
' % low-SCV first
28 % Bound the order of each individual flow to maxorder. A single flow
29 % whose order already exceeds maxorder (e.g. a high-order Erlang from a
30 % near-deterministic APH fit) would otherwise pass through uncapped as
31 % the superposition base and blow up downstream matrix-analytic solves.
32 if length(MMAPs{i}{1}) > maxorder
34 MMAPs{i} = mamap2m_fit_gamma_fb_mmap(MMAPs{i});
36 MMAPs{i} = mmap_exponential(mmap_lambda(MMAPs{i}));
39 if isempty(SUP) % is this is the first MMAP
42 % then treat it as a Poisson process if the limit is 1
43 SUP = mmap_exponential(mmap_lambda(MMAPs{i}));
46 if length(SUP{1}) * length(MMAPs{i}{1}) > maxorder
47 % otherwise treat it as a marked AMAP(2) process if the limit is >1
48 if length(SUP{1}) * 2 <= maxorder
49 SUP = mmap_super(SUP, mamap2m_fit_gamma_fb_mmap(MMAPs{i}), method);
51 SUP = mmap_super(SUP, mmap_exponential(mmap_lambda(MMAPs{i})), method);
54 SUP = mmap_super(SUP,MMAPs{i}, method);