5#ifndef LINE_SOLVERS_ENV_ENV_DISPATCH_H
6#define LINE_SOLVERS_ENV_ENV_DISPATCH_H
132namespace dispatch_detail {
138 for (std::size_t i = 0; i < A.
rows(); ++i)
154 for (std::size_t i = 0; i < c.
caches.size(); ++i) {
162 for (std::size_t k = 0; k < m.
hitprob.size(); ++k)
164 for (std::size_t k = 0; k < m.
missprob.size(); ++k)
166 for (std::size_t k = 0; k < m.
delayedprob.size(); ++k)
168 for (std::size_t k = 0; k < m.
latency.size(); ++k)
170 for (std::size_t k = 0; k < m.
listcost.size(); ++k)
199EnvStatevecOptions<T> env_statevec_options(
const EnvOptions& o) {
200 EnvStatevecOptions<T> s;
201 s.iter_max = o.iter_max;
202 s.iter_tol = o.iter_tol;
203 s.stage_solver = o.stage_solver;
204 s.sojourn = o.sojourn;
205 s.timespan_end = o.timespan_end;
210 if (o.stage_cutoff > 0) s.mam_cutoff =
static_cast<std::size_t
>(o.stage_cutoff);
216void env_take_statevec(EnvAnalyzerSolution<T>& out) {
217 out.method =
"statevec";
218 out.QN = out.statevec.QN;
219 out.UN = out.statevec.UN;
220 out.TN = out.statevec.TN;
221 out.iterations = out.statevec.iterations;
222 out.converged = out.statevec.converged;
223 out.cache = out.statevec.cache;
235void env_take_meanfield(EnvAnalyzerSolution<T>& out,
const std::string& asked =
"meanfield") {
236 out.method = asked.
empty() ?
"meanfield" : asked;
237 out.QN = env_widen<T>(out.meanfield.avg.QN);
238 out.UN = env_widen<T>(out.meanfield.avg.UN);
239 out.TN = env_widen<T>(out.meanfield.avg.TN);
240 out.iterations = out.meanfield.avg.iterations;
241 out.converged = out.meanfield.avg.converged;
242 out.cache = out.meanfield.cache;
247void env_take_limit(EnvAnalyzerSolution<T>& out) {
248 out.method = out.limit.method;
249 out.QN = env_widen<T>(out.limit.QN);
250 out.UN = env_widen<T>(out.limit.UN);
251 out.TN = env_widen<T>(out.limit.TN);
253 out.converged =
true;
254 out.cache = env_widen_cache<T>(out.limit.cache);
258inline bool env_is_statevec(
const std::string& m) {
return m ==
"statevec"; }
264inline bool env_is_limit(
const std::string& m) {
265 return m ==
"avg" || m ==
"dec" || m ==
"occupation";
297 return ::line::method_registry::methods(
"ENV");
303 if (std::find(valid.begin(), valid.end(), method) != valid.end())
return;
318 if (dispatch_detail::env_is_limit(o.
method)) {
320 dispatch_detail::env_take_limit(out);
323 if (dispatch_detail::env_is_statevec(o.
method)) {
325 dispatch_detail::env_take_statevec(out);
329 dispatch_detail::env_take_meanfield(out, o.
method);
359 if (!dispatch_detail::env_is_limit(o.
method))
361 "SolverENV: the '" + o.
method +
362 "' coupling cannot run an injected stage solver; it carries a per-stage object across "
363 "an environment switch that only its own backend produces (the mean-field coupling "
364 "the RMF transient and the marginal means, the state-vector one a generator and the "
365 "joint law over it). The closed-form limits 'avg' and 'dec' take one");
368 out.limit = s.
solve();
369 dispatch_detail::env_take_limit(out);
395 if (dispatch_detail::env_is_limit(o.
method)) {
400 dispatch_detail::env_take_limit(out);
403 if (dispatch_detail::env_is_statevec(o.
method)) {
408 dispatch_detail::env_take_statevec(out);
413 dispatch_detail::env_take_meanfield(out, o.
method);
UnsupportedError(const std::string &what)
The state-vector environment solver.
EnvStatevecSolution< T > solve()
A random environment: a port of matlab/src/lang/Environment.m, restricted to what SolverENV reads out...
Dense matrix and non-owning view.
The method names of each solver, in listing order.
EnvStatevecSolution< T > solver_env_statevec(Environment< T > &e, const EnvStatevecOptions< T > &o)
Solve in one call, for a caller with no use for the solver object.
EnvLimitSolution solver_env_limit(Environment< T > &e, const EnvOptions &o)
solveEnvLimit on the original stages.
std::function< EnvStageAvg< T >(const qn::NetworkStruct< T > &)> EnvStageAvgFn
The stage solver, as a callable: the C++ spelling of the MATLAB function handle SolverENV(renv,...
void env_check_method(const std::string &method)
Port of runAnalyzerChecks' method gate: an unlisted method is refused.
EnvMeanfieldSolution< T > solver_env_meanfield(Environment< T > &e, const EnvOptions &o)
The mean-field solve on the original stages, with no compression.
EnvCompression< T > env_compress(const Environment< T > &e0, const EnvCompressOptions &opt)
Port of applyCompression: pick a partition, decompose, and build the macro-state environment.
std::vector< std::string > env_list_valid_methods()
Port of SolverENV.listValidMethods.
void env_apply_macro_probabilities(Environment< T > &e, const EnvCompression< T > &c)
probEnv = pMacro and probOrig = newEmbweight, the two quantities applyCompression overwrites on the e...
EnvAnalyzerSolution< T > solver_env(Environment< T > &e, const EnvOptions &o)
SolverENV.init's analyzer selection: solve the environment with the coupling o.method names.
Conservation laws of a layered queueing network, enumerated from its structure.
Number-type abstraction for the templated API port.
SolverENV: a queueing network in a random environment.
The two CLOSED-FORM environment limits: SolverENV.solveEnvLimit, reached by options....
SolverENV, the default mean-field path: ENVIRONMENT COMPRESSION.
SolverENV, method = "statevec": a port of matlab/src/solvers/ENV/solver_env_statevec_analyzer....
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
What the ENV entry reports: the environment-blended metrics, and the whole result of whichever coupli...
EnvMeanfieldSolution< T > meanfield
Populated on the mean-field path.
std::string method
What ran: meanfield, statevec, or the limit avg / dec.
EnvLimitSolution limit
Populated on the closed-form limit path (avg, dec, occupation); limit.occupation / limit....
EnvStatevecSolution< T > statevec
Populated on the state-vector path.
bool converged
True on the limit path: a closed form has converged by construction.
Matrix< T > QN
Environment-averaged metrics, (nstations x nclasses).
EnvCompression< T > compression
The aggregation, when there was one; its eps against epsMAX says whether it was meaningful.
bool compressed
True when the environment was aggregated before the coupling ran.
solvers::CacheMetrics< T > cache
The environment-blended cache surface, whichever coupling produced it.
int iterations
ZERO ON THE LIMIT PATH, and that is the answer rather than a gap: a limit reads the environment once ...
The knobs applyCompression reads out of options.config.
Everything applyCompression computes, plus the compressed environment.
What a limit solve reports.
A mean-field solve, with the compression that produced it.
std::string method
The inter-stage coupling: meanfield is the reference's default.
What the state-vector coupling reports.
Every Cache node of the model, in node order; empty on a model with none.
std::vector< CacheNodeMetrics< T > > caches
One Cache node's measured behaviour.
std::vector< double > itemcap
(h) capacity of each list
std::vector< double > itemsize
(n) storage cost per item, EMPTY without setItemSizes
std::vector< T > hitprob
(K) TRUE hit fraction, EMPTY = not computed
std::vector< T > delayedprob
(K) delayed-hit fraction, EMPTY off a retrieval system
Matrix< T > hitproblist
(K x h) per-list hit fraction, EMPTY = not computed
std::size_t node
1-based node index of the Cache
std::vector< T > latency
(K) expected latency per read request (hits wait 0), EMPTY = not computed
std::vector< T > missprob
(K)
std::vector< T > listcost
(h) mean storage cost held by each list
Matrix< T > itemprob
(n x h+1), column 0 = miss; EMPTY = not computed
std::string name
The Cache node's NAME, which is what a cross-language payload must key on.