LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
overtake_prob.m
1function prOt = overtake_prob(self, eidx)
2% OVERTAKE_PROB Compute overtaking probability using transient Markov chain
3%
4% PROT = OVERTAKE_PROB(SELF, EIDX) computes the probability that a new
5% arrival to entry EIDX finds the server in phase-2 (post-reply processing).
6%
7% This uses a 3-state Continuous Time Markov Chain (CTMC):
8% State 0: Server idle
9% State 1: Server in phase-1 (caller is blocked)
10% State 2: Server in phase-2 (caller has been released)
11%
12% Transitions:
13% 0 -> 1: arrival (rate lambda)
14% 1 -> 2: phase-1 completion (rate mu1 = 1/S1)
15% 2 -> 0: phase-2 completion (rate mu2 = 1/S2)
16%
17% By PASTA (Poisson Arrivals See Time Averages), the overtaking probability
18% equals the steady-state probability of being in phase-2.
19%
20% For multi-server systems, an approximation is used.
21%
22% References:
23% Franks, G. and Woodside, M. "Effectiveness of early replies in
24% client-server systems", Performance Evaluation, 36(1):165-184, 1999.
25
26 lqn = self.lqn;
27 e = eidx - lqn.eshift;
28 tidx = lqn.parent(eidx);
29
30 S1 = self.servt_ph1(eidx);
31 S2 = self.servt_ph2(eidx);
32
33 % Get throughput - use entry if available, otherwise use task
34 if self.tput(eidx) > GlobalConstants.FineTol
35 lambda = self.tput(eidx);
36 elseif self.tput(tidx) > GlobalConstants.FineTol
37 lambda = self.tput(tidx);
38 else
39 lambda = 0;
40 end
41
42 c = lqn.mult(tidx); % number of servers
43
44 % Handle degenerate cases
45 if S2 < GlobalConstants.FineTol || lambda < GlobalConstants.FineTol || S1 < GlobalConstants.FineTol
46 prOt = 0;
47 return;
48 end
49
50 mu1 = 1/S1;
51 mu2 = 1/S2;
52
53 if c == 1
54 % Single server: exact CTMC solution
55 % Generator matrix Q for states {idle, phase-1, phase-2}
56 %
57 % Q = | -lambda lambda 0 |
58 % | 0 -mu1 mu1 |
59 % | mu2 0 -mu2 |
60 %
61 % Steady-state: pi * Q = 0, sum(pi) = 1
62
63 % Solve using the augmented system [Q'; 1 1 1] * pi = [0; 0; 0; 1]
64 Q = [-lambda, lambda, 0;
65 0, -mu1, mu1;
66 mu2, 0, -mu2];
67
68 A = [Q'; ones(1,3)];
69 b = [0; 0; 0; 1];
70
71 % Use least squares for numerical stability
72 pi = A \ b;
73
74 % PASTA: P(find in phase-2) = pi(3)
75 prOt = max(0, min(1, pi(3)));
76 else
77 % Multi-server approximation
78 % Based on utilization decomposition
79 rho = lambda * (S1 + S2) / c;
80
81 if rho >= 1
82 % Saturated system: probability proportional to phase-2 fraction
83 prOt = S2 / (S1 + S2);
84 else
85 % Probability a random server is in phase-2
86 % Approximation: fraction of time in phase-2 weighted by utilization
87 prOt = (S2 / (S1 + S2)) * rho;
88 end
89
90 % Bound the result
91 prOt = max(0, min(1, prOt));
92 end
93end