LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MAP.m
1classdef MAP < MarkovModulated
2 % Markovian Arrival Process for correlated arrival modeling
3 %
4 % Models arrival streams with correlation and burstiness via D0 and D1 matrices.
5 %
6 % Copyright (c) 2012-2026, Imperial College London
7 % All rights reserved.
8
9 methods
10 %Constructor
11 function self = MAP(D0,D1)
12 % MAP Create a Markovian Arrival Process instance
13 %
14 % @brief Creates a MAP with specified D0 and D1 matrices
15 % @param D0 Generator matrix for transitions without arrivals
16 % @param D1 Rate matrix for transitions with arrivals
17 % @return self MAP instance with specified matrices
18
19 self@MarkovModulated('MAP',2);
20 if nargin < 2 && iscell(D0)
21 M = D0;
22 D0 = M{1};
23 D1 = M{2};
24 end
25 setParam(self, 1, 'D0', D0);
26 setParam(self, 2, 'D1', D1);
27 self.process = {D0,D1};
28 if ~map_isfeasible(self.D)
29 line_warning(mfilename,'MAP is infeasible.\n');
30 end
31 end
32
33 function n = getNumberOfPhases(self)
34 n = length(D(0));
35 end
36
37 function Di = D(self, i, wantSparse)
38 % Di = D(i)
39 if nargin<3
40 wantSparse = false;
41 end
42
43 % Return representation matrix, e.g., D0=MAP.D(0)
44 if wantSparse
45 if nargin<2
46 Di=self.getProcess;
47 else
48 Di=self.getProcess{i+1};
49 end
50 else
51 if nargin<2
52 Di=self.getProcess;
53 for i=1:length(Di)
54 Di(i)=full(Di(i));
55 end
56 else
57 Di=full(self.getProcess{i+1});
58 end
59 end
60 end
61
62 function meant = evalMeanT(self, t)
63 % MEANT = EVALMEANT(SELF,T)
64
65 meant = map_count_mean(self.D, t);
66 end
67
68 function vart = evalVarT(self, t)
69 % VART = EVALVART(SELF,T)
70
71 % Evaluate the variance-time curve at timescale t
72 vart = map_count_var(self.D, t);
73 end
74
75 function acf = evalACFT(self, lags, timescale)
76 % ACF = EVALACFT(self, lags)
77 %
78 % Evaluate the autocorrelation in counts at timescale t
79
80 acf = map_acfc(self.D, lags, timescale);
81 end
82
83 function acf = getACF(self, lags)
84 % ACF = GETACF(self, lags)
85
86 acf = map_acf(self.D,lags);
87 end
88
89 function [gamma2, gamma] = getACFDecay(self)
90 % [gamma2, gamma] = GETACFDECAY(self)
91 %
92 % gamma2: asymptotic decay rate of acf
93 % gamma: interpolated decay rate of acf
94
95 gamma2 = map_gamma2(self.D);
96 if nargout>1
97 gamma = map_gamma(self.D);
98 end
99 end
100
101 function id = getIDC(self, t) % index of dispersion for counts
102 % IDC = GETIDC() % ASYMPTOTIC INDEX OF DISPERSION
103
104 if nargin < 2
105 id = map_idc(self.D);
106 else
107 id = map_count_var(self.D,t) / map_count_mean(self.D,t);
108 end
109 end
110
111 function lam = getRate(self)
112 % MAP = GETRATE()
113
114 lam = map_lambda(self.D);
115 end
116
117 function mapr = toTimeReversed(self)
118 mapr = MAP(map_timereverse(self.D));
119 end
120
121 function X = sample(self, n)
122 % X = SAMPLE(N)
123 if nargin<2 %~exist('n','var'),
124 n = 1;
125 end
126 MAP = self.getProcess;
127 if map_isfeasible(MAP)
128 X = map_sample(MAP,n);
129 else
130 line_error(mfilename,'This process is infeasible (negative rates).');
131 end
132 end
133
134 function self = setMean(self,MEAN)
135 % UPDATEMEAN(SELF,MEAN)
136 % Update parameters to match the given mean
137 newMAP = map_scale(self.D,MEAN);
138 self.params{1}.paramValue = newMAP{1};
139 self.params{2}.paramValue = newMAP{2};
140 end
141
142 function bool = isImmediate(self)
143 bool = self.getMean < GlobalConstants.FineTol;
144 end
145
146 end
147
148 methods (Static)
149
150 function map = rand(order)
151 % MAP = RAND(ORDER)
152 %
153 % Generate random MAP using uniform random numbers
154 if nargin < 1
155 order = 2;
156 end
157 map = MAP(map_rand(order));
158 end
159
160 function map = randn(order, mu, sigma)
161 % MAP = RANDN(ORDER, MU, SIGMA)
162 %
163 % Generate random MAP using specified Gaussian parameter and
164 % taking the absolute value of the resulting values
165 map = MAP(map_randn(order, mu, sigma));
166 end
167
168 end
169end