LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_xmax_hyperexp.m
1%{ @file fj_xmax_hyperexp.m
2 % @brief Expected maximum of K i.i.d. Hyperexponential-2 random variables
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Expected maximum of K i.i.d. Hyperexponential-2 random variables
9 %
10 % @details
11 % Computes the expected value of the maximum of K independent and
12 % identically distributed Hyperexponential random variables with
13 % two branches.
14 %
15 % The pdf of H2 is: f(t) = p1*mu1*exp(-mu1*t) + p2*mu2*exp(-mu2*t)
16 % where p1 + p2 = 1 and p1, p2 > 0.
17 %
18 % The expected maximum is:
19 % X_K^max = sum_{n=1}^{K} (-1)^{n+1} * sum_{m=0}^{n} C(n,m) * p1^m * p2^{n-m} / (m*mu1 + (n-m)*mu2)
20 %
21 % The H2 distribution has CV > 1, making it useful for modeling
22 % high-variability service times.
23 %
24 % @par Syntax:
25 % @code
26 % Xmax = fj_xmax_hyperexp(K, p1, mu1, mu2)
27 % @endcode
28 %
29 % @par Parameters:
30 % <table>
31 % <tr><th>Name<th>Description
32 % <tr><td>K<td>Number of parallel servers (positive integer)
33 % <tr><td>p1<td>Probability of branch 1 (0 < p1 < 1)
34 % <tr><td>mu1<td>Rate of branch 1
35 % <tr><td>mu2<td>Rate of branch 2
36 % </table>
37 %
38 % @par Returns:
39 % <table>
40 % <tr><th>Name<th>Description
41 % <tr><td>Xmax<td>Expected maximum service time X_K^max
42 % </table>
43 %
44 % @par Reference:
45 % A. Thomasian, "Analysis of Fork/Join and Related Queueing Systems",
46 % ACM Computing Surveys, Vol. 47, No. 2, Article 17, July 2014.
47 % Page 17:13, Eq. (15).
48%}
49function Xmax = fj_xmax_hyperexp(K, p1, mu1, mu2)
50
51if K < 1
52 line_error(mfilename, 'K must be a positive integer. Got K=%d.', K);
53end
54
55if p1 <= 0 || p1 >= 1
56 line_error(mfilename, 'p1 must be in (0,1). Got p1=%.4f.', p1);
57end
58
59if mu1 <= 0 || mu2 <= 0
60 line_error(mfilename, 'Rates mu1 and mu2 must be positive.');
61end
62
63p2 = 1 - p1;
64
65% X_K^max = sum_{n=1}^{K} (-1)^{n+1} * sum_{m=0}^{n} C(n,m) * p1^m * p2^{n-m} / (m*mu1 + (n-m)*mu2)
66Xmax = 0;
67for n = 1:K
68 inner_sum = 0;
69 for m = 0:n
70 denominator = m * mu1 + (n - m) * mu2;
71 if denominator > 0
72 inner_sum = inner_sum + nchoosek(n, m) * (p1^m) * (p2^(n - m)) / denominator;
73 end
74 end
75 Xmax = Xmax + ((-1)^(n + 1)) * inner_sum;
76end
77
78end