1function [QN,UN,RN,TN,CN,XN,lGN,runtime,iter,method] = solver_mva_cache_analyzer(sn, options)
2% [Q,U,R,T,C,X,LG,RUNTIME,ITER] = SOLVER_MVA_CACHE_ANALYZER(QN, OPTIONS)
4% Copyright (c) 2012-2026, Imperial College London
11XN = zeros(1,sn.nclasses);
15line_debug(
'MVA cache analyzer starting: method=%s, nclasses=%d', options.method, sn.nclasses);
17source_ist = sn.nodeToStation(sn.nodetype == NodeType.Source);
18sourceRate = sn.rates(source_ist,:);
19sourceRate(isnan(sourceRate)) = 0;
20TN(source_ist,:) = sourceRate;
22ch = sn.nodeparam{sn.nodetype == NodeType.Cache};
33 if ~isnan(ch.pread{v})
34 lambda(v,k,l) = sourceRate(v) * ch.pread{v}(k);
42 % Default linear cache routing: items flow from list l to list l+1
46 Rmat = diag(ones(1, h), 1);
53gamma = cache_gamma_lp(lambda,Rcost);
57 line_debug(
'Using exact cache method');
58 switch sn.nodeparam{sn.nodetype == NodeType.Cache}.replacestrat
59 case {ReplacementStrategy.RR, ReplacementStrategy.FIFO}
60 line_debug(
'Replacement strategy: RR/FIFO, calling cache_mva');
61 [~,~,pij] = cache_mva(gamma, m);
62 pij = [abs(1-sum(pij,2)),pij];
64 line_error(mfilename,
'MVA does not support exact solution of the specified cache replacement policy.')
67 line_debug('Default method: using approximate cache method\n');
68 line_debug('Using approximate cache method');
69 switch sn.nodeparam{sn.nodetype == NodeType.Cache}.replacestrat
70 case {ReplacementStrategy.RR, ReplacementStrategy.FIFO}
71 line_debug(
'Replacement strategy: RR/FIFO, calling cache_prob_fpi');
72 pij = cache_prob_fpi(gamma,m); % FPI method
73 case ReplacementStrategy.LRU
74 line_debug(
'Replacement strategy: LRU, calling cache_ttl_lrua');
75 %pij = cache_ttl_lrum(lambda, m); % linear topology only
76 pij = cache_ttl_lrua(lambda, Rcost, m); % allows trees and access costs
77 %
case ReplacementStrategy.HLRU
78 %
this is integrated but the cache_ttl_hlru script
is not
79 % working correctly at present
80 %pij = cache_ttl_hlru(lambda, m); % without considering different graph of different items linear
82 line_error(mfilename,
'MVA does not support approximate solution of the specified cache replacement policy.')
87 missRate(v) = lambda(v,:,1)*pij(:,1);
91 if length(ch.hitclass)>=r && ch.missclass(r)>0 && ch.hitclass(r)>0
92 XN(ch.missclass(r)) = XN(ch.missclass(r)) + missRate(r);
93 XN(ch.hitclass(r)) = XN(ch.hitclass(r)) + (sourceRate(r) - missRate(r));
97% Set the actual method used
98if strcmp(options.method, 'exact')
101 switch sn.nodeparam{sn.nodetype == NodeType.Cache}.replacestrat
102 case {ReplacementStrategy.RR, ReplacementStrategy.FIFO}
104 case ReplacementStrategy.LRU
107 method = options.method;