LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver_env_statevec.h File Reference

SolverENV, method = "statevec": a port of matlab/src/solvers/ENV/solver_env_statevec_analyzer.m. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <functional>
#include <limits>
#include <map>
#include <string>
#include <vector>
#include "line/api/mam/map_cdf.h"
#include "line/api/mam/map_moment.h"
#include "line/api/mc/ctmc_transient.h"
#include "line/api/mc/ctmc_uniformization.h"
#include "line/lang/qn/environment.h"
#include "line/lang/qn/network_struct.h"
#include "line/num/number.h"
#include "line/solvers/ctmc/solver_ctmc.h"
#include "line/api/mc/ctmc_solve_reducible.h"
#include "line/solvers/ctmc/solver_ctmc_analyzer.h"
#include "line/solvers/mam/solver_mam_ldqbd_flatten.h"
#include "line/util/error.h"
#include "line/util/lu.h"
#include "line/util/matrix.h"
Include dependency graph for solver_env_statevec.h:

Go to the source code of this file.

Classes

struct  line::env::EnvStatevecOptions< T >
 Options of the state-vector coupling. More...
struct  line::env::EnvStatevecSolution< T >
 What the state-vector coupling reports. More...
class  line::env::SolverEnvStatevec< T >
 The state-vector environment solver. More...

Namespaces

namespace  line
namespace  line::env

Typedefs

template<class T>
using line::env::ResetStateVec = std::function<std::vector<T>(const std::vector<T>&)>
 resetStateFun{h,e} of the reference: the state distribution of stage h at the h -> e switch, mapped onto the state space of stage e.

Functions

template<class T>
EnvStatevecSolution< T > line::env::solver_env_statevec (Environment< T > &e, const EnvStatevecOptions< T > &o)
 Solve in one call, for a caller with no use for the solver object.

Detailed Description

SolverENV, method = "statevec": a port of matlab/src/solvers/ENV/solver_env_statevec_analyzer.m.

WHAT IT DOES DIFFERENTLY FROM THE MEAN-FIELD COUPLING. solver_env.h carries only the MARGINAL MEAN queue lengths across an environment switch, so any correlation between stations at the moment of the switch is thrown away. This analyzer carries the whole JOINT distribution instead: each stage is an explicitly enumerated CTMC, and what crosses a switch is the full state probability vector. The two agree exactly when the marginal collapse happens to be lossless and diverge when it is not, which is the entire reason the reference keeps both.

THE FIXED POINT, and it is the same shape as the mean-field one. For stage e with generator Q_e and entry distribution pi_enter[e], propagate the transient pi(t) = pi_enter[e] exp(Q_e t) over the stage's time span, then read off pi_exit[e][h] the distribution AT the e -> h switch, the expectation of pi(t) under the e -> h transition time, pi_timeavg[e] the distribution at the END of the sojourn, under the superposed holding time, and chain the entries as pi_enter[e] = sum_h prob_orig(h, e) reset_{h->e}( pi_exit[h][e] ), renormalized, iterated to an L1 fixed point. The blend at the end weights each stage's pi_timeavg by prob_env and maps it to means.

THREE SOJOURN REGIMES, and only the third one integrates anything. When every outgoing transition of a stage is exponential the exit distribution equals the time-average and both are the RESOLVENT s pi_0 (sI - Q)^{-1}, a single linear solve with no quadrature – so that regime stays exact even in rational arithmetic. A deterministic sojourn is uniformization at one point. Only a general phase-type sojourn needs the adaptive transient, and that branch is gated below.

WHY THIS FILE DOES NOT DECODE MARGINALS ITSELF. There is a recorded defect here: _kb/06-solver-catalog.md, "ENV state-vector Util had drifted from the CTMC analyzer". MATLAB, Java and Python each grew a THIRD copy of the state-to-means reduction beside solver_ctmc_analyzer, all three drifted identically in the lld/cd branch, and no parity check saw it because they drifted together – Util was overstated by 44% on a closed lld model. The reduction here is therefore ctmc::solver_ctmc_avg_from_pi, the same function the CTMC analyzer calls, invoked on the same CtmcResult. Nothing about the discipline, the load dependence or the loss guards is re-derived.

THE ORACLE THAT NEEDS NO EXTERNAL REFERENCE, named in that same entry: an environment whose stages are IDENTICAL cannot change anything the network does, so this solver must reproduce the plain SolverCTMC solution of that one model. It does so EXACTLY here, not approximately, because the stationary distribution is a fixed point of all three sojourn regimes: pi Q = 0 makes the resolvent, the uniformized time-average and the transient all return pi unchanged, and pre() seeds from pi.

WHAT IS PORTED, and what is refused by name: ported the CTMC backend, all three sojourn regimes, per-transition state reset policies, the cache hit/miss blend of aggregateCacheBlend_ ported both stage backends – the enumerated CTMC and the MAM/LDQBD one (solver_mam_ldqbd + solver_mam_ldqbd_flatten, reduced by solver_mam_ldqbd_avg) – all three sojourn regimes, per-transition state reset policies, the cache hit/miss blend of aggregateCacheBlend_ refused an infinite inner-solver timespan

THE TWO BACKENDS DIFFER IN WHAT A STATE IS, and everything downstream of that is shared. A CTMC stage's state is an enumerated row of sn.space; a MAM stage's is a (level, phase) pair of the flattened QBD, with no marginal to decode and no cache content in it. So the propagation, the fixed point and the reset policies are backend-agnostic – they act on a probability vector and a generator – while the two ENDS are not: pre() builds the generator differently and finish() reduces it differently (solver_ctmc_avg_from_pi against solver_mam_ldqbd_avg).

Definition in file solver_env_statevec.h.