LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_t_hlru.m
1%{ @file cache_t_hlru.m
2 % @brief Characteristic times for h-LRU / LRU(m) cache lists
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Characteristic time of each list of an h-LRU cache
9 %
10 % @details
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
16 % Toolbox dependency.
17 %
18 % @par Syntax:
19 % @code
20 % t = cache_t_hlru(gamma, m)
21 % @endcode
22 %
23 % @par Parameters:
24 % <table>
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
29 % </table>
30 %
31 % @par Returns:
32 % <table>
33 % <tr><th>Name<th>Description
34 % <tr><td>t<td>(1 x h) characteristic time of each list
35 % </table>
36%}
37function t = cache_t_hlru(gamma, m)
38lam = gamma(:,1);
39n = length(lam); %#ok<NASGU>
40h = length(m);
41m = m(:)';
42
43t = ones(1,h) / max(mean(lam), GlobalConstants.FineTol);
44maxSweeps = 200;
45for sweep = 1:maxSweeps
46 told = t;
47 for l = 1:h
48 lo = 0;
49 hi = max(t(l), 1/max(mean(lam), GlobalConstants.FineTol));
50 while occ_l(lam, t, l, hi, h) < m(l) && hi < 1e12
51 hi = 2*hi;
52 end
53 for it = 1:100
54 mid = (lo+hi)/2;
55 if occ_l(lam, t, l, mid, h) < m(l)
56 lo = mid;
57 else
58 hi = mid;
59 end
60 end
61 t(l) = (lo+hi)/2;
62 end
63 if max(abs(t-told)./max(told,GlobalConstants.Zero)) < GlobalConstants.FineTol
64 break
65 end
66end
67end
68
69function occ = occ_l(lam, t, l, tl, h)
70t(l) = tl;
71n = length(lam);
72occ = 0;
73for k = 1:n
74 w = zeros(1, h+1);
75 w(1) = 1;
76 for s = 1:h
77 e = exp(-lam(k)*t(s));
78 w(1+s) = w(s) * (1-e)/max(e, GlobalConstants.Zero);
79 end
80 occ = occ + w(1+l)/sum(w);
81end
82end
Definition Station.m:245