LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
mmpp2_fit4.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_FIT4_H
6
#define LINE_API_MAM_MMPP2_FIT4_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* MMPP(2) matching mean, SCV, skewness and the lag-1 autocorrelation
12
* (matlab/lib/kpctoolbox/mmpp/mmpp2_fit4.m).
13
*
14
* Same conversion as mmpp2_fit2 except that the autocorrelation is given at
15
* lag 1 rather than as the decay rate, so it is divided by the lag-0
16
* autocorrelation rho0 = (1 - 1/scv)/2 first. skew = -1 is the sentinel that
17
* defers the choice of the third moment, which mmpp2_fit3 does not support;
18
* unlike MATLAB, which would pass E3 = -1 straight into the closed form and
19
* return a meaningless MAP, this port rejects it.
20
*
21
* Gated on transcendental arithmetic through mmpp2_fit3.
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_fit2.h
"
28
#include "
line/api/mam/mmpp2_fit3.h
"
29
#include "
line/num/number.h
"
30
#include "
line/util/error.h
"
31
32
namespace
line
{
33
namespace
mam
{
34
35
/** MMPP(2) with the given mean, SCV, skewness and lag-1 autocorrelation. */
36
template
<
class
T>
37
Mmpp2FitResult<T>
mmpp2_fit4
(
const
T& mean,
const
T& scv,
const
T& skew,
const
T& acf1) {
38
static_assert
(
num_traits<T>::has_transcendental
,
39
"mmpp2_fit4 requires transcendental arithmetic"
);
40
using
fitdetail::num_sqrt;
41
using
fitdetail::pw;
42
const
T one =
num_traits<T>::from_int
(1);
43
const
T two =
num_traits<T>::from_int
(2);
44
const
T three =
num_traits<T>::from_int
(3);
45
46
if
(skew == -one)
47
throw
InputError
(
"mmpp2_fit4: skew = -1 (automatic third moment) is not supported"
);
48
if
(scv ==
num_traits<T>::from_int
(0))
throw
InputError
(
"mmpp2_fit4: zero SCV"
);
49
const
T rho0 = (one - one / scv) / two;
50
if
(rho0 ==
num_traits<T>::from_int
(0))
51
throw
InputError
(
"mmpp2_fit4: unit SCV admits no autocorrelation"
);
52
53
const
T E1 = mean;
54
const
T E2 = (one + scv) * E1 * E1;
55
const
T v = E2 - E1 * E1;
56
if
(v <
num_traits<T>::from_int
(0))
throw
InputError
(
"mmpp2_fit4: negative variance"
);
57
const
T E3 = -(two * pw(E1, 3) - three * E1 * E2 - skew * v * num_sqrt(v));
58
59
Mmpp2FitResult<T>
r;
60
r.
map
=
mmpp2_fit3
(E1, E2, E3, T(acf1 / rho0));
61
r.
feasible
=
map_isfeasible
(r.
map
, T(
num_traits<T>::from_double
(1e-10)));
62
return
r;
63
}
64
65
}
// namespace mam
66
}
// namespace line
67
68
#endif
// LINE_API_MAM_MMPP2_FIT4_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_fit2.h
MMPP(2) matching mean, SCV, skewness and the autocorrelation decay rate (matlab/lib/kpctoolbox/mmpp/m...
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::mmpp2_fit4
Mmpp2FitResult< T > mmpp2_fit4(const T &mean, const T &scv, const T &skew, const T &acf1)
MMPP(2) with the given mean, SCV, skewness and lag-1 autocorrelation.
Definition
mmpp2_fit4.h:37
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
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
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_fit4.h
Generated by
1.18.0