LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_gamma_lp.m
1%{ @file cache_gamma_lp.m
2 % @brief Computes gamma parameters for cache models using linear programming
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes gamma parameters for cache models
9 %
10 % @details
11 % This function computes item popularity probabilities at each cache level
12 % using a linear programming approach based on arrival rates and routing
13 % probabilities.
14 %
15 % @par Syntax:
16 % @code
17 % [gamma, u, n, h] = cache_gamma_lp(lambda, R)
18 % @endcode
19 %
20 % @par Parameters:
21 % <table>
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 % </table>
26 %
27 % @par Returns:
28 % <table>
29 % <tr><th>Name<th>Description
30 % <tr><td>gamma<td>Item popularity probabilities at each level
31 % <tr><td>u<td>Number of users
32 % <tr><td>n<td>Number of items
33 % <tr><td>h<td>Number of cache levels
34 % </table>
35%}
36function [gamma,u,n,h]=cache_gamma_lp(lambda,R)
37u=size(lambda,1); % number of users
38n=size(lambda,2); % number of items
39h=size(lambda,3)-1; % number of lists
40
41gamma=zeros(n,h);
42for i = 1:n % for all items
43 for j = 1:h % for all levels
44 % compute gamma(i,j)
45 Rvi = 0*R{1,i};
46 for v=1:u
47 Rvi = Rvi + R{v,i};
48 end
49 Pij =[1+j];
50 pr_j = par(Rvi, 1+j);
51 while ~isempty(pr_j)
52 Pij =[pr_j, Pij];
53 pr_j = par(Rvi, pr_j);
54 end
55 if isempty(Pij) % debug
56 %if length(Pij) < 2
57 gamma(i,j)=0;
58 else
59 gamma(i,j)=1;
60 for li = 2:length(Pij) % for all levels up to the current one
61 y = 0;
62 l_1 = Pij(li-1);
63 l = Pij(li);
64 for v = 1:u % for all streams
65 for t=1:l_1
66 y=y + lambda(v, i, t) * R{v,i}(t, l);
67 end
68 end
69 gamma(i,j)=gamma(i,j)*y;
70 end
71 end
72 end
73end
74
75end
76
77function parent = par(R, j)
78% finds the parent of j according to the access probabilities in R
79 parent = find(R(1:(j-1),j));
80 if length(parent) > 1
81 line_error(mfilename,'A cache has a list with more than one parent, but the structure must be a tree.');
82 end
83end