LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
mmpp2_fit1.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_FIT1_H
6
#define LINE_API_MAM_MMPP2_FIT1_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* MAP(2) matching mean, SCV, skewness and the index of dispersion for counts
12
* (matlab/lib/kpctoolbox/mmpp/mmpp2_fit1.m).
13
*
14
* The four characteristics are converted to the (e1, e2, e3, g2) coordinates
15
* of map2_fit:
16
* E2 = (1 + scv) E1^2,
17
* g2 = -(scv - idc)/(idc - 1),
18
* E3 = -(2 E1^3 - 3 E1 E2 - skew (E2 - E1^2)^(3/2)),
19
* with skew = -1 acting as the sentinel that lets map2_fit choose E3 itself.
20
*
21
* Gated on transcendental arithmetic: the third moment needs (E2 - E1^2)^(3/2)
22
* and map2_fit is itself gated.
23
*/
24
25
#include "
line/api/mam/map2_fit.h
"
26
#include "
line/api/mam/map_fit_detail.h
"
27
#include "
line/api/mam/map_moment.h
"
28
#include "
line/num/number.h
"
29
#include "
line/util/error.h
"
30
31
namespace
line
{
32
namespace
mam
{
33
34
/** MAP(2) with the given mean, SCV, skewness and IDC. */
35
template
<
class
T>
36
Map2FitResult<T>
mmpp2_fit1
(
const
T& mean,
const
T& scv,
const
T& skew,
const
T& idc) {
37
static_assert
(
num_traits<T>::has_transcendental
,
38
"mmpp2_fit1 requires transcendental arithmetic"
);
39
using
fitdetail::num_sqrt;
40
using
fitdetail::pw;
41
const
T one =
num_traits<T>::from_int
(1);
42
const
T two =
num_traits<T>::from_int
(2);
43
const
T three =
num_traits<T>::from_int
(3);
44
const
T E1 = mean;
45
const
T E2 = (one + scv) * E1 * E1;
46
if
(idc == one)
throw
InputError
(
"mmpp2_fit1: unit IDC admits no MMPP(2)"
);
47
const
T g2 = -(scv - idc) / (idc - one);
48
T E3;
49
if
(skew == -one) {
50
E3 = -one;
// map2_fit sentinel: pick the third moment automatically
51
}
else
{
52
const
T v = E2 - E1 * E1;
53
if
(v <
num_traits<T>::from_int
(0))
throw
InputError
(
"mmpp2_fit1: negative variance"
);
54
E3 = -(two * pw(E1, 3) - three * E1 * E2 - skew * v * num_sqrt(v));
55
}
56
return
map2_fit
(E1, E2, E3, g2);
57
}
58
59
}
// namespace mam
60
}
// namespace line
61
62
#endif
// LINE_API_MAM_MMPP2_FIT1_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
map2_fit.h
Explicit inverse characterization of a second-order acyclic MAP (matlab/lib/kpctoolbox/map/map2_fit....
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...
line::mam
Definition
amap2_adjust_gamma.h:78
line::mam::mmpp2_fit1
Map2FitResult< T > mmpp2_fit1(const T &mean, const T &scv, const T &skew, const T &idc)
MAP(2) with the given mean, SCV, skewness and IDC.
Definition
mmpp2_fit1.h:36
line::mam::map2_fit
Map2FitResult< T > map2_fit(const T &e1, const T &e2, const T &e3_in, const T &g2)
Fit an AMAP(2) to (e1, e2, e3, g2); see the header comment for e3 sentinels.
Definition
map2_fit.h:117
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::mam::Map2FitResult
Result of map2_fit: the MAP plus the reference's ERR code.
Definition
map2_fit.h:54
line::num_traits
Definition
number.h:111
include
line
api
mam
mmpp2_fit1.h
Generated by
1.18.0