5#ifndef LINE_SOLVERS_SOLVER_NODE_TABLES_H
6#define LINE_SOLVERS_SOLVER_NODE_TABLES_H
71 const std::vector<double>& CN,
72 const std::vector<double>& XN,
73 const std::string& method) {
74 const std::size_t M =
sn.nstations, R =
sn.nclasses;
83 std::vector<std::vector<bool>> srcmask(M, std::vector<bool>(R,
false));
84 for (std::size_t i = 0; i < M; ++i) {
86 for (std::size_t c = 0; c < R; ++c) srcmask[i][c] =
true;
87 for (std::size_t c = 0; c < R; ++c) {
108 for (std::size_t c = 0; c < CN.size(); ++c)
110 for (std::size_t c = 0; c < XN.size(); ++c)
128 std::vector<bool> hidden(
sn.nclasses,
false);
129 for (
const auto& kv :
sn.nodeparam) {
130 if (kv.first == 0 || kv.first >
sn.nodes.size() ||
131 sn.nodes[kv.first - 1].nodetype != line::qn::NodeType::Cache)
133 for (
const std::vector<std::size_t>& row : kv.second.retrieval_classes)
134 for (std::size_t rc : row)
135 if (rc >= 1 && rc <=
sn.nclasses) hidden[rc - 1] =
true;
156 const std::size_t I =
sn.nodes.size(), R =
sn.nclasses;
163 for (std::size_t ist = 0; ist <
sn.nstations; ++ist) {
164 const std::size_t ind =
sn.station_to_node[ist];
166 for (std::size_t c = 0; c < R; ++c) {
167 m.
QN(ind - 1, c) = r.
QN(ist, c);
168 m.
UN(ind - 1, c) = r.
UN(ist, c);
169 m.
RN(ind - 1, c) = r.
RN(ist, c);
170 m.
WN(ind - 1, c) = r.
WN(ist, c);
194 std::map<std::size_t, line::api::CacheActualProb<T>> cacheprob;
195 for (std::size_t ci = 0; ci < r.
cache.caches.size(); ++ci) {
202 cacheprob[cm.
node] = p;
212 bool hascache =
false;
213 for (std::size_t pass = 0; pass < I; ++pass) {
214 bool changed =
false;
215 for (std::size_t cind = 1; cind <= I; ++cind) {
216 if (refsn.
nodes[cind - 1].nodetype != line::qn::NodeType::Cache)
continue;
218 typename std::map<std::size_t, line::qn::CacheParam<T>>::const_iterator np =
220 if (np == refsn.
nodeparam.end())
continue;
221 for (std::size_t ind = 1; ind <= I; ++ind) {
222 if (ind == cind || refsn.
nodes[ind - 1].station != 0)
continue;
223 for (std::size_t s = 0; s < R; ++s) {
226 for (std::size_t c = 1; c <= R; ++c) {
227 if (!line::api::detail::sn_is_cache_class(np->second.hitclass, np->second.missclass, c))
229 const T p = refsn.
rtnodes((cind - 1) * R + (c - 1), (ind - 1) * R + s);
231 arv = T(arv + m.
TN(cind - 1, c - 1) * p);
239 m.
AN(ind - 1, s) = arv;
251 for (std::size_t ist = 0; ist < refsn.
nstations; ++ist) {
253 if (!ind || refsn.
nodes[ind - 1].nodetype == line::qn::NodeType::Source)
continue;
254 for (std::size_t rr = 0; rr < R; ++rr) {
256 for (std::size_t j = 0; j < I; ++j)
257 for (std::size_t s = 0; s < R; ++s) {
258 const T p = refsn.
rtnodes(j * R + s, (ind - 1) * R + rr);
259 if (p > zero) arv = T(arv + m.
TN(j, s) * p);
261 m.
AN(ind - 1, rr) = arv;
What a solver observed about the Cache nodes of a model.
A network plus its refreshed NetworkStruct.
std::map< std::size_t, CacheParam< T > > nodeparam
Cache parameters by 1-based NODE index; only Cache nodes have an entry.
std::vector< NodeDef > nodes
every node, in creation order
std::vector< std::size_t > station_to_node
(nstations) 1-based node index
Dense matrix and non-owning view.
Matrix< T > sn_get_node_tput_from_tput(const qn::NetworkStruct< T > &sn, const Matrix< T > &TN, const Matrix< T > &ANn, const std::map< std::size_t, CacheActualProb< T > > &cache_prob=std::map< std::size_t, CacheActualProb< T > >())
Port of sn_get_node_tput_from_tput.
Matrix< T > sn_get_node_arvr_from_tput(const qn::NetworkStruct< T > &sn, const Matrix< T > &TN, const Matrix< T > &AN)
Port of sn_get_node_arvr_from_tput.
Matrix< T > sn_get_residt_from_respt(const qn::NetworkStruct< T > &L, const Matrix< T > &RN)
Port of sn_get_residt_from_respt: the per-JOB residence time.
Matrix< T > filter_metric(const qn::NetworkStruct< T > &L, const Matrix< T > &metric, MetricKind kind, const std::vector< std::vector< bool > > *zero_mask)
Port of filterMetric: what @@NetworkSolver/getAvg does between the analyzer and the caller.
Matrix< T > sn_get_arvr_from_tput(const qn::NetworkStruct< T > &L, const Matrix< T > &TN)
Port of sn_get_arvr_from_tput: the arrival rate each station sees, from the throughputs and the class...
void sn_arvr_state_dependent_balance(const qn::NetworkStruct< T > &L, Matrix< T > &AN, const Matrix< T > &TN, Matrix< T > *WN)
std::vector< bool > node_table_hidden_classes(const line::qn::NetworkStruct< T > &sn)
The classes getAvgNodeTable omits: the auxiliary retrieval classes that Cache.setRetrievalSystem mint...
line::mva::AvgResult< T > avg_result_from_sim(const line::qn::NetworkStruct< T > &sn, const line::Matrix< double > &QN, const line::Matrix< double > &UN, const line::Matrix< double > &RN, const line::Matrix< double > &TN, const std::vector< double > &CN, const std::vector< double > &XN, const std::string &method)
The station AvgResult of a solver whose runner returns its own solution type, i.e.
NodeMetrics< T > node_metrics(const line::qn::NetworkStruct< T > &sn, const line::mva::AvgResult< T > &r)
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
Arrival rates at stations fed by a JSQ or SQ(d) dispatcher, from flow balance.
Ports of matlab/src/api/sn/sn_get_node_arvr_from_tput.m and sn_get_node_tput_from_tput....
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
The converged cache split, per ORIGINAL class of one Cache node.
std::vector< T > delayed_hit
static constexpr double FineTol
The metrics getAvg returns, after filtering.
std::shared_ptr< qn::NetworkStruct< T > > refreshed_struct
The struct whose cache self-switch carries the CONVERGED hit/miss split, filled by the cacheqn branch...
Matrix< T > RN
response time, per visit
Matrix< T > UN
utilization
Matrix< T > WN
residence time, per job
std::string method
the method asked for
std::string actualmethod
the algorithm that ran
Matrix< T > QN
queue length
std::vector< T > CN
system response time per class
std::vector< T > XN
system throughput per class
solvers::CacheMetrics< T > cache
What the cache branches observed, EMPTY on a model with no Cache node and on every solver that does n...
Matrix< T > AN
arrival rate
One Cache node's measured behaviour.
std::vector< T > hitprob
(K) TRUE hit fraction, EMPTY = not computed
std::vector< T > delayedprob
(K) delayed-hit fraction, EMPTY off a retrieval system
std::size_t node
1-based node index of the Cache
std::vector< T > missprob
(K)
The station table scattered to the NODE index space, plus the two flow columns the reference recomput...
line::Matrix< T > TN
(nnodes x nclasses)