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);
42gamma = cache_gamma_lp(lambda,Rcost);
46 line_debug(
'Using exact cache method');
47 switch sn.nodeparam{sn.nodetype == NodeType.Cache}.replacestrat
48 case {ReplacementStrategy.RR, ReplacementStrategy.FIFO}
49 line_debug(
'Replacement strategy: RR/FIFO, calling cache_mva');
50 [~,~,pij] = cache_mva(gamma, m);
51 pij = [abs(1-sum(pij,2)),pij];
53 line_error(mfilename,
'MVA does not support exact solution of the specified cache replacement policy.')
56 line_debug('Default method: using approximate cache method\n');
57 line_debug('Using approximate 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_prob_fpi');
61 pij = cache_prob_fpi(gamma,m); % FPI method
62 case ReplacementStrategy.LRU
63 line_debug(
'Replacement strategy: LRU, calling cache_ttl_lrua');
64 %pij = cache_ttl_lrum(lambda, m); % linear topology only
65 pij = cache_ttl_lrua(lambda, Rcost, m); % allows trees and access costs
66 %
case ReplacementStrategy.HLRU
67 %
this is integrated but the cache_ttl_hlru script
is not
68 % working correctly at present
69 %pij = cache_ttl_hlru(lambda, m); % without considering different graph of different items linear
71 line_error(mfilename,
'MVA does not support approximate solution of the specified cache replacement policy.')
76 missRate(v) = lambda(v,:,1)*pij(:,1);
80 if length(ch.hitclass)>=r && ch.missclass(r)>0 && ch.hitclass(r)>0
81 XN(ch.missclass(r)) = XN(ch.missclass(r)) + missRate(r);
82 XN(ch.hitclass(r)) = XN(ch.hitclass(r)) + (sourceRate(r) - missRate(r));
86% Set the actual method used
87if strcmp(options.method, 'exact')
90 switch sn.nodeparam{sn.nodetype == NodeType.Cache}.replacestrat
91 case {ReplacementStrategy.RR, ReplacementStrategy.FIFO}
93 case ReplacementStrategy.LRU
96 method = options.method;