LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::solvers Namespace Reference

Namespaces

namespace  map_env_detail

Classes

struct  CacheMetrics
 Every Cache node of the model, in node order; empty on a model with none. More...
struct  CacheNodeMetrics
 One Cache node's measured behaviour. More...
struct  ChainResult
 The station- or node-level table aggregated by chain. More...
struct  DefaultCdfCurve
 One [F(t), t] curve of the base-class response-time CDF fallback. More...
struct  MapEnvConfig
 The caller-facing map_env knobs, options.config.map_env and friends. More...
struct  MapEnvDecision
 What the gate decided, and what it decided it about. More...
struct  NodeMetrics
 The station table scattered to the NODE index space, plus the two flow columns the reference recomputes there. More...
struct  SysResult
 @@NetworkSolver/getAvgSys: one response time and one throughput per chain. More...

Functions

template<class T>
CacheMetrics< T > cache_metrics_of (const qn::NetworkStruct< T > &sn, const std::vector< T > &hitprob, const std::vector< T > &missprob, const std::vector< T > &delayedprob, const std::vector< T > &latency, const Matrix< T > &hitproblist, const Matrix< T > &itemprob, const std::vector< T > &listcost)
 Assemble CacheMetrics from what a cache analyzer returned.
template<class T>
CacheMetrics< T > cache_metrics_of_matrix (const qn::NetworkStruct< T > &sn, const Matrix< T > &hitprob, const Matrix< T > &missprob)
 The same, for the integrated caching-queueing branch, whose hit and miss probabilities are (ncaches x nclasses) rather than one vector per model.
template<class T, class StageFn>
mva::AvgResult< T > map_env_approx (const qn::NetworkStruct< T > &sn, const std::string &solver, const MapEnvConfig &cfg, StageFn stage_fn, const std::string &requested_method="default")
 mapEnvApprox: solve the model through the random-environment image of its non-renewal processes.
template<class T, class Run, class StageFn>
mva::AvgResult< T > run_avg (const qn::NetworkStruct< T > &sn, const std::string &solver, const qn::FeatureSet &declared, const MapEnvConfig &cfg, Run run, StageFn stage_fn, const std::string &requested_method="default")
 The getAvg funnel: run the model, or its environment image when the ONLY thing in the way is a non-renewal process.
const std::vector< qn::Feature > & map_env_tokens ()
 The four process names an environment image can represent; the order is the registry's.
bool is_map_env_token (qn::Feature f)
 True when f is one of the four.
template<class T>
MapEnvDecision needs_map_env (const qn::FeatureSet &declared, const qn::NetworkStruct< T > &sn, const MapEnvConfig &cfg=MapEnvConfig())
 needsMapEnv: does this model need the environment image, and would the image make it solvable?
std::string map_env_stage_backend (const std::string &solver)
 Which ENV stage backend a solver's name maps to, or empty when it has none.
bool supports_transient_analysis (const std::string &solver)
 supportsTransientAnalysis: does this solver produce transient averages?
env::EnvStageAvgFn< double > mva_stage_fn (const mva::MvaOptions &opt)
 MVA stages, bound to the caller's own MvaOptions.
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.
template<class T>
SysResult< T > solver_get_avg_sys (const qn::NetworkStruct< T > &sn, const mva::AvgResult< T > &r)
 Port of @@NetworkSolver/getAvgSys.m.
template<class T>
ChainResult< T > solver_get_avg_chain (const qn::NetworkStruct< T > &sn, const mva::AvgResult< T > &r)
 Port of @@NetworkSolver/getAvgChain.m: the station table aggregated by chain.
template<class T>
ChainResult< T > solver_get_avg_node_chain (const qn::NetworkStruct< T > &sn, const Matrix< T > &QNn, const Matrix< T > &UNn, const Matrix< T > &RNn, const Matrix< T > &WNn, const Matrix< T > &ANn, const Matrix< T > &TNn)
 Port of @@NetworkSolver/getAvgNodeChain.m: the NODE table aggregated by chain.
std::vector< std::string > chain_names (std::size_t nchains)
 Chain1, Chain2, ... – the reference's own chain labels.
template<class T>
std::vector< std::string > chain_class_labels (const qn::NetworkStruct< T > &sn)
 (ClassA ClassB), the JobClasses column: which classes a chain holds.
template<class T>
std::vector< std::vector< DefaultCdfCurve > > solver_default_cdf_respt (const qn::NetworkStruct< T > &sn, const Matrix< T > &RN)
 The NetworkSolver base-class response-time CDF: an exponential law with the right mean per (station, class), tabulated on 100 quantile points.
template<class T>
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.
template<class T>
NodeMetrics< T > node_metrics (const line::qn::NetworkStruct< T > &sn, const line::mva::AvgResult< T > &r)

Function Documentation

◆ avg_result_from_sim()

template<class T>
line::mva::AvgResult< T > line::solvers::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.

SSA and Fluid: their QN/UN/RN/TN are the same six columns the AvgTable arm already prints, so a VIEW of them is a view of the same numbers.

The two columns those runners do not carry are filled the way the reference fills them, and the SAME way their own -a avg arms do:

  • ResidT is sn_get_residt_from_respt, the per-JOB residence time. It is a pure function of sn and RN, which is why SolverMVA's runner calls it rather than deriving it inside the analyzer, and why a solver that reports no residence time of its own is not thereby excused from reporting one. ResidT = RespT holds only when every station is visited once per cycle; assuming it cost sdroute_closed a factor of 3 on the two Queues and init_state_ps a factor of 17 on Queue1.
  • ArvR is the throughput except at a Source, which has no arrivals TO ITSELF. Restating either rule here rather than sharing it would let -a avg and -a node disagree on one column of one model, which is the divergence -s mva vs -s fluid already produced once on gallery_mm1.

Definition at line 63 of file solver_node_tables.h.

References line::mva::AvgResult< T >::actualmethod, line::mva::AvgResult< T >::AN, line::mva::ArvR, avg_result_from_sim(), line::mva::AvgResult< T >::CN, line::lang::EXT, line::mva::filter_metric(), line::mva::AvgResult< T >::method, line::mva::AvgResult< T >::QN, line::mva::AvgResult< T >::RN, line::mva::sn_get_arvr_from_tput(), line::mva::sn_get_residt_from_respt(), line::mva::AvgResult< T >::TN, line::mva::AvgResult< T >::UN, line::mva::AvgResult< T >::WN, and line::mva::AvgResult< T >::XN.

Referenced by avg_result_from_sim().

◆ cache_metrics_of()

template<class T>
CacheMetrics< T > line::solvers::cache_metrics_of ( const qn::NetworkStruct< T > & sn,
const std::vector< T > & hitprob,
const std::vector< T > & missprob,
const std::vector< T > & delayedprob,
const std::vector< T > & latency,
const Matrix< T > & hitproblist,
const Matrix< T > & itemprob,
const std::vector< T > & listcost )

Assemble CacheMetrics from what a cache analyzer returned.

ONE PLACE, EVERY BRANCH OF EVERY SOLVER. Each cache analyzer computes a different subset – the retrieval ones give a delayed-hit fraction, the non-reentrant one gives the per-item law, the integrated one gives neither – and each leaves the rest empty. Assembling the struct here rather than in each branch keeps "absent means not computed" a single rule, which is what lets getAvgCacheTable print NaN in exactly the right places.

IT LIVES HERE, BESIDE THE STRUCT IT BUILDS, rather than in a solver's runner: SolverNC and SolverMVA both have cache branches and must assemble the answer the same way, and a runner including another runner to borrow the helper is how the two would drift apart.

THE MODEL'S CACHES ARE READ FROM THE STRUCT, not from the analyzer: the caps, the item count and the item sizes are model parameters and are reported even where the solve measured nothing, so a caller can see the cache it described.

Definition at line 105 of file cache_metrics.h.

References cache_metrics_of(), line::solvers::CacheMetrics< T >::caches, line::Matrix< T >::cols(), line::solvers::CacheNodeMetrics< T >::delayedprob, line::solvers::CacheNodeMetrics< T >::hitprob, line::solvers::CacheNodeMetrics< T >::hitproblist, line::solvers::CacheNodeMetrics< T >::itemcap, line::solvers::CacheNodeMetrics< T >::itemprob, line::solvers::CacheNodeMetrics< T >::itemsize, line::solvers::CacheNodeMetrics< T >::latency, line::solvers::CacheNodeMetrics< T >::listcost, line::solvers::CacheNodeMetrics< T >::missprob, line::solvers::CacheNodeMetrics< T >::name, line::solvers::CacheNodeMetrics< T >::nitems, line::solvers::CacheNodeMetrics< T >::node, and line::Matrix< T >::rows().

Referenced by cache_metrics_of(), cache_metrics_of_matrix(), line::ssa::cache_metrics_of_ssa(), and line::mva::mva_dispatch().

◆ cache_metrics_of_matrix()

template<class T>
CacheMetrics< T > line::solvers::cache_metrics_of_matrix ( const qn::NetworkStruct< T > & sn,
const Matrix< T > & hitprob,
const Matrix< T > & missprob )

The same, for the integrated caching-queueing branch, whose hit and miss probabilities are (ncaches x nclasses) rather than one vector per model.

Definition at line 163 of file cache_metrics.h.

References cache_metrics_of(), cache_metrics_of_matrix(), line::solvers::CacheMetrics< T >::caches, line::Matrix< T >::cols(), and line::Matrix< T >::rows().

Referenced by cache_metrics_of_matrix(), line::mva::mva_dispatch(), and line::fluid::solver_fluid_run_analyzer().

◆ chain_class_labels()

template<class T>
std::vector< std::string > line::solvers::chain_class_labels ( const qn::NetworkStruct< T > & sn)

(ClassA ClassB), the JobClasses column: which classes a chain holds.

Definition at line 548 of file solver_chain_tables.h.

References chain_class_labels().

Referenced by chain_class_labels().

◆ chain_names()

std::vector< std::string > line::solvers::chain_names ( std::size_t nchains)
inline

Chain1, Chain2, ... – the reference's own chain labels.

Definition at line 540 of file solver_chain_tables.h.

References chain_names().

Referenced by chain_names().

◆ fluid_stage_fn()

◆ is_map_env_token()

bool line::solvers::is_map_env_token ( qn::Feature f)
inline

True when f is one of the four.

Definition at line 71 of file map_env_gate.h.

References is_map_env_token(), and map_env_tokens().

Referenced by is_map_env_token(), and needs_map_env().

◆ map_env_approx()

template<class T, class StageFn>
mva::AvgResult< T > line::solvers::map_env_approx ( const qn::NetworkStruct< T > & sn,
const std::string & solver,
const MapEnvConfig & cfg,
StageFn stage_fn,
const std::string & requested_method = "default" )

mapEnvApprox: solve the model through the random-environment image of its non-renewal processes.

Parameters
snthe base model
solverthe calling solver's label ("SolverMVA", "SolverNC", ...), which decides the stage backend and the transient capability
cfgthe caller's map_env knobs
stage_fnruns ONE stage with the calling solver and returns its Q/U/T and cache surface; the C++ spelling of the reference's feval(class(self), stageModel, innerOptions) factory
requested_methodthe method the caller asked for, echoed in the result

THE MEAN-FIELD COUPLING DOES NOT TAKE stage_fn, and that is not an omission: it carries the marginal means and the RMF cache transient across a switch, objects only its own backend produces, so it runs SolverEnv's own fluid or ctmc stage instead. A solver with neither backend asking for meanfield EXPLICITLY is refused by name; auto never picks it for such a solver.

Definition at line 186 of file map_env.h.

References line::mva::AvgResult< T >::actualmethod, line::mva::AvgResult< T >::AN, line::solvers::map_env_detail::assert_stage_correspondence(), line::env::EnvAnalyzerSolution< T >::cache, line::mva::AvgResult< T >::cache, line::mva::AvgResult< T >::CN, line::solvers::map_env_detail::image_kind(), line::io::map2renv(), map_env_approx(), map_env_stage_backend(), line::Matrix< T >::Matrix(), line::solvers::map_env_detail::max_hold_time(), line::solvers::MapEnvConfig::max_stages, line::env::EnvOptions::method, line::mva::AvgResult< T >::method, line::solvers::MapEnvConfig::method, line::io::Map2RenvInfo< T >::nstages, line::env::EnvAnalyzerSolution< T >::QN, line::mva::AvgResult< T >::QN, line::mva::AvgResult< T >::RN, line::solvers::map_env_detail::select_env_limit(), line::mva::sn_get_residt_from_respt(), line::env::solver_env(), line::env::EnvOptions::stage_solver, supports_transient_analysis(), line::env::EnvOptions::timespan_end, line::env::EnvAnalyzerSolution< T >::TN, line::mva::AvgResult< T >::TN, line::env::EnvAnalyzerSolution< T >::UN, line::mva::AvgResult< T >::UN, line::UnsupportedError::UnsupportedError(), line::mva::AvgResult< T >::warning, line::mva::AvgResult< T >::WN, and line::mva::AvgResult< T >::XN.

Referenced by line::NetworkSolver::avg_table(), map_env_approx(), and run_avg().

◆ map_env_stage_backend()

std::string line::solvers::map_env_stage_backend ( const std::string & solver)
inline

Which ENV stage backend a solver's name maps to, or empty when it has none.

NOT THE SAME QUESTION AS supports_transient_analysis. SolverEnv::init admits stage_solver in {fluid, ctmc} only, so LDES and JMT answer the transient capability TRUE and still have no backend in this port; asking the capability alone would pick the mean-field coupling for a solver that cannot run a stage, and the coupling would then refuse by name. Keyed on the label string the feature gate already takes ("SolverMVA", "SolverNC", ...), because that is the only solver identity that exists at this level.

Definition at line 133 of file map_env_gate.h.

References map_env_stage_backend().

Referenced by map_env_approx(), and map_env_stage_backend().

◆ map_env_tokens()

const std::vector< qn::Feature > & line::solvers::map_env_tokens ( )
inline

The four process names an environment image can represent; the order is the registry's.

Definition at line 64 of file map_env_gate.h.

References map_env_tokens().

Referenced by is_map_env_token(), and map_env_tokens().

◆ mva_stage_fn()

◆ nc_stage_fn()

◆ needs_map_env()

template<class T>
MapEnvDecision line::solvers::needs_map_env ( const qn::FeatureSet & declared,
const qn::NetworkStruct< T > & sn,
const MapEnvConfig & cfg = MapEnvConfig() )

needsMapEnv: does this model need the environment image, and would the image make it solvable?

declared is the feature set of the RESOLVED method, not of the solver: MVA's default upgrades to rqna on a bursty open model and rqna declares MAP, so asking the base envelope would send a model into an image the run did not need. The callers resolve the method first for exactly that reason.

FALSE FOR A SUPPORTED MODEL, which is not the same as "no MAP in the model": a solver that declares the process consumes it natively and must not be diverted through an approximation of it.

Definition at line 108 of file map_env_gate.h.

References line::qn::feature_set_supports(), is_map_env_token(), line::qn::SupportResult::missing, line::solvers::MapEnvDecision::needed, needs_map_env(), line::qn::SupportResult::ok, line::solvers::MapEnvDecision::tokens, and line::qn::used_lang_features().

Referenced by line::NetworkSolver::avg_table(), needs_map_env(), and run_avg().

◆ node_metrics()

◆ run_avg()

template<class T, class Run, class StageFn>
mva::AvgResult< T > line::solvers::run_avg ( const qn::NetworkStruct< T > & sn,
const std::string & solver,
const qn::FeatureSet & declared,
const MapEnvConfig & cfg,
Run run,
StageFn stage_fn,
const std::string & requested_method = "default" )

The getAvg funnel: run the model, or its environment image when the ONLY thing in the way is a non-renewal process.

THREE OUTCOMES, AND THE THIRD IS THE SUBTLE ONE. Supported -> run. Needs the image -> map_env_approx. Otherwise -> RUN ANYWAY, and let the runner raise its own refusal in its own words. Raising a second copy of the refusal here would mean two messages for one condition, drifting apart as the feature sets move; needs_map_env is deliberately a question about whether the IMAGE helps, not a gate on whether the model is supported.

NOT WIRED INTO THE -s ba ARM, deliberately. A bound request must be answered with a bound, and the environment image is an approximation of the model, so its bounds do not bracket the original one. The reference refuses SolverBA inside needsMapEnv itself; here the exclusion is the absence of this wrapper at the three BA call sites, each of which says so.

Definition at line 327 of file map_env.h.

References map_env_approx(), line::solvers::MapEnvDecision::needed, needs_map_env(), and run_avg().

Referenced by line::NetworkSolver::avg_table(), and run_avg().

◆ solver_default_cdf_respt()

template<class T>
std::vector< std::vector< DefaultCdfCurve > > line::solvers::solver_default_cdf_respt ( const qn::NetworkStruct< T > & sn,
const Matrix< T > & RN )

The NetworkSolver base-class response-time CDF: an exponential law with the right mean per (station, class), tabulated on 100 quantile points.

This is @@NetworkSolver/getCdfRespT.m verbatim – "a trivial approximation that assumes exponential distributions everywhere with mean as RN(i,r)" – and it is what the reference serves for every solver without a distributional result of its own (MVA, LQNS, BA, AG). It says nothing about the tail; the solvers with a real law (CTMC, NC, Fluid, MAM, JMT, LDES) never reach it, and SSA refuses instead of inheriting it.

A Source station is left with empty curves, as the reference leaves its cells empty; a served cell whose mean is non-finite or non-positive gets the reference's degenerate [1, 0] point mass at zero.

Definition at line 50 of file solver_default_cdf.h.

References line::Matrix< T >::cols(), line::solvers::DefaultCdfCurve::F, line::Matrix< T >::rows(), solver_default_cdf_respt(), line::lang::Source, and line::solvers::DefaultCdfCurve::t.

Referenced by solver_default_cdf_respt().

◆ solver_get_avg_chain()

template<class T>
ChainResult< T > line::solvers::solver_get_avg_chain ( const qn::NetworkStruct< T > & sn,
const mva::AvgResult< T > & r )

Port of @@NetworkSolver/getAvgChain.m: the station table aggregated by chain.

QLen, Util, ArvR, Tput and ResidT are row sums over the chain's classes; RespT is the alpha-weighted average, alpha being sn_get_demands_chain's visit share. See the file header for why the two rules differ.

Definition at line 460 of file solver_chain_tables.h.

References line::mva::ChainDemands< T >::alpha, line::mva::AvgResult< T >::AN, line::solvers::ChainResult< T >::AN, line::Matrix< T >::Matrix(), line::mva::AvgResult< T >::QN, line::solvers::ChainResult< T >::QN, line::mva::AvgResult< T >::RN, line::solvers::ChainResult< T >::RN, line::mva::sn_get_demands_chain(), solver_get_avg_chain(), line::mva::AvgResult< T >::TN, line::solvers::ChainResult< T >::TN, line::mva::AvgResult< T >::UN, line::solvers::ChainResult< T >::UN, line::mva::AvgResult< T >::WN, and line::solvers::ChainResult< T >::WN.

Referenced by solver_get_avg_chain().

◆ solver_get_avg_node_chain()

template<class T>
ChainResult< T > line::solvers::solver_get_avg_node_chain ( const qn::NetworkStruct< T > & sn,
const Matrix< T > & QNn,
const Matrix< T > & UNn,
const Matrix< T > & RNn,
const Matrix< T > & WNn,
const Matrix< T > & ANn,
const Matrix< T > & TNn )

Port of @@NetworkSolver/getAvgNodeChain.m: the NODE table aggregated by chain.

The node-level class matrices are the caller's, because the scatter from stations to nodes and the recomputation of ArvR and Tput per node is getAvgNodeTable's work and is not repeated here. Rows that are not stations carry zero response and residence time, which is the reference's construction and not a gap: a node that is not a station holds no jobs.

Definition at line 499 of file solver_chain_tables.h.

References line::mva::ChainDemands< T >::alpha, line::solvers::ChainResult< T >::AN, line::Matrix< T >::Matrix(), line::solvers::ChainResult< T >::QN, line::solvers::ChainResult< T >::RN, line::mva::sn_get_demands_chain(), solver_get_avg_node_chain(), line::solvers::ChainResult< T >::TN, line::solvers::ChainResult< T >::UN, and line::solvers::ChainResult< T >::WN.

Referenced by solver_get_avg_node_chain().

◆ solver_get_avg_sys()

template<class T>
SysResult< T > line::solvers::solver_get_avg_sys ( const qn::NetworkStruct< T > & sn,
const mva::AvgResult< T > & r )

Port of @@NetworkSolver/getAvgSys.m.

FORK-JOIN WITH AN OPEN CHAIN IS SERVED (2026-08-15). The reference fills the join station's response time with the order statistic of the parallel branch times – d0, an inclusion-exclusion sum over every path from the fork to the join, enumerated by ModelAdapter.pathsCS – and both halves of that are ported above as chain_detail::paths_cs and chain_detail::exp_max_mean. A CLOSED fork-join chain needs neither: its cycle time comes from Little's law, which reads the population and the throughput and never touches the join's response time, and the reference skips the walk there too. The JAR still refuses this case and then fills RN with NaN.

Definition at line 256 of file solver_chain_tables.h.

References line::solvers::SysResult< T >::CN, line::lang::Fork, line::lang::Join, line::mva::AvgResult< T >::RN, solver_get_avg_sys(), line::mva::AvgResult< T >::TN, line::UnsupportedError::UnsupportedError(), and line::solvers::SysResult< T >::XN.

Referenced by solver_get_avg_sys().

◆ supports_transient_analysis()

bool line::solvers::supports_transient_analysis ( const std::string & solver)
inline

supportsTransientAnalysis: does this solver produce transient averages?

A CAPABILITY CLAIM, answered before any run, because the driver reads it to decide whether the stages can be coupled by the mean-field analyzer (which integrates each stage over its sojourn and so needs a transient) or only by the two steady-state limits. The four that populate result.Tran.Avg in the reference are FLD, CTMC, LDES and JMT.

Definition at line 148 of file map_env_gate.h.

References supports_transient_analysis().

Referenced by map_env_approx(), and supports_transient_analysis().