1function [MAP,mu1,mu2,p]=map_hyperexp(MEAN,SCV,p)
2% MAP=map_hyperexp(MEAN,SCV,p) - Fit a two-phase Hyperexponential process as a MAP
5% MEAN: mean inter-arrival time of the process
6% SCV: squared coefficient of variation of inter-arrival times
7% p: probability of being served in phase 1 (DEFAULT: p=0.99)
10% MAP: a MAP in the form of {D0,D1}
13% - MAP=map_hyperexp(1,2) a two-phase Hyperexponential process where
14% phase 1
is selected with probability 0.99
15% - MAP=map_hyperexp(1,2,0.2) a two-phase Hyperexponential process where
16% phase 1
is selected with probability 0.2
17% - map_isfeasible(map_hyperexp(1,25,0.5)) a two-phase Hyperexponential
18% with SCV=25 and p=0.5 does not exist
24% there are two possible solutions,
try with the first root
26Delta=-4*p*MEAN^2+4*p^2*MEAN^2+2*E2*p-2*E2*p^2;
27mu2=(-2*MEAN+2*p*MEAN+sqrt(Delta))/(E2*p-2*MEAN^2);
28mu1=mu2*p/(p-1+MEAN*mu2);
29MAP={[-mu1,0;0,-mu2],[mu1*p,mu1*(1-p);mu2*p,mu2*(1-p)]};
30if map_isfeasible(MAP) %
if the solution
is feasible
32else %
if the solution
is not feasible go
for the second root
33 mu2=(-2*MEAN+2*p*MEAN-sqrt(Delta))/(E2*p-2*MEAN^2);
34 mu1=mu2*p/(p-1+MEAN*mu2);
35 MAP={[-mu1,0;0,-mu2],[mu1*p,mu1*(1-p);mu2*p,mu2*(1-p)]};
36 if p>1e-6 && ~map_isfeasible(MAP) %
if the solution
is not feasible
try to decrease p
37 [MAP,mu1,mu2,p] = map_hyperexp(MEAN,SCV,p/10);