LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mmpp2_fitc.m
1function mmpp = mmpp2_fitc(mu, bt1, bt2, binf, m3t2, t1, t2)
2% Fits a MMPP according to [Heffes and Lucantoni, 1986].
3% mu: arrival rate
4% bt1: IDC at scale t1
5% bt2: IDC at scale t2
6% binf: IDC for t->inf
7% m3t2: third central moment
8% t1
9% t2
10
11if abs(binf-1) < 1e-8 && abs(binf-bt1) < 1e-8
12 % degenerate case, r2 = 0
13 % therefore never goes back to state 1
14 % fit a marked poisson process
15 %fprintf('Warning: marked Poisson process, constant IDC(t) = 1\n');
16 mmpp = {-mu,mu};
17 return;
18end
19
20if ~(binf>bt1 && bt1>1)
21 %fprintf('Warning: no valid MMPP(2), infeasible IDC(t): IDC(%.2f) = %.3f, IDC(inf) = %.3f\n', t1, bt1, binf);
22 %mmpp = {};
23 mmpp = {-mu,mu};
24 return;
25end
26
27% d = r1 + r2
28c = (binf-1)/(binf-bt1);
29% according to WolframAlpha
30% the solution can be written as (ProductLog[-c e^(-c)]+c)/t1
31z = -c*exp(-c);
32w = fsolve(@(w) z-w*exp(w), 1, optimset('Display','none',...
33 'MaxIter',10000,...
34 'MaxFunEvals',10000,...
35 'TolFun', 1.0e-12,...
36 'TolX',1.0e-12));
37x = (w + c)/t1;
38
39k1 = mu^3 * t2^3;
40k2 = 3*mu^2*(binf-1)*t2^2;
41k3 = 3*mu*(binf-1)/x*t2;
42k4 = 3*mu/x^2*(binf-1)*t2*exp(-x*t2);
43k5 = 6*mu/x^3*(binf-1)*(1-exp(-x*t2));
44g1t2 = m3t2 + 3*mu*t2*(mu*t2-1)*bt2 + mu*t2*(mu*t2-1)*(mu*t2-2);
45h = (g1t2 - k1 - k2 - k3*(-mu) - k4*mu*x) / ((k3/x) + k4 -k5);
46if abs(h) < 1e-4 % h=0 case
47 r1 = x/2;
48 r2 = x/2;
49 l2 = mu - 1/2 * sqrt(2*(binf-1)*mu*x);
50 l1 = mu + 1/2 * sqrt(2*(binf-1)*mu*x);
51else
52 y = (binf-1)*mu*x^3/(2*h^2);
53 r1 = x/2 * (1 + 1/sqrt(4*y + 1));
54 r2 = x - r1;
55 if (r1 < r2)
56 tmp = r1;
57 r1 = r2;
58 r2 = tmp;
59 end
60 w = h/(r1-r2);
61 w_min = -mu/r1*(r1+r2);
62 w_max = mu/r2*(r1+r2);
63 if (w < w_min || w > w_max)
64 %fprintf('Warning: ignoring third moment to achieve feasibility\n');
65 z = (binf-1)*x^3*mu;
66 u = x*z/(2*mu^2*x^2+z);
67 r1 = u+(x-u)/2;
68 r2 = x-r1;
69 delta = sqrt(z/(2*r1*r2));
70 l2 = mu - r2/x * delta;
71 l1 = l2 + delta;
72 else
73 l2 = mu - h/(r1-r2)*(r2/(r1+r2));
74 l1 = h/(r1-r2) + l2;
75 end
76end
77
78mmpp = {[-(r1+l1) r1; r2 -(r2+l2)], [l1 0; 0 l2]};
79
80end