LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_t_hlru.m
1%{ @file cache_t_hlru.m
2 % @brief Computes characteristic times for hierarchical LRU cache levels
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes characteristic times for hierarchical LRU cache
9 %
10 % @details
11 % This function computes the characteristic time for each level of a
12 % hierarchical LRU cache using fixed-point iteration.
13 %
14 % @par Syntax:
15 % @code
16 % t = cache_t_hlru(gamma, m)
17 % @endcode
18 %
19 % @par Parameters:
20 % <table>
21 % <tr><th>Name<th>Description
22 % <tr><td>gamma<td>Item popularity probabilities or arrival rates
23 % <tr><td>m<td>Cache capacity vector
24 % </table>
25 %
26 % @par Returns:
27 % <table>
28 % <tr><th>Name<th>Description
29 % <tr><td>t<td>Characteristic time for each cache level
30 % </table>
31%}
32function t = cache_t_hlru(gamma,m)
33% fsolve solution to to T1,T2,...,Th, i.e., the characteristic time of
34% each list
35[n,h]=size(gamma);
36fun = @time;
37x = ones(1,h);
38options = optimoptions('fsolve','MaxIter',1e5,'MaxFunEvals',1e6,'Display','off');
39t = fsolve(fun,x,options);
40
41
42function F = time(x)
43F = zeros(1,h);
44
45% the probability of each item at each list
46for a = 1:h
47 temp1 = ones(n,1);
48 temp2 = zeros(n,1);
49 probh = zeros(n,1);
50for k = 1:n
51 for s = 1:a
52 temp1(k) = temp1(k)*(1-exp(-gamma(k,s)*x(s)));
53 end
54
55 middtemp = 1;
56 middtemp2 = 0;
57 for l = 1:a-1
58 for s = 1:l
59 middtemp = middtemp*(1-exp(-gamma(k,s)*x(s)));
60 end
61 middtemp2 = middtemp2+middtemp;
62 end
63 temp2(k) = exp(-gamma(k,a)*x(a))*(1+middtemp2);
64
65 probh(k) = temp1(k)/(temp1(k)+temp2(k));
66end
67
68F(a) = m(a)-sum(probh);
69end
70end
71
72end