LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_fld_cacheqn_tran.m
1function [tcache, hitprob_t, missprob_t, caches, arate, xocc] = solver_fld_cacheqn_tran(sn, options, x0cell)
2% SOLVER_FLD_CACHEQN_TRAN Transient refined-mean-field cache trajectory.
3%
4% Converges the per-class cache arrival rates with the same decomposition-
5% aggregation alternation as the steady solver (da_cacheqn), then integrates
6% the mean-field drift over OPTIONS.TIMESPAN to obtain the time-resolved
7% per-class hit/miss probabilities of each cache. This is the transient
8% counterpart of solver_fld_cacheqn_analyzer: the steady solver drives the
9% drift to its fixed point, whereas here the same drift is integrated over
10% the finite window from the supplied (or default) initial occupancy.
11%
12% SN: NetworkStruct with at least one Cache node.
13% OPTIONS: solver options; OPTIONS.TIMESPAN = [t0,t1] sets the window.
14% X0CELL: optional cell(1,ncaches); X0CELL{c} seeds cache c occupancy
15% (flat DDPP state vector, n_items*(h+1)); [] uses the default
16% all-items-outside-plus-first-m-in-list initial state.
17%
18% Returns the time grid TCACHE, the per-cache per-class hit/miss probability
19% trajectories HITPROB_T/MISSPROB_T (ncaches x nclasses x nt), and the cache
20% node indices CACHES (rows ordered as find(sn.nodetype==Cache)).
21%
22% Copyright (c) 2012-2026, Imperial College London
23% All rights reserved.
24
25K = sn.nclasses;
26if nargin < 3
27 x0cell = {};
28end
29tspan = options.timespan;
30if isinf(tspan(1))
31 tspan(1) = 0;
32end
33
34% Converge the cache arrival rates and capture the per-cache isolated inputs.
35[~, ~, ~, ~, ~, cacheinfo] = da_cacheqn(sn, @miss_isolated, @netsolve, options);
36caches = cacheinfo.node;
37ncaches = numel(caches);
38
39tcache = [];
40hitprob_t = [];
41missprob_t = [];
42arate = zeros(ncaches, K);
43xocc = cell(1, ncaches);
44for cIdx = 1:ncaches
45 gamma = cacheinfo.gamma{cIdx};
46 m = cacheinfo.m{cIdx};
47 lam = cacheinfo.lambda_cache{cIdx};
48 strat = cacheinfo.strat{cIdx};
49 if cIdx <= numel(x0cell)
50 x0 = x0cell{cIdx};
51 else
52 x0 = [];
53 end
54
55 % Isolated-cache transient occupancy. Only RANDOM(m) has a drift-based
56 % transient (RMF); other strategies expose no transient here.
57 if strat == ReplacementStrategy.RR
58 [~, ~, ~, ~, tc, ~, MU_t, xtraj] = cache_miss_rmf(gamma, m, lam, tspan, x0);
59 xocc{cIdx} = xtraj;
60 else
61 line_error(mfilename, sprintf(['Transient cache analysis is only ' ...
62 'available for RANDOM(m) (RR) replacement via the refined mean ' ...
63 'field; cache %d uses a strategy without a drift-based transient.'], cIdx));
64 end
65
66 if isempty(tcache)
67 nt = numel(tc);
68 tcache = tc(:)';
69 hitprob_t = zeros(ncaches, K, nt);
70 missprob_t = zeros(ncaches, K, nt);
71 end
72
73 % Per-user (per-class) arrival rate = sum over items of its isolated rate.
74 u = size(lam, 1);
75 for v = 1:u
76 rowrate = sum(lam(v, :, 1));
77 arate(cIdx, v) = rowrate;
78 if rowrate > 0
79 mp = MU_t(v, :) ./ rowrate;
80 mp = max(0, min(1, mp));
81 missprob_t(cIdx, v, :) = reshape(mp, 1, 1, []);
82 hitprob_t(cIdx, v, :) = reshape(1 - mp, 1, 1, []);
83 end
84 end
85end
86
87 function missrate = miss_isolated(gamma, m, lambda_cache, ch)
88 if ch.replacestrat == ReplacementStrategy.RR
89 [~, missrate] = cache_miss_rmf(gamma, m, lambda_cache);
90 else
91 [~, missrate] = cache_miss_fpi(gamma, m, lambda_cache);
92 end
93 end
94
95 function res = netsolve(snit)
96 res = struct();
97 fluid_options = options;
98 fluid_options.method = 'matrix';
99 fluid_options.init_sol = solver_fluid_initsol(snit, fluid_options);
100 [res.QN, res.UN, res.RN, res.TN, res.xvec_iter, res.QNt, res.UNt, res.TNt, ~, res.t] = solver_fluid_matrix(snit, fluid_options);
101 res.XN = zeros(1, K);
102 for k = 1:K
103 if snit.refstat(k) > 0
104 res.XN(k) = res.TN(snit.refstat(k), k);
105 end
106 end
107 end
108end
Definition Station.m:245