1function AMAPS = amap2_fitall_gamma(M1,M2,M3,GAMMA)
2% Finds the equivalent AMAP(2)s (up to 4) fitting the given set of
3% characteristics. If the characteristics are infeasible, an empty cell
4% array
is returned (no approximate fitting
is performed).
6% - M1,M2,M3: moments of the inter-arrival times
7% - GAMMA: auto-correlation decay rate of the inter-arrival times
9% - AMAPS: a cell array of feasible AMAP(2) processes
15% lower bound of M3 for SCV <= 1
16M3lb = 3*M1^3*(3*SCV-1+sqrt(2)*(1-SCV)^(3/2));
18if SCV <= 1 && abs(M3 - M3lb) < degentol
19 % when M3
is close to the lower bound, the sqrt argument
is zero
22 tmp0 = M3^2/9 + ((8*M1^3)/3 - 2*M2*M1)*M3 - 3*M1^2*M2^2 + 2*M2^3;
24 % infeasible: square root of negative element
31tmp3 = (6*M2 - 12*M1^2);
33% maximum number of solutions
35 % the diagonal elements of D0 are identical
49 h2v(1) = (tmp2 + tmp1)/tmp3;
50 h2v(2) = (tmp2 - tmp1)/tmp3;
55% check
for infeasibility
75 % FIRST canonical form
77 z = M1^2*GAMMA^2 + (2*M1*h1 + 2*M1*h2 - 4*h1*h2 - 2*M1^2)*GAMMA + M1^2 - 2*M1*h1 - 2*M1*h2 + h1^2 + 2*h1*h2 + h2^2;
80 % one solution, argument of square root
is practically zero
81 r2 = (h1 - M1 + h2 + GAMMA*M1)/(2*h1);
82 r1 = (M1 - h1 - M1*r2 + h1*r2)/(h2 - M1*r2);
83 % construct MAP
if feasible
87 AMAPS{idx} = amap2_assemble(h1, h2, r1, r2, 1);
91 % two possible values of r2
93 r2v(1) = (h1 - M1 + h2 - sqrt(z) + GAMMA*M1)/(2*h1);
94 r2v(2) = (h1 - M1 + h2 + sqrt(z) + GAMMA*M1)/(2*h1);
95 % two possible values of r1
99 r1v(i) = (M1 - h1 - M1*r2 + h1*r2)/(h2 - M1*r2);
105 % construct MAP
if feasible
109 AMAPS{idx} = amap2_assemble(h1, h2, r1, r2, 1);
117 % SECOND canonical form
119 r2 = (h1 - M1 + h2 + GAMMA*M1)/h1;
120 r1 = (r2 + (h1 + h2 - h1*r2)/M1 - 2)/(r2 - 1);
121 % construct MAP
if feasible
125 AMAPS{idx} = amap2_assemble(h1, h2, r1, r2, 2);
132%
return feasible solutions
133AMAPS = AMAPS(1:(idx-1));
139 function feas = feasible(r1, r2)
140 feas = isreal(r1) && isreal(r2) && ...
141 r1 >= -r12tol && r1 <= 1+r12tol && ...
142 r2 >= -r12tol && r2 <= 1+r12tol;