5#ifndef LINE_API_NPFQN_TRAFFIC_MERGE_H
6#define LINE_API_NPFQN_TRAFFIC_MERGE_H
101 throw InputError(
"mmap_super_match: class matching failed, the MMAPs have different "
102 "numbers of classes");
126 const std::size_t K = prob.
rows(), R = prob.
cols();
128 throw InputError(
"mmap_mark_types: prob needs one row per marked type of the MMAP");
133 const std::size_t n = m.
order();
134 for (std::size_t r = 0; r < R; ++r) {
136 for (std::size_t k = 0; k < K; ++k) {
137 const T& p = prob(k, r);
138 if (p == zero)
continue;
139 for (std::size_t i = 0; i < n; ++i)
140 for (std::size_t j = 0; j < n; ++j) Dr(i, j) += m.
Dc[k](i, j) * p;
142 out.
Dc.push_back(Dr);
182 throw UnsupportedError(
"npfqn_traffic_merge: compression needs transcendental arithmetic "
183 "(aph2_fit); merge at exact arithmetic with Compress::None");
199 std::vector<const mam::Mmap<T>*> nonEmpty;
201 if (f.order() != 0) nonEmpty.push_back(&f);
202 if (nonEmpty.empty())
throw InputError(
"npfqn_traffic_merge: no non-empty flow to merge");
203 if (nonEmpty.size() == 1)
return *nonEmpty.front();
205 switch (config.merge) {
211 "mmap_mixture_fit_mmap, which is not ported");
221 "M3PP(2,m), which is transcendental; use double or real");
226 std::vector<mam::Mmap<T>> flowFits;
227 for (std::size_t j = 0; j < nonEmpty.size(); ++j)
233 lumped = detail::compress_or_refuse(lumped);
240 for (std::size_t j = 1; j < nonEmpty.size(); ++j) s =
mmap_super_match(s, *nonEmpty[j]);
UnsupportedError(const std::string &what)
The exception types the port throws.
LUMPED interleaving of several M3PP(2, m), and the two fitters built on it (matlab/lib/m3a/m3a/m3pp/m...
Dense matrix and non-owning view.
Compression of a marked MAP into a smaller representation, and the two M3A primitives it is built fro...
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
Mmap< T > mmap_normalize(const Mmap< T > &in)
Clamp negative off-diagonal and per-class entries to zero and rebuild D1 and the diagonal of D0 from ...
@ MixtureOrder1
'default', 'mixture', 'mixture.order1'
Mmap< T > m3pp2m_interleave(const std::vector< Mmap< T > > &parts)
Interleave L M3PP(2, m_i) into one M3PP of order L + 1 whose class list is the concatenation of their...
Matrix< T > krons(const Matrix< T > &A, const Matrix< T > &B)
Kronecker sum, MATLAB's krons: kron(A, I_nb) + kron(I_na, B).
Mmap< T > mmap_compress(const Mmap< T > &in, MmapCompressMethod method)
Compress an MMAP (mmap_compress.m).
Mmap< T > m3pp2m_fitc_theoretical(const Mmap< T > &mm, const std::string &method, const T &t, const T &tinf)
Fit the counting characteristics of a GIVEN MMAP with an M3PP(2, m).
Merge
Merge rule, MATLAB's config.merge.
@ Interpos
'interpos', lumped interleaving of per-flow M3PP(2, m) fits
@ Default
'default', identical to 'super'
@ Mixture
'mixture', not ported
mam::Mmap< T > mmap_super_match(const mam::Mmap< T > &a, const mam::Mmap< T > &b)
Superposition matching classes one to one (mmap_super.m, option 'match').
mam::Mmap< T > 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).
Compress
Post-merge compression, MATLAB's config.compress.
@ Default
'default', mmap_compress with its own default method
mam::Mmap< T > npfqn_traffic_merge(const std::vector< mam::Mmap< T > > &flows, const MergeConfig &config=MergeConfig())
Merge a list of MMAPs carrying the same classes.
Number-type abstraction for the templated API port.
An MMAP: the underlying MAP plus the per-class arrival matrices.
std::size_t classes() const
std::vector< Matrix< T > > Dc
per-class matrices, sum_c Dc = D1
std::size_t order() const