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

Superposition of several marked arrival flows into one. More...

#include <cstddef>
#include <vector>
#include "line/api/mam/m3pp2m_interleave.h"
#include "line/api/mam/mmap_compress.h"
#include "line/api/mam/mmap_lambda.h"
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
Include dependency graph for npfqn_traffic_merge.h:

Go to the source code of this file.

Classes

struct  line::npfqn::MergeConfig
 MATLAB's config struct. More...

Namespaces

namespace  line
namespace  line::npfqn

Enumerations

enum class  line::npfqn::Merge { line::npfqn::Default , line::npfqn::Super , line::npfqn::Mixture , line::npfqn::Interpos }
 Merge rule, MATLAB's config.merge. More...
enum class  line::npfqn::Compress { line::npfqn::Default , line::npfqn::None }
 Post-merge compression, MATLAB's config.compress. More...

Functions

template<class T>
mam::Mmap< T > line::npfqn::mmap_super_match (const mam::Mmap< T > &a, const mam::Mmap< T > &b)
 Superposition matching classes one to one (mmap_super.m, option 'match').
template<class T>
mam::Mmap< T > line::npfqn::mmap_mark_types (const mam::Mmap< T > &m, const Matrix< T > &prob)
 Re-mark an MMAP's K types into R classes (mmap_mark.m).
template<class T>
mam::Mmap< T > line::npfqn::npfqn_traffic_merge (const std::vector< mam::Mmap< T > > &flows, const MergeConfig &config=MergeConfig())
 Merge a list of MMAPs carrying the same classes.

Detailed Description

Superposition of several marked arrival flows into one.

Templated port of matlab/src/api/npfqn/npfqn_traffic_merge.m and matlab/src/api/npfqn/npfqn_traffic_merge_cs.m.

Given n MMAPs carrying the same R classes, the merge is the class-by-class superposition mmap_super(., ., 'match'), folded left to right, followed optionally by a compression back to a small representation. The class- switching variant first re-marks flow i with its own (R x R) switching matrix, prob((i-1)R + r, s) being the probability that a class-r arrival from flow i leaves as class s, and then superposes.

WHAT MUST HOLD. Superposition of independent flows adds the rates: the merged per-class rate is the sum of the per-class rates of the operands, as an identity and not as an approximation. The class-switching variant carries the rates through the switching matrix, so the merged class-s rate is sum_i sum_r lambda_{i,r} P_i(r, s), and the TOTAL rate is preserved whenever every P_i is stochastic. Both are asserted exactly in the rational instantiation by the tests. Compression does NOT preserve them exactly: it preserves the class probabilities p_c and the aggregate mean, hence the per-class rates, only up to the APH(2) moment fit.

REFERENCE DEFECTS in matlab/src/api/npfqn/npfqn_traffic_merge.m:

  1. A ONE-ARGUMENT CALL WITH MORE THAN ONE NON-EMPTY FLOW ALWAYS ERRORS. Line 9 builds the default configuration as struct('merge','default'), with no compress field, and line 46 then reaches switch config.compress unconditionally. MATLAB raises "Reference to non-existent field 'compress'". The single-flow case returns early at line 13 and is unaffected, which is why the defect survives: the n == 1 shortcut is by far the most common call. Reproduction, from matlab/: M = map_exponential(1); M{3} = M{2}; npfqn_traffic_merge({M, M}) -> Reference to non-existent field 'compress'. while npfqn_traffic_merge({M}) returns M. The INTENDED behaviour is the documented default of the compress switch, i.e. compression by mmap_compress, and that is what this port does with its default-constructed configuration. The defect is NOT propagated: there is no way to spell "merge configured but compression unset" here, since MergeConfig::compress is a value with a default.
  2. The 'default'/'super' branch guards each operand with ~isempty(MMAP{j}) although the empty operands were already deleted at line 5, so the guard is dead. Reproduced as written (the port drops empty flows up front and the loop then has nothing to skip), and harmless.

ARITHMETIC. The merge itself is a Kronecker sum and stays exact at T = Rational, so npfqn_traffic_merge_cs and the no-compression merge are offered at every arithmetic. Compression pulls in aph2_fit, so npfqn_traffic_merge with Compress::Default is gated on num_traits<T>::has_transcendental through mmap_compress.

NOT PORTED. Merge::Mixture needs mmap_mixture_fit_mmap, which is not in this tree; it raises UnsupportedError naming the missing MATLAB function rather than falling back to another merge. Merge::Interpos is served, through m3pp2m_fitc_theoretical and m3pp2m_interleave; it is gated on transcendental arithmetic like the rest of the counting-process fitters, so it is not offered at T = Rational.

Definition in file npfqn_traffic_merge.h.