LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mmap_compress.m
1%{ @file mmap_compress.m
2 % @brief Compresses an MMAP into a smaller representation
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Compresses a Marked MAP into a smaller representation
9 %
10 % @details
11 % This function compresses an MMAP (Marked Markovian Arrival Process) into
12 % a smaller representation using various compression methods including
13 % mixture fitting, MAMAP2, and M3PP approaches.
14 %
15 % @par Syntax:
16 % @code
17 % MMAP = mmap_compress(MMAP)
18 % MMAP = mmap_compress(MMAP, config)
19 % @endcode
20 %
21 % @par Parameters:
22 % <table>
23 % <tr><th>Name<th>Description
24 % <tr><td>MMAP<td>Original Marked Markovian Arrival Process
25 % <tr><td>config<td>(Optional) Configuration struct with compression method
26 % </table>
27 %
28 % @par Returns:
29 % <table>
30 % <tr><th>Name<th>Description
31 % <tr><td>MMAP<td>Compressed MMAP
32 % </table>
33%}
34function MMAP = mmap_compress(MMAP, config)
35if nargin<2 % config not supplied: use the default method
36 config = struct;
37end
38if ~isfield(config,'method')
39 config.method = 'default';
40end
41
42K = length(MMAP)-2;
43switch config.method
44 case {'default','mixture','mixture.order1'}
45 % Order-1 mixture (M3A). K components, one per class, recombined by
46 % mmap_mixture with the class probabilities p_c as mixing weights.
47 %
48 % Component c must carry the law of the inter-arrival time CONDITIONED
49 % ON THE ARRIVAL THAT ENDS IT BEING OF CLASS c: mmap_mixture marks the
50 % arrival LEAVING component c with class c (mmap_mixture.m:24-31), so
51 % the class of an arrival and the interval preceding it are both
52 % governed by the component active during that interval. That
53 % conditional law is the class-c BACKWARD moment set B(c,1:3), i.e.
54 % E[T^k | class of the ending arrival = c] (mmap_backward_moment.m).
55 % It is NOT the forward moment (E[T^k | class of the STARTING arrival
56 % = c]) and it is NOT the class-c marginal MAP from mmap_maps (whose
57 % mean is 1/lambda_c, the time between successive class-c arrivals --
58 % mixing those with weights lambda_c/Lambda inflates the mean to
59 % K/Lambda). This mirrors 'mixture.order2', which conditions on the
60 % (last,next) class PAIR and fits the CROSS moments
61 % (mmap_mixture_fit.m:1-5), order 1 simply drops the "last" index.
62 %
63 % PRESERVED exactly: aggregate moments 1..3, via the M3A mixture law
64 % M_k = sum_c B(k,c)*p_c stated in mmap_backward_moment.m:5-11 (M1 is
65 % always exact because aph2_adjust never alters M1; M2/M3 are exact
66 % when APH(2)-feasible); the class probabilities p_c and hence the
67 % per-class rates lambda_c = p_c/M1; marking consistency
68 % D1 = sum_c D1^(c); and MAP feasibility (mmap_mixture normalizes).
69 %
70 % LOST by construction: every autocorrelation. mmap_mixture re-enters
71 % each component at its map_pie on every arrival (mmap_mixture.m:20-22),
72 % so the intervals are i.i.d. and the result is a RENEWAL process:
73 % acf -> 0, IDC -> the SCV-determined renewal value, and the class
74 % sequence becomes i.i.d. (sigma(i,j) -> p_j). Retaining sigma is
75 % exactly what 'mixture.order2' buys with its K^2 components.
76 p = mmap_pc(MMAP);
77 B = mmap_backward_moment(MMAP, [1 2 3], 1);
78 AMAPs = cell(1,K);
79 for k=1:K
80 if p(k) <= GlobalConstants.Zero
81 % Class c never arrives, so B(k,:) is an 0/0 normalization.
82 % The component carries zero mixture weight: any proper MAP
83 % leaves the result unchanged.
84 AMAPs{k} = map_exponential(1);
85 else
86 AMAPs{k} = aph2_fit(B(k,1), B(k,2), B(k,3));
87 end
88 end
89 MMAP = mmap_mixture(p, AMAPs);
90 case 'mixture.order2'
91 MMAP = mmap_mixture_fit_mmap(MMAP);
92 case 'mamap2'
93 MMAP = mmap_normalize(MMAP);
94 MMAP = mamap2m_fit_mmap(MMAP);
95 case 'mamap2.fb'
96 MMAP = mmap_normalize(MMAP);
97 MMAP = mamap2m_fit_gamma_fb_mmap(MMAP);
98 case 'm3pp.approx_cov'
99 MMAP = m3pp2m_fitc_theoretical(MMAP, 'approx_cov', 1, 1e6); %derivest
100 case 'm3pp.approx_ag'
101 MMAP = m3pp2m_fitc_theoretical(MMAP, 'approx_ag', 1, 1e6); %derivest
102 case 'm3pp.exact_delta'
103 MMAP = m3pp2m_fitc_theoretical(MMAP, 'exact_delta', 1, 1e6); %derivest
104 case 'm3pp.approx_delta'
105 MMAP = m3pp2m_fitc_theoretical(MMAP, 'approx_delta', 1, 1e6); %derivest
106end
107MMAP = mmap_normalize(MMAP);
108end
Definition Station.m:245