1function [QN,UN,RN,TN,CN,XN,lG,pij,runtime,method] = solver_nc_cache_analyzer(sn, options)
2% [Q,U,R,T,C,X,LG,PIJ,RUNTIME] = SOLVER_NC_CACHE_ANALYZER(QN, OPTIONS)
4% Copyright (c) 2012-2026, Imperial College London
11XN = zeros(1,sn.nclasses);
15line_debug(
'NC 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};
28 line_error(mfilename,
'NC requires the number of items to exceed the cache capacity at least by 2.');
38 if ~isnan(ch.pread{v})
39 lambda(v,k,l) = sourceRate(v) * ch.pread{v}(k);
46gamma = cache_gamma_lp(lambda,R);
49 line_debug(
'Using exact method, calling cache_prob_erec');
50 [pij] = cache_prob_erec(gamma, m);
51 missRate = zeros(1,u);
53 missRate(v) = lambda(v,:,1)*pij(:,1);
57 line_debug(
'Using sampling method, calling cache_miss_is');
58 [~,missRate,~,~,lE] = cache_miss_is(gamma, m, lambda, options.samples);
59 pij = cache_prob_is(gamma, m, options.samples);
62 line_debug(
'Default method: using SPM approximation method\n');
63 line_debug(
'Using SPM approximation method, calling cache_miss_spm');
64 [~,missRate,~,~,lE] = cache_miss_spm(gamma, m, lambda);
65 pij = cache_prob_spm(gamma, m, lE);
70 if length(ch.hitclass)>=r && ch.missclass(r)>0 && ch.hitclass(r)>0
71 XN(ch.missclass(r)) = XN(ch.missclass(r)) + missRate(r);
72 XN(ch.hitclass(r)) = XN(ch.hitclass(r)) + (sourceRate(r) - missRate(r));