5#ifndef LINE_SOLVERS_ENV_ENV_DISPATCH_H
6#define LINE_SOLVERS_ENV_ENV_DISPATCH_H
115namespace dispatch_detail {
121 for (std::size_t i = 0; i < A.
rows(); ++i)
146EnvStatevecOptions<T> env_statevec_options(
const EnvOptions& o) {
147 EnvStatevecOptions<T> s;
148 s.iter_max = o.iter_max;
149 s.iter_tol = o.iter_tol;
150 s.stage_solver = o.stage_solver;
151 s.sojourn = o.sojourn;
152 s.timespan_end = o.timespan_end;
157 if (o.stage_cutoff > 0) s.mam_cutoff =
static_cast<std::size_t
>(o.stage_cutoff);
163void env_take_statevec(EnvAnalyzerSolution<T>& out) {
164 out.method =
"statevec";
165 out.QN = out.statevec.QN;
166 out.UN = out.statevec.UN;
167 out.TN = out.statevec.TN;
168 out.iterations = out.statevec.iterations;
169 out.converged = out.statevec.converged;
181void env_take_meanfield(EnvAnalyzerSolution<T>& out,
const std::string& asked =
"meanfield") {
182 out.method = asked.empty() ?
"meanfield" : asked;
183 out.QN = env_widen<T>(out.meanfield.avg.QN);
184 out.UN = env_widen<T>(out.meanfield.avg.UN);
185 out.TN = env_widen<T>(out.meanfield.avg.TN);
186 out.iterations = out.meanfield.avg.iterations;
187 out.converged = out.meanfield.avg.converged;
192void env_take_limit(EnvAnalyzerSolution<T>& out) {
193 out.method = out.limit.method;
194 out.QN = env_widen<T>(out.limit.QN);
195 out.UN = env_widen<T>(out.limit.UN);
196 out.TN = env_widen<T>(out.limit.TN);
198 out.converged =
true;
202inline bool env_is_statevec(
const std::string& m) {
return m ==
"statevec" || m ==
"blend"; }
205inline bool env_is_limit(
const std::string& m) {
return m ==
"avg" || m ==
"dec"; }
223 return {
"default",
"meanfield",
"smp",
"statedep",
"statevec",
"blend",
"avg",
"dec"};
229 if (std::find(valid.begin(), valid.end(), method) != valid.end())
return;
230 throw UnsupportedError(
"SolverENV: the '" + method +
"' method is unsupported by this solver");
244 if (dispatch_detail::env_is_limit(o.
method)) {
246 dispatch_detail::env_take_limit(out);
249 if (dispatch_detail::env_is_statevec(o.
method)) {
251 dispatch_detail::env_take_statevec(out);
255 dispatch_detail::env_take_meanfield(out, o.
method);
281 if (dispatch_detail::env_is_limit(o.
method)) {
286 dispatch_detail::env_take_limit(out);
289 if (dispatch_detail::env_is_statevec(o.
method)) {
294 dispatch_detail::env_take_statevec(out);
299 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.
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.
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.
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....
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).
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.
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.
std::string method
The inter-stage coupling: meanfield is the reference's default.
What the state-vector coupling reports.