2 % @brief Characteristic times
for h-LRU / LRU(m) cache lists
4 % @author LINE Development Team
8 % @brief Characteristic time of each list of an h-LRU cache
11 % Solves
the TTL (characteristic-time) fixed point of
the list-based h-LRU
12 % (LRU(m)) policy: sum_k pi_l(k;T) = m(l)
for each list l, where
the level
13 % probabilities follow
the birth-death form pi_l ~ prod_{s<=l} (1-e_s)/e_s
14 % with e_s = exp(-gamma_k*T(s)) (Gast and Van Houdt, SIGMETRICS 2015).
15 % Solved by per-list bisection with Gauss-Seidel sweeps; no Optimization
20 % t = cache_t_hlru(gamma, m)
25 % <tr><th>Name<th>Description
26 % <tr><td>gamma<td>(n x 1) per-item request rates; an (n x h) matrix
is
27 % accepted
for backward compatibility (first
column used)
28 % <tr><td>m<td>(1 x h) list capacities
33 % <tr><th>Name<th>Description
34 % <tr><td>t<td>(1 x h) characteristic time of each list
37function t = cache_t_hlru(gamma, m)
39n = length(lam); %#ok<NASGU>
43t = ones(1,h) / max(mean(lam), GlobalConstants.FineTol);
45for sweep = 1:maxSweeps
49 hi = max(t(l), 1/max(mean(lam), GlobalConstants.FineTol));
50 while occ_l(lam, t, l, hi, h) < m(l) && hi < 1e12
55 if occ_l(lam, t, l, mid, h) < m(l)
63 if max(abs(t-told)./max(told,GlobalConstants.Zero)) < GlobalConstants.FineTol
69function occ = occ_l(lam, t, l, tl, h)
77 e = exp(-lam(k)*t(s));
78 w(1+s) = w(s) * (1-e)/max(e, GlobalConstants.Zero);
80 occ = occ + w(1+l)/sum(w);