LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
lqn_overtake_markov.m
1function prOt = lqn_overtake_markov(clientPhases, prVisit, xj, y_aj)
2% LQN_OVERTAKE_MARKOV Overtaking probability via the LQNS Markov phased-server chain.
3%
4% Layer-1 port of LQNS V6 (lqns/slice.cc setRates + prOvertakingStates,
5% lqns/overtake.cc computeOvertaking) for the single-conditioning case
6% (calling entry == conditioning entry). Reproduces `lqns -t overtaking`:
7% e.g. 31-overtaking -> prOt(server phase 2) = 0.5.
8%
9% Inputs
10% clientPhases : (maxPhaseA+1) x 5 matrix, row idx = client phase p (p=0..maxPhaseA).
11% columns [nSlices, service, y_ij, y_ik, t_k] per phase, where
12% nSlices = 1 + sum(rendezvous calls in phase p),
13% service = total phase host residence (slice mean = service/nSlices),
14% y_ij = calls to the server task, y_ik = calls to other tasks,
15% t_k = mean time at other tasks (rendezvousDelay/y_ik).
16% Row 1 (p=0) is the client think slice (service = thinkTime).
17% prVisit : client entry visit probability (1 for ref/sole entry).
18% xj : server residenceTimeForPhase(j) for the server phase j being tested.
19% y_aj : (maxPhaseA+1) vector, y_aj(1)=total calls, y_aj(i+1)=phase-i calls.
20%
21% Output
22% prOt : overtaking probability P(new arrival finds server in phase j).
23%
24% Reference: Franks & Woodside, "Effectiveness of early replies in client-server
25% systems", Perf. Eval. 36 (1999). See [[overtaking-markov-port]].
26
27maxPhaseA = size(clientPhases,1) - 1;
28nStates = maxPhaseA + 1;
29
30% --- setRates for each client phase (0..maxPhaseA) ---
31a = zeros(1,nStates); b = zeros(1,nStates); c = zeros(1,nStates); d = zeros(1,nStates);
32for idx = 1:nStates
33 p = idx - 1;
34 if p == maxPhaseA, prA = prVisit; else, prA = 1.0; end
35 [a(idx),b(idx),c(idx),d(idx)] = local_setRates(xj, prA, ...
36 clientPhases(idx,1), clientPhases(idx,2), clientPhases(idx,3), ...
37 clientPhases(idx,4), clientPhases(idx,5));
38end
39
40% --- prOvertakingStates: PrOT(i+1,r+1,1)=overtaking, (:,:,2)=next ---
41PrOT = zeros(nStates, nStates, 2);
42for i0 = 0:maxPhaseA
43 temp = 1.0;
44 for r0 = 0:maxPhaseA
45 if r0 == i0, continue; end
46 temp = temp * local_prodOfB(b(r0+1), d(r0+1));
47 end
48 product = 1.0 / local_denominator(b(i0+1), d(i0+1), temp);
49 r0 = i0;
50 while true
51 PrOT(i0+1, r0+1, 1) = c(i0+1) * product;
52 PrOT(i0+1, r0+1, 2) = a(i0+1) * product;
53 if r0 == 0, r0 = maxPhaseA; else, r0 = r0 - 1; end
54 product = product * local_prodOfB(b(r0+1), d(r0+1));
55 if r0 == i0, break; end
56 end
57end
58
59% --- computeOvertaking (entA == entC): nextProb(i)=1 for the call-carrying phase ---
60nextProb = zeros(1, maxPhaseA);
61if maxPhaseA >= 1, nextProb(maxPhaseA) = 1.0; end
62prOt = 0.0;
63for i = 1:maxPhaseA
64 if clientPhases(i+1,3) == 0, continue; end % y_ij for phase i
65 temp = 1.0; % single-conditioning: (y_ab/y_aj_i)*(y_cd/y_cj0)=1
66 acc = 0.0;
67 for r = 1:maxPhaseA
68 acc = acc + temp * nextProb(r) * PrOT(i+1, r+1, 1);
69 end
70 prOt = prOt + acc * (y_aj(1) / y_aj(i+1)); % condition
71end
72end
73
74% ---------------------------------------------------------------------------
75function [a,b,c,d] = local_setRates(xj, prA, nSlices, service, y_ij, y_ik, t_k)
76y_sum = y_ij + y_ik + 1.0;
77if nSlices ~= 0, slice = service / nSlices; else, slice = 0.0; end
78temp = xj + t_k;
79if ~isfinite(temp), q0=1.0; q3=0.0;
80elseif temp ~= 0, q0=xj/temp; q3=t_k/temp;
81else, q0=0.0; q3=1.0; end
82temp = xj + slice;
83if ~isfinite(temp), q1=0.0; q5=1.0;
84elseif temp ~= 0, q1=xj/temp; q5=slice/temp;
85else, q1=1.0; q5=0.0; end
86q2 = y_ik / y_sum; q4 = y_ij / y_sum; q6 = prA / y_sum;
87a = q5 + q1*q2*q3; b = q1*q6; c = q1*q4; d = q0*q1*q2;
88end
89
90function v = local_prodOfB(b, d), v = b / (1.0 - d); end
91function v = local_denominator(b, d, product), v = 1.0 - (b*product + d); end
Definition Station.m:245