LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_t_lrum.m
1%{ @file cache_t_lrum.m
2 % @brief Computes characteristic times for LRU(m) cache levels
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes characteristic times for LRU(m) cache
9 %
10 % @details
11 % This function computes the characteristic time for each level of an
12 % LRU(m) cache using fixed-point iteration.
13 %
14 % @par Syntax:
15 % @code
16 % t = cache_t_lrum(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_lrum(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
41function F = time(x)
42F = zeros(1,h);
43
44% the probability of each item at each list
45trans = zeros(n,h);
46logtrans = zeros(n,h);
47denom = zeros(1,n);
48capa = zeros(1,h);
49stablecapa = zeros(1,h);
50for k =1:n
51 for j = 1:h
52 trans(k,j) = exp(gamma(k,j)*x(j))-1; %birth and death
53 logtrans(k,j) = log(trans(k,j));
54 end
55 denom(k) = sum(exp(cumsum(logtrans(k,:))));
56end
57for l = 1:h
58 for k = 1:n
59 capa(l) = capa(l) + prod(trans(k,1:l))/(1+denom(k));
60 stablecapa(l) = stablecapa(l) + exp(sum(log(trans(k,1:l)))-log(1+denom(k)));
61 end
62 F(l) = m(l)-stablecapa(l);
63end
64end
65end