LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_rmf_transient.m
1%% Cache RMF Transient Analysis
2% Demonstrates refined mean field (RMF) transient and steady-state
3% analysis of a multi-list cache with RANDOM(m) replacement.
4%
5% Uses CacheRMF directly to compute:
6% - Steady-state hit/miss probabilities with 1/N correction
7% - Transient evolution of hit rates via coupled ODE system
8
9clear;
10
11% Cache parameters
12n = 10; % number of items
13m = [3, 2]; % list capacities (2-list cache)
14alpha = 0.8; % Zipf exponent
15
16% Zipf popularity distribution
17p = (1:n).^(-alpha);
18p = p / sum(p);
19
20fprintf('Cache parameters: n=%d, m=[%s], Zipf(%.1f)\n', n, strjoin(arrayfun(@num2str, m, 'UniformOutput', false), ', '), alpha);
21
22% Build DDPP model
23model = CacheRMF(p, m);
24
25% Steady-state analysis with 1/N correction
26[pi, V, VW] = model.meanFieldExpansionSteadyState(1);
27pi_refined = pi(:)' + V(:)' / n;
28
29fprintf('\nSteady-state results (refined mean field):\n');
30total_hit = 0;
31for k = 1:length(m)
32 hr = model.hitRate(pi_refined, k);
33 total_hit = total_hit + hr;
34 fprintf(' Hit rate (list %d): %.6f\n', k, hr);
35end
36miss_rate = model.hitRate(pi_refined, 0);
37fprintf(' Miss rate: %.6f\n', miss_rate);
38fprintf(' Total hit prob: %.6f\n', total_hit);
39fprintf(' Total miss prob: %.6f\n', miss_rate);
40
41% Transient analysis
42[T, X, Vt, W] = model.meanFieldExpansionTransient(50, 200, 1);
43
44fprintf('\nTransient hit rates (refined, N=%d):\n', n);
45time_indices = [1, 21, 51, 101, 200]; % t=0, ~5, ~12.5, ~25, 50
46for idx = time_indices
47 xt = X(idx, :) + Vt(idx, :) / n;
48 hr = 0;
49 for k = 1:length(m)
50 hr = hr + model.hitRate(xt, k);
51 end
52 fprintf(' t=%7.3f: hit_rate=%.6f\n', T(idx), hr);
53end