LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MMDP2.m
1classdef MMDP2 < MMDP
2 % 2-state Markov-Modulated Deterministic Process
3 %
4 % A specialized MMDP with exactly 2 phases, using a convenient
5 % parameterization analogous to MMPP2.
6 %
7 % Parameterization:
8 % r0, r1: Deterministic rates in states 0 and 1
9 % sigma0: Transition rate from state 0 to state 1
10 % sigma1: Transition rate from state 1 to state 0
11 %
12 % The generator matrix is:
13 % Q = [-sigma0, sigma0; sigma1, -sigma1]
14 %
15 % The rate matrix is:
16 % R = diag([r0, r1])
17 %
18 % Copyright (c) 2012-2026, Imperial College London
19 % All rights reserved.
20
21 methods
22 function self = MMDP2(r0, r1, sigma0, sigma1)
23 % MMDP2 Create a 2-state Markov-Modulated Deterministic Process
24 %
25 % @brief Creates a 2-state MMDP with specified rates and transitions
26 % @param r0 Deterministic rate in state 0
27 % @param r1 Deterministic rate in state 1
28 % @param sigma0 Transition rate from state 0 to state 1
29 % @param sigma1 Transition rate from state 1 to state 0
30 % @return self MMDP2 instance
31
32 Q = [-sigma0, sigma0; sigma1, -sigma1];
33 R = diag([r0; r1]);
34 self@MMDP(Q, R);
35 self.name = 'MMDP2';
36
37 % Override parameters with original scalar values for convenience
38 self.params = cell(1, 4);
39 setParam(self, 1, 'r0', r0);
40 setParam(self, 2, 'r1', r1);
41 setParam(self, 3, 'sigma0', sigma0);
42 setParam(self, 4, 'sigma1', sigma1);
43 end
44
45 function rate = getMeanRate(self)
46 % GETMEANRATE Compute stationary mean rate (closed-form)
47 %
48 % For a 2-state MMDP, the mean rate has the closed form:
49 % E[r] = (r0*σ1 + r1*σ0) / (σ0 + σ1)
50 %
51 % @return rate Stationary mean deterministic rate
52
53 r0 = self.getParam(1).paramValue;
54 r1 = self.getParam(2).paramValue;
55 sigma0 = self.getParam(3).paramValue;
56 sigma1 = self.getParam(4).paramValue;
57 rate = (r0*sigma1 + r1*sigma0) / (sigma0 + sigma1);
58 end
59
60 function scv = getSCV(self)
61 % GETSCV Compute squared coefficient of variation (closed-form)
62 %
63 % For a 2-state MMDP, the SCV has a closed form based on
64 % the variance of rates over the stationary distribution.
65 %
66 % @return scv Squared coefficient of variation
67
68 r0 = self.getParam(1).paramValue;
69 r1 = self.getParam(2).paramValue;
70 sigma0 = self.getParam(3).paramValue;
71 sigma1 = self.getParam(4).paramValue;
72
73 % Stationary probabilities
74 pi0 = sigma1 / (sigma0 + sigma1);
75 pi1 = sigma0 / (sigma0 + sigma1);
76
77 % Mean and variance
78 mean_rate = pi0 * r0 + pi1 * r1;
79 var_rate = pi0 * r0^2 + pi1 * r1^2 - mean_rate^2;
80
81 if mean_rate > 0
82 scv = var_rate / (mean_rate^2);
83 else
84 scv = Inf;
85 end
86 end
87
88 function n = getNumberOfPhases(~)
89 % GETNUMBEROFPHASES Return the number of phases
90 %
91 % @return n Always 2 for MMDP2
92
93 n = 2;
94 end
95
96 function Q_mat = Q(self)
97 % Q Return the generator matrix
98 %
99 % @return Q_mat 2×2 generator matrix
100
101 sigma0 = self.getParam(3).paramValue;
102 sigma1 = self.getParam(4).paramValue;
103 Q_mat = [-sigma0, sigma0; sigma1, -sigma1];
104 end
105
106 function R_mat = R(self)
107 % R Return the rate matrix (diagonal)
108 %
109 % @return R_mat 2×2 diagonal rate matrix
110
111 r0 = self.getParam(1).paramValue;
112 r1 = self.getParam(2).paramValue;
113 R_mat = diag([r0; r1]);
114 end
115
116 function r_vec = r(self)
117 % r Return the rate vector
118 %
119 % @return r_vec 2-vector of rates [r0; r1]
120
121 r0 = self.getParam(1).paramValue;
122 r1 = self.getParam(2).paramValue;
123 r_vec = [r0; r1];
124 end
125 end
126end