5#ifndef LINE_SOLVERS_NC_SOLVER_NC_CACHEQN_H
6#define LINE_SOLVERS_NC_SOLVER_NC_CACHEQN_H
79 "solver_nc_cacheqn_analyzer: the integrated caching-queueing decomposition alternates "
80 "two tolerance-stopped solves and needs transcendental arithmetic");
88 for (
const auto& kv :
sn.nodeparam) {
91 for (
int c : ch.
itemcap) capsum += c;
92 if (
static_cast<long>(ch.
nitems) < capsum + 2)
94 "solver_nc_cacheqn_analyzer: NC requires the number of items to exceed the "
95 "cache capacity at least by 2; this cache holds " +
96 std::to_string(ch.
nitems) +
" items with total capacity " +
97 std::to_string(capsum));
100 const bool exact = (
opt.method ==
"exact");
109 for (
const auto& kv :
sn.nodeparam) {
114 "solver_nc_cacheqn_analyzer: NC does not support the exact solution of "
115 "this cache replacement policy -- only RR and FIFO are exchangeable, and "
116 "a recency-based policy (LRU, h-LRU, q-LRU, CLIMB) would silently receive "
117 "the exchangeable answer. Use the default (approximate) method or "
132 std::function<std::vector<T>(
const Matrix<T>&,
const std::vector<int>&,
134 missfun = [exact](
const Matrix<T>& gamma,
const std::vector<int>& m,
135 const std::vector<Matrix<T> >& lambda_cache,
138 const std::size_t u = lambda_cache.
size();
140 if (u == 0)
return missrate;
141 const std::size_t n = lambda_cache[0].
rows();
144 for (std::size_t v = 0; v < u; ++v) {
146 for (std::size_t k = 0; k < n && k < pij.
rows(); ++k)
147 acc = T(acc + lambda_cache[v](k, 0) * pij(k, 0));
152 for (std::size_t v = 0; v < u; ++v)
153 for (std::size_t k = 0; k < n; ++k) lam_un(v, k) = lambda_cache[v](k, 0);
155 for (std::size_t v = 0; v < mr.MU.size() && v < u; ++v) missrate[v] = mr.MU[v];
169 out.
sol.actualmethod = exact ?
"exact" :
"spm";
170 out.
sol.sol.method = out.
sol.actualmethod;
188 bool hasCache =
false;
190 if (nd.
nodetype == qn::NodeType::Cache) hasCache =
true;
Saddle-point approximation of the cache miss rates.
Exact per-item hit and miss probabilities of a multi-list cache.
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
Decomposition-aggregation driver for integrated cache-queueing models, a port of matlab/src/api/da/da...
The exception types the port throws.
Matrix< T > cache_prob_erec(const Matrix< T > &gamma, const std::vector< int > &m, const std::vector< int > &sigma, const std::vector< int > &k)
Per-item hit and miss probabilities under per-list storage cost caps, pi_ij = m_j gamma(i,...
CacheMissSpmResult< T > cache_miss_spm(const Matrix< T > &gamma, const std::vector< int > &m, const Matrix< T > &lambda)
Saddle-point approximation of the cache miss rates.
CacheqnResult< T > da_cacheqn(qn::NetworkStruct< T > sn, bool exact, const mva::MvaOptions &opt, const std::function< mva::MvaSolution< T >(const qn::NetworkStruct< T > &)> &netfun, const std::function< std::vector< T >(const Matrix< T > &, const std::vector< int > &, const std::vector< Matrix< T > > &, const qn::CacheParam< T > &)> &missfun=nullptr)
Decomposition-aggregation driver for integrated cache-queueing models, a port of matlab/src/api/da/da...
std::vector< Matrix< T > > da_cacheqn_itemprob(const CacheqnInfo< T > &info)
Per-item occupancy of every cache from the CONVERGED access factors.
@ FIFO
first in, first out
bool nc_is_cacheqn(const qn::NetworkStruct< T > &sn)
True when the model has a Cache node and is not the Source-Cache-Sink shape.
NcCacheqnSolution< T > solver_nc_cacheqn_analyzer(const qn::NetworkStruct< T > &sn, const NcSolverOptions &opt)
Port of solver_nc_cacheqn_analyzer.m.
NcSolution< T > nc_dispatch(const qn::NetworkStruct< T > &sn, const NcSolverOptions &opt)
Port of @@SolverNC/ncDispatch.m: the inner solve of the fork-join fixed point, which is the load-depe...
Port of solver_nc_analyzer.m, solver_ncld_analyzer.m and @@SolverNC/ncDispatch.m: one inner solve,...
Controls and result shape shared by the normalizing-constant analyzers.
A queueing network and its refreshed NetworkStruct.
Return value of cache_miss_spm, mirroring [M,MU,MI,pi0,lE].
Matrix< T > missprob
(ncaches x nclasses)
Matrix< T > hitprob
(ncaches x nclasses)
mva::MvaSolution< T > res
The options SolverMVA reads.
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
What the integrated analyzer returns: the metrics plus the converged split.
Matrix< T > hitprob
(ncaches x nclasses) converged hit probability
Matrix< T > missprob
(ncaches x nclasses)
qn::NetworkStruct< T > refreshed
The struct whose cache self-switch carries the CONVERGED split rather than the offered one,...
std::vector< Matrix< T > > itemprob
per cache, (n x h+1); EMPTY = not computed
The [Q,U,R,T,C,X,lG] of the reference, plus the algorithm that ran.
Controls, defaulting to SolverOptions('NC') in the reference.
std::vector< int > itemcap
lang::ReplacementStrategy replacestrat