1%{ @file cache_ttl_lrua.m
2 % @brief Computes steady-state probabilities
for TTL-LRU cache with arrivals
4 % @author LINE Development Team
8 % @brief Computes steady-state probabilities
for TTL-LRU cache with arrivals
11 % This function computes the steady-state probability distribution
for a
12 % TTL-LRU cache system with multiple users, items, and cache levels.
16 % prob = cache_ttl_lrua(lambda, R, m)
17 % prob = cache_ttl_lrua(lambda, R, m, seed)
22 % <tr><th>Name<th>Description
23 % <tr><td>lambda<td>Arrival rates per user per item per list
24 % <tr><td>R<td>Routing probability structure
25 % <tr><td>m<td>Cache capacity vector
26 % <tr><td>seed<td>(Optional) Random seed
for initialization
31 % <tr><th>Name<th>Description
32 % <tr><td>prob<td>Steady-state probability distribution
35function prob=cache_ttl_lrua(lambda, R, m, seed)
41u=size(lambda,1); % number of users
42n=size(lambda,2); % number of items
43h=size(lambda,3)-1; % number of lists
47% random seed to generate the initial value
for x
48range_left = 0; range_right = 10;
49x = (range_right-range_left).*rand(1,h) + range_left;
50options = optimoptions(
'fsolve',
'MaxIter',1e5,
'MaxFunEvals',1e6,
'Display',
'off');
51[listtime,~,~,~] = fsolve(fun,x,options);
52[~,ssprob] = ttl_tree_time(listtime);
55 function [F,ssprob,capadiff] = ttl_tree_time(x)
56 steadystateprob = zeros(n,h+1);
57 randprob = zeros(n,h+1);
58 avgtime = zeros(n,h+1);
61 rpdenominator = zeros(1,n);
62 % the probability of each item at each list
63 for i = 1:n %
for all items
64 transmatrix = zeros(h+1, h+1);
66 leafnode = find(R{1,i}(j,:));
69 transmatrix(j,k) = R{1,i}(j,k);
71 transmatrix(j,k) = (1-exp(-lambda(1,i,j)*x(j-1)))*R{1,i}(j,k);
74 transmatrix(k,j) = exp(-lambda(1,i,k)*x(k-1));
78 missconnection = find(all(transmatrix==0));
79 dtchain = setdiff(1:h+1, missconnection);
80 transmatrix(missconnection,:)=[];
81 transmatrix(:,missconnection)=[]; % remove the unused
nodes in the transfer matrix
82 dtmcprob = dtmc_solve(transmatrix); % solution of dtmc, i.e., prob of item i in list j, 1*h
83 for a = 1:numel(dtchain)
84 steadystateprob(i,dtchain(a)) = dtmcprob(a);
86 avgtime(i,dtchain(a)) = (1-exp(-lambda(1,i,dtchain(a))*x(dtchain(a)-1)))/lambda(1,i,dtchain(a));% average time of item i spent in l , l>=1
88 avgtime(i,dtchain(a)) = 1/lambda(1,i,dtchain(a));
90 rpdenominator(i) = rpdenominator(i)+steadystateprob(i,dtchain(a))*avgtime(i,dtchain(a));% denominator
for the probability of item i at node j at a random time
92 for a = 1:numel(dtchain)
93 randprob(i,dtchain(a)) = steadystateprob(i,dtchain(a))*avgtime(i,dtchain(a))/rpdenominator(i); % random time , prob of item i in list j
99 capa(l) = sum(randprob(:,l+1));
100 cdiff(l) = m(l)-capa(l);