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 % The method call needs its receiver: without it this reads as a
35 % call to a function named D and errors out, which made every model
36 % holding a MAP fail at getStruct time (refreshPetriNetNodes.m:50
37 % asks a Markovian firing distribution for its phase count).
38 n = size(self.D(0), 1);
39 end
40
41 function Di = D(self, i, wantSparse)
42 % Di = D(i)
43 if nargin<3
44 wantSparse = false;
45 end
46
47 % Return representation matrix, e.g., D0=MAP.D(0)
48 if wantSparse
49 if nargin<2
50 Di=self.getProcess;
51 else
52 Di=self.getProcess{i+1};
53 end
54 else
55 if nargin<2
56 Di=self.getProcess;
57 for i=1:length(Di)
58 Di(i)=full(Di(i));
59 end
60 else
61 Di=full(self.getProcess{i+1});
62 end
63 end
64 end
65
66 function meant = evalMeanT(self, t)
67 % MEANT = EVALMEANT(SELF,T)
68
69 meant = map_count_mean(self.D, t);
70 end
71
72 function vart = evalVarT(self, t)
73 % VART = EVALVART(SELF,T)
74
75 % Evaluate the variance-time curve at timescale t
76 vart = map_count_var(self.D, t);
77 end
78
79 function acf = evalACFT(self, lags, timescale)
80 % ACF = EVALACFT(self, lags)
81 %
82 % Evaluate the autocorrelation in counts at timescale t
83
84 acf = map_acfc(self.D, lags, timescale);
85 end
86
87 function acf = getACF(self, lags)
88 % ACF = GETACF(self, lags)
89
90 acf = map_acf(self.D,lags);
91 end
92
93 function [gamma2, gamma] = getACFDecay(self)
94 % [gamma2, gamma] = GETACFDECAY(self)
95 %
96 % gamma2: asymptotic decay rate of acf
97 % gamma: interpolated decay rate of acf
98
99 gamma2 = map_gamma2(self.D);
100 if nargout>1
101 gamma = map_gamma(self.D);
102 end
103 end
104
105 function id = getIDC(self, t) % index of dispersion for counts
106 % IDC = GETIDC() % ASYMPTOTIC INDEX OF DISPERSION
107
108 if nargin < 2
109 id = map_idc(self.D);
110 else
111 id = map_count_var(self.D,t) / map_count_mean(self.D,t);
112 end
113 end
114
115 function lam = getRate(self)
116 % MAP = GETRATE()
117
118 lam = map_lambda(self.D);
119 end
120
121 function mapr = toTimeReversed(self)
122 mapr = MAP(map_timereverse(self.D));
123 end
124
125 function X = sample(self, n)
126 % X = SAMPLE(N)
127 if nargin<2 %~exist('n','var'),
128 n = 1;
129 end
130 MAP = self.getProcess;
131 if map_isfeasible(MAP)
132 X = map_sample(MAP,n);
133 else
134 line_error(mfilename,'This process is infeasible (negative rates).');
135 end
136 end
137
138 function self = setMean(self,MEAN)
139 % UPDATEMEAN(SELF,MEAN)
140 % Update parameters to match the given mean
141 newMAP = map_scale(self.D,MEAN);
142 self.params{1}.paramValue = newMAP{1};
143 self.params{2}.paramValue = newMAP{2};
144 end
145
146 function bool = isImmediate(self)
147 bool = self.getMean < GlobalConstants.FineTol;
148 end
149
150 function mmdp = toMMDP(self)
151 % TOMMDP Convert MAP to MMDP (deterministic representation)
152 %
153 % Converts this Markovian Arrival Process to a Markov-Modulated
154 % Deterministic Process suitable for fluid queue analysis.
155 %
156 % @return mmdp MMDP representation of this MAP
157
158 mmdp = MMDP.fromMAP(self);
159 end
160
161 end
162
163 methods (Static)
164
165 function map = rand(order)
166 % MAP = RAND(ORDER)
167 %
168 % Generate random MAP using uniform random numbers
169 if nargin < 1
170 order = 2;
171 end
172 map = MAP(map_rand(order));
173 end
174
175 function map = randn(order, mu, sigma)
176 % MAP = RANDN(ORDER, MU, SIGMA)
177 %
178 % Generate random MAP using specified Gaussian parameter and
179 % taking the absolute value of the resulting values
180 map = MAP(map_randn(order, mu, sigma));
181 end
182
183 end
184end
Definition Station.m:287
Definition Station.m:245