LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
map_env_stages.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_SOLVERS_MAP_ENV_STAGES_H
6#define LINE_SOLVERS_MAP_ENV_STAGES_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * The stage solvers `map_env_approx` injects, one per runner that can be a
12 * caller.
13 *
14 * WHAT THEY ARE. The C++ spelling of `feval(class(self), stageModel,
15 * self.options)` in `mapEnvApprox.m`: the environment image is solved with the
16 * solver that was asked for, at the settings it was asked for. Binding the
17 * caller's own options into the callable is the whole point -- a hard-coded
18 * backend silently discards the method, the tolerances and the iteration caps
19 * the user set, which is the defect the injection exists to close.
20 *
21 * WHY A SHARED HEADER RATHER THAN THREE LAMBDAS PER CALLER. Two translation
22 * units enter the fallback, `solver_facade.cpp` (`avg_table`) and
23 * `line_cli.cpp` (`run_avg_engine` plus the per-solver `-a avg` arms), and they
24 * must agree on what a stage solve reports or the same model answers differently
25 * through the facade and through the CLI. That is the divergence the Knobs
26 * struct exists to prevent one layer up, and it applies here for the same
27 * reason.
28 *
29 * They are `double`-only because the driver is: `map_env_approx` and
30 * `SolverEnvLimit::init` both refuse `T != double`, so a multiprecision caller
31 * keeps the plain refusal rather than falling back.
32 */
33
40#include "line/util/matrix.h"
41
42namespace line {
43namespace solvers {
44
45/** MVA stages, bound to the caller's own `MvaOptions`. */
47 return [opt](const qn::NetworkStruct<double>& stage) {
48 Matrix<double> init;
51 s.QN = r.QN;
52 s.UN = r.UN;
53 s.TN = r.TN;
54 s.cache = r.cache;
55 return s;
56 };
57}
58
59/** NC stages, bound to the caller's own `NcSolverOptions`. */
61 return [opt](const qn::NetworkStruct<double>& stage) {
64 s.QN = r.QN;
65 s.UN = r.UN;
66 s.TN = r.TN;
67 s.cache = r.cache;
68 return s;
69 };
70}
71
72/** Fluid stages, bound to the caller's own `FluidOptions`. */
74 return [opt](const qn::NetworkStruct<double>& stage) {
75 // The five-argument overload is the only one that reports cache metrics;
76 // the short one drops them, which on a cache-bearing stage is the whole
77 // quantity the environment blend is trying to recombine.
79 const fluid::FluidSolution r =
80 fluid::solver_fluid_run_analyzer<double>(stage, opt, nullptr, nullptr, &cache);
82 s.QN = r.QN;
83 s.UN = r.UN;
84 s.TN = r.TN;
85 s.cache = cache;
86 return s;
87 };
88}
89
90} // namespace solvers
91} // namespace line
92
93#endif // LINE_SOLVERS_MAP_ENV_STAGES_H
What a solver observed about the Cache nodes of a model.
A network plus its refreshed NetworkStruct.
The fluid solver's outermost entry point: @@SolverFLD/runAnalyzer.m's method resolution over solver_f...
Dense matrix and non-owning view.
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,...
FluidSolution solver_fluid_run_analyzer(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, qn::NetworkStruct< T > *sn_out=nullptr, qn::NetworkStruct< T > *refreshed_out=nullptr, solvers::CacheMetrics< T > *cache_out=nullptr)
Port of @@SolverFLD/runAnalyzer.m: resolve the method, route to the function the reference routes to,...
AvgResult< T > solver_mva_run_analyzer(const qn::NetworkStruct< T > &L, const MvaOptions &opt_in, const Matrix< T > &init_sol)
Port of @@SolverMVA/runAnalyzer.m for the lang='matlab' path: gate, solve, convert,...
mva::AvgResult< T > solver_nc_run_analyzer(const qn::NetworkStruct< T > &L_in, const NcSolverOptions &opt_in)
env::EnvStageAvgFn< double > nc_stage_fn(const nc::NcSolverOptions &opt)
NC stages, bound to the caller's own NcSolverOptions.
env::EnvStageAvgFn< double > fluid_stage_fn(const fluid::FluidOptions &opt)
Fluid stages, bound to the caller's own FluidOptions.
env::EnvStageAvgFn< double > mva_stage_fn(const mva::MvaOptions &opt)
MVA stages, bound to the caller's own MvaOptions.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
A queueing network and its refreshed NetworkStruct.
The two CLOSED-FORM environment limits: SolverENV.solveEnvLimit, reached by options....
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
The SolverNC class surface: @@SolverNC/runAnalyzer.m and the gates around it.
What one stage solve reports back to the limits.
solvers::CacheMetrics< T > cache
Controls, defaulting to SolverOptions('Fluid') in the reference.
What the analyzer returns, in the same shape as the MVA solver's result.
The metrics getAvg returns, after filtering.
Matrix< T > TN
throughput
Matrix< T > UN
utilization
Matrix< T > QN
queue length
solvers::CacheMetrics< T > cache
What the cache branches observed, EMPTY on a model with no Cache node and on every solver that does n...
The options SolverMVA reads.
Definition mva_types.h:31
Controls, defaulting to SolverOptions('NC') in the reference.
Definition nc_types.h:33
Every Cache node of the model, in node order; empty on a model with none.