1%{ @file retrieval_fpi.m
2 % @brief Fixed-point iteration (FPI) heuristic
for delayed-hit (list-based) caches
4 % @author LINE Development Team
8 % @brief Approximates miss, hit and delayed-hit metrics of a delayed-hit cache via FPI
11 % Implements the fixed-point heuristic of the paper (Sec.
"Fixed-Point
12 % Heuristic", eqs. theta/xi/pi/pi_0/phi_FPI)
for a list-based cache with delayed
13 % hits whose retrieval system has one IS station (s=0) and r PS stations
14 % (s=1,...,r). The heuristic truncates the regular perturbation expansion at 0th
15 % order (pi_{i,l}(m-1_j) ~ pi_{i,l}(m)) and solves the resulting nonlinear system
16 % by successive substitution. Iteration t -> t+1:
18 % D_i = 1 + lambda_i*eta_{0,i} + sum_{s=1}^r lambda_i*eta_{s,i}*(1 + sum_{k!=i} phi_{s,k})
19 % theta_{ij} = gamma_{ij} / D_i
20 % xi_j = m_j / sum_k theta_{kj} (1 - sum_l pi_{kl})
21 % pi_{ij} = theta_{ij} xi_j / (1 + sum_l theta_{il} xi_l)
22 % pi_{i0} = (1 - sum_j pi_{ij}) / D_i
23 % phi_{si} = lambda_i*eta_{s,i}*(1 + sum_{k!=i} phi_{s,k}) pi_{i0} (s=1..r)
24 % phi_{0i} = lambda_i*eta_{0,i} pi_{i0}
26 % where phi_{s,k}
is the delayed-hit probability of item k at PS station s. (The
27 % paper writes phi_{r,k} in eqs. theta_FPI/phi_FPI, but the exact recursion it
28 % approximates, eq. theta RS, uses the per-station index s; the two coincide
for
29 % a single PS station.) The solution satisfies the balance
30 % pi_{i0} + sum_s phi_{si} + sum_j pi_{ij} = 1. Output orientation matches
31 % retrieval_metrics
for direct comparison.
35 % [pmiss, phit, pdh] = retrieval_fpi(m, lambda, eta, gamma)
36 % [pmiss, phit, pdh] = retrieval_fpi(m, lambda, eta, gamma, max_iter, tol)
41 % <tr><th>Name<th>Description
42 % <tr><td>m<td>Cache list capacities (1 x h)
43 % <tr><td>lambda<td>Per-item arrival rates (1 x n)
44 % <tr><td>eta<td>Fetching demands eta(i,s+1)=eta_{s,i} (column 1 = IS station s=0, columns 2..r+1 = PS stations), (n x (r+1)). A PS column models any symmetric/identical-rate single-server discipline (PS, SIRO, FCFS, LCFS-PR), all treated alike via the mean-field sharing slowdown.
45 % <tr><td>gamma<td>Access factors gamma(i,j)=gamma_{i,j}, (n x h)
46 % <tr><td>max_iter<td>Maximum number of iterations (
default 1e5)
47 % <tr><td>tol<td>Convergence tolerance on relative change (
default 1e-6)
52 % <tr><th>Name<th>Description
53 % <tr><td>pmiss<td>Miss ratios pi_{i,0}, (1 x n)
54 % <tr><td>phit<td>Hit ratios pi_{i,j}, (h x n)
55 % <tr><td>pdh<td>Delayed-hit probabilities phi_{s,i}
for s=0,...,r, ((r+1) x n)
58function [pmiss,phit,pdh]=retrieval_fpi(m,lambda,eta,gamma,max_iter,tol)
59if nargin < 5 || isempty(max_iter), max_iter = 1000; end
60if nargin < 6 || isempty(tol), tol = 1e-6; end
66lambda = lambda(:); % n x 1
67eta0 = eta(:,1); % n x 1 (IS station s=0)
68etaPS = eta(:,2:end); % n x r (PS stations s=1..r)
70% initial guess (paper Sec. Fixed-Point Heuristic)
71phi = ones(r+1,n) / ((h+1)*(r+2)); % phi(s+1,i), s=0..r
72pij = ones(h,n) / (h+1); % pij(j,i)
73pi0 = ones(1,n) / ((h+1)*(r+2)); % pi0(i)
76 % per-station PS-sharing factor F(s,i) = 1 + sum_{k!=i} phi_{s,k}
77 % (the paper writes phi_{r,k}, but the exact recursion eq. theta RS uses the
78 % station index s; for a single PS station the two coincide.)
82 F(s,:) = 1 + (sum(phis) - phis);
85 D = 1 + lambda.*eta0; % n x 1
87 D = D + lambda .* etaPS(:,s) .* F(s,:).';
90 theta = gamma ./ D; % n x h
92 oneminus = (1 - sum(pij,1)).'; % n x 1 (uses pij^[t])
95 xi(j) = m(j) / sum(theta(:,j).*oneminus);
98 txi = theta .* xi; % n x h
99 pij_new = (txi ./ (1 + sum(txi,2))).'; % h x n
101 pi0_new = (1 - sum(pij_new,1)) ./ D.'; % 1 x n
103 phi_new = zeros(r+1,n);
104 phi_new(1,:) = (lambda.*eta0).
' .* pi0_new; % phi_{0,i}
106 phi_new(s+1,:) = (lambda.*etaPS(:,s)).' .* F(s,:) .* pi0_new; % phi_{s,i}
109 % convergence: max relative change in miss, hit, delayed-hit ratios
110 delta = max([reldiff(pi0_new,pi0), reldiff(pij_new,pij), reldiff(phi_new,phi)]);
117 line_warning(mfilename,
'FPI diverged (non-finite iterate) at iteration %d.\n', t);
124 line_warning(mfilename,
'FPI did not converge within %d iterations (last rel. change %.2e).\n', max_iter, delta);
133function d = reldiff(a,b)
134denom = max(abs(b(:)));
138d = max(abs(a(:)-b(:))) / denom;