LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
mmpp2_fit2.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_API_MAM_MMPP2_FIT2_H
6
#define LINE_API_MAM_MMPP2_FIT2_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* MMPP(2) matching mean, SCV, skewness and the autocorrelation decay rate
12
* (matlab/lib/kpctoolbox/mmpp/mmpp2_fit2.m).
13
*
14
* Converts (mean, scv, skew) to raw moments and delegates to mmpp2_fit3. A
15
* unit SCV short-circuits to a Poisson process, where the MMPP(2) closed form
16
* is degenerate. MATLAB then warns when the result fails map_isfeasible; this
17
* port reports it through the result struct instead, since a warning printed
18
* from a library is invisible to a caller that only has the return value.
19
*
20
* Gated on transcendental arithmetic: the third moment needs
21
* (E2 - E1^2)^(3/2) and mmpp2_fit3 is itself gated.
22
*/
23
24
#include "
line/api/mam/map_fit_detail.h
"
25
#include "
line/api/mam/map_moment.h
"
26
#include "
line/api/mam/map_transform.h
"
27
#include "
line/api/mam/mmpp2_fit3.h
"
28
#include "
line/num/number.h
"
29
#include "
line/util/error.h
"
30
31
namespace
line
{
32
namespace
mam
{
33
34
/** Result of the (mean, scv, skew)-parameterized MMPP(2) fits. */
35
template
<
class
T>
36
struct
Mmpp2FitResult
{
37
Map<T>
map
;
38
bool
feasible
;
///< map_isfeasible of the result at the given tolerance
39
};
40
41
/** MMPP(2) with the given mean, SCV, skewness and decay rate g2. */
42
template
<
class
T>
43
Mmpp2FitResult<T>
mmpp2_fit2
(
const
T& mean,
const
T& scv,
const
T& skew,
const
T& g2) {
44
static_assert
(
num_traits<T>::has_transcendental
,
45
"mmpp2_fit2 requires transcendental arithmetic"
);
46
using
fitdetail::num_sqrt;
47
using
fitdetail::pw;
48
const
T one =
num_traits<T>::from_int
(1);
49
const
T two =
num_traits<T>::from_int
(2);
50
const
T three =
num_traits<T>::from_int
(3);
51
52
Mmpp2FitResult<T>
r;
53
if
(scv == one) {
54
r.
map
=
map_exponential_mean
(mean);
55
r.
feasible
=
true
;
56
return
r;
57
}
58
const
T E1 = mean;
59
const
T E2 = (one + scv) * E1 * E1;
60
const
T v = E2 - E1 * E1;
61
if
(v <
num_traits<T>::from_int
(0))
throw
InputError
(
"mmpp2_fit2: negative variance"
);
62
const
T E3 = -(two * pw(E1, 3) - three * E1 * E2 - skew * v * num_sqrt(v));
63
r.
map
=
mmpp2_fit3
(E1, E2, E3, g2);
64
r.
feasible
=
map_isfeasible
(r.
map
, T(
num_traits<T>::from_double
(1e-10)));
65
return
r;
66
}
67
68
}
// namespace mam
69
}
// namespace line
70
71
#endif
// LINE_API_MAM_MMPP2_FIT2_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
map_fit_detail.h
Scalar helpers shared by the MAP/PH moment-matching headers.
map_moment.h
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
map_transform.h
MAP constructors and structural transformations.
mmpp2_fit3.h
MMPP(2) matching three moments and the autocorrelation decay rate (matlab/lib/kpctoolbox/mmpp/mmpp2_f...
line::mam
Definition
amap2_adjust_gamma.h:78
line::mam::mmpp2_fit3
Map< T > mmpp2_fit3(const T &E1, const T &E2, const T &E3, const T &G2, const T &g2tol)
MMPP(2) with moments (E1, E2, E3) and autocorrelation decay rate G2.
Definition
mmpp2_fit3.h:51
line::mam::map_isfeasible
bool map_isfeasible(const Map< T > &m, const T &tol)
Structural feasibility of a MAP within a tolerance (map_isfeasible.m): off-diagonal D0 and all of D1 ...
Definition
map_transform.h:498
line::mam::map_exponential_mean
Map< T > map_exponential_mean(const T &mean)
Poisson process with the given mean inter-arrival time (map_exponential.m).
Definition
map_transform.h:118
line::mam::mmpp2_fit2
Mmpp2FitResult< T > mmpp2_fit2(const T &mean, const T &scv, const T &skew, const T &g2)
MMPP(2) with the given mean, SCV, skewness and decay rate g2.
Definition
mmpp2_fit2.h:43
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::mam::Map
A MAP as the pair of matrices (D0, D1).
Definition
map_moment.h:53
line::mam::Mmpp2FitResult
Result of the (mean, scv, skew)-parameterized MMPP(2) fits.
Definition
mmpp2_fit2.h:36
line::mam::Mmpp2FitResult::feasible
bool feasible
map_isfeasible of the result at the given tolerance
Definition
mmpp2_fit2.h:38
line::mam::Mmpp2FitResult::map
Map< T > map
Definition
mmpp2_fit2.h:37
line::num_traits
Definition
number.h:111
include
line
api
mam
mmpp2_fit2.h
Generated by
1.18.0