5#ifndef LINE_API_MAM_MMAP_COMPRESS_H
6#define LINE_API_MAM_MMAP_COMPRESS_H
102 const std::size_t I = maps.size();
103 if (I == 0)
throw InputError(
"mmap_mixture: no components");
104 if (alpha.size() != I)
throw InputError(
"mmap_mixture: one weight per component is required");
107 std::vector<std::size_t> sz(I), off(I);
108 std::size_t total = 0;
109 for (std::size_t i = 0; i < I; ++i) {
110 sz[i] = maps[i].order();
115 std::vector<std::vector<T>> pies(I);
116 for (std::size_t j = 0; j < I; ++j) pies[j] =
map_pie(maps[j]);
123 for (std::size_t i = 0; i < I; ++i) {
124 for (std::size_t a = 0; a < sz[i]; ++a)
125 for (std::size_t b = 0; b < sz[i]; ++b) out.
D0(off[i] + a, off[i] + b) = maps[i].D0(a, b);
127 std::vector<T> t(sz[i], zero);
128 for (std::size_t a = 0; a < sz[i]; ++a)
129 for (std::size_t b = 0; b < sz[i]; ++b) t[a] += maps[i].D1(a, b);
130 for (std::size_t j = 0; j < I; ++j)
131 for (std::size_t a = 0; a < sz[i]; ++a)
132 for (std::size_t b = 0; b < sz[j]; ++b) {
133 const T v = alpha[j] * t[a] * pies[j][b];
134 out.
D1(off[i] + a, off[j] + b) = v;
135 out.
Dc[i](off[i] + a, off[j] + b) = v;
165 "mmap_compress requires transcendental arithmetic");
186 const std::size_t K = in.
classes();
187 if (K == 0)
throw InputError(
"mmap_compress: the MMAP has no classes");
188 const std::vector<T> p =
mmap_pc(in);
189 std::vector<unsigned> orders;
190 orders.push_back(1u);
191 orders.push_back(2u);
192 orders.push_back(3u);
196 std::vector<Map<T>> comps;
198 for (std::size_t k = 0; k < K; ++k) {
199 if (p[k] <= zeroTol) {
204 one.
Dc.assign(1, in.
Dc[k]);
206 comps.push_back(
aph2_fit(B[0][0], B[0][1], B[0][2]).aph);
APH(2) fit of three moments, with a fallback to adjusted moments (matlab/lib/m3a/m3a/aph2/aph2_fit....
The exception types the port throws.
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
LUMPED interleaving of several M3PP(2, m), and the two fitters built on it (matlab/lib/m3a/m3a/m3pp/m...
Fit a MAMAP(2,m): a second-order acyclic MAP marked with m classes, matching the forward and backward...
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
Class-conditional backward moments of an MMAP (matlab/lib/m3a/m3a/mmap/mmap_backward_moment....
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
Modulate a family of marked MAPs by an environment chain.
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 ...
MmapCompressMethod
The compression methods of mmap_compress.m.
@ M3ppApproxDelta
'm3pp.approx_delta'
@ M3ppApproxAg
'm3pp.approx_ag'
@ MixtureOrder1
'default', 'mixture', 'mixture.order1'
@ MixtureOrder2
'mixture.order2'
@ M3ppExactDelta
'm3pp.exact_delta'
@ M3ppApproxCov
'm3pp.approx_cov'
Aph2FitResult< T > aph2_fit(const T &M1, const T &M2, const T &M3)
Fit an APH(2) to (M1, M2, M3), relaxing the moments if necessary.
Mmap< T > mmap_mixture(const std::vector< T > &alpha, const std::vector< Map< T > > &maps)
Probabilistic mixture of MAPs (mmap_mixture.m).
Mmap< T > mmap_mixture_fit_mmap(const Mmap< T > &mm)
mmap_mixture_fit driven from an MMAP (mmap_mixture_fit_mmap.m): the triple sigma and the cross moment...
Map< T > map_exponential(const T &lambda)
Two-phase MAP constructor for a Poisson process of rate lambda.
Mmap< T > mmap_compress(const Mmap< T > &in, MmapCompressMethod method)
Compress an MMAP (mmap_compress.m).
Mmap< T > mamap2m_fit_gamma_fb_mmap(const Mmap< T > &mm)
Fit a MAMAP(2,m) to an MMAP through the (F, B) pair alone (mamap2m_fit_gamma_fb_mmap....
std::vector< std::vector< T > > mmap_backward_moment(const Mmap< T > &m, const std::vector< unsigned > &orders, bool normalized)
Class-conditional backward moments of an MMAP (mmap_backward_moment.m).
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
Mmap< T > mamap2m_fit_mmap(const Mmap< T > &mm, const std::vector< T > &fbsWeights=std::vector< T >())
Fit a MAMAP(2,m) to the characteristics of an MMAP (mamap2m_fit_mmap.m): its three moments,...
std::vector< T > mmap_pc(const Mmap< T > &m)
Class probabilities seen by an arriving job, pc = pie (-D0)^-1 D1^(c) e.
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).
Conservation laws of a layered queueing network, enumerated from its structure.
Number-type abstraction for the templated API port.
A MAP as the pair of matrices (D0, D1).
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