LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
map_hyperexp.m
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
3%
4% Input:
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)
8%
9% Output:
10% MAP: a MAP in the form of {D0,D1}
11%
12% Examples:
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
19%
20
21if nargin<3
22 p=0.99;
23end
24% there are two possible solutions, try with the first root
25E2=(1+SCV)*MEAN^2;
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
31 return
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);
38 else
39 MAP = {};
40 return
41 end
42end
43end