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.
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.
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.
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)).
22% Copyright (c) 2012-2026, Imperial College London
29tspan = options.timespan;
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);
42arate = zeros(ncaches, K);
43xocc = cell(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)
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);
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));
69 hitprob_t = zeros(ncaches, K, nt);
70 missprob_t = zeros(ncaches, K, nt);
73 % Per-user (per-class) arrival rate = sum over items of its isolated rate.
76 rowrate = sum(lam(v, :, 1));
77 arate(cIdx, v) = rowrate;
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, []);
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);
91 [~, missrate] = cache_miss_fpi(gamma, m, lambda_cache);
95 function res = netsolve(snit)
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);
103 if snit.refstat(k) > 0
104 res.XN(k) = res.TN(snit.refstat(k), k);