LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
aph2_fit.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_APH2_FIT_H
6
#define LINE_API_MAM_APH2_FIT_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* APH(2) fit of three moments, with a fallback to adjusted moments
12
* (matlab/lib/m3a/m3a/aph2/aph2_fit.m).
13
*
14
* Exact fitting is attempted first with aph2_fitall; if that yields nothing
15
* the moments are relaxed with aph2_adjust ('simple' method) and the fit is
16
* repeated. The first solution is returned, together with all of them.
17
*
18
* Gated on transcendental arithmetic through aph2_fitall and aph2_adjust.
19
*/
20
21
#include <vector>
22
23
#include "
line/api/mam/aph2_adjust.h
"
24
#include "
line/api/mam/aph2_fitall.h
"
25
#include "
line/api/mam/map_moment.h
"
26
#include "
line/num/number.h
"
27
#include "
line/util/error.h
"
28
29
namespace
line
{
30
namespace
mam
{
31
32
/** Result of aph2_fit. */
33
template
<
class
T>
34
struct
Aph2FitResult
{
35
Map<T>
aph
;
///< the selected fit, APHS.front()
36
std::vector<Map<T>>
aphs
;
///< every feasible form found
37
bool
adjusted
;
///< true when the moments had to be relaxed
38
};
39
40
/** Fit an APH(2) to (M1, M2, M3), relaxing the moments if necessary. */
41
template
<
class
T>
42
Aph2FitResult<T>
aph2_fit
(
const
T& M1,
const
T& M2,
const
T& M3) {
43
static_assert
(
num_traits<T>::has_transcendental
,
"aph2_fit requires transcendental arithmetic"
);
44
Aph2FitResult<T>
r;
45
r.
adjusted
=
false
;
46
r.
aphs
=
aph2_fitall
(M1, M2, M3);
47
if
(r.
aphs
.empty()) {
48
const
Aph2AdjustResult<T>
adj =
aph2_adjust
(M1, M2, M3);
49
r.
adjusted
=
true
;
50
r.
aphs
=
aph2_fitall
(M1, adj.
M2a
, adj.
M3a
);
51
if
(r.
aphs
.empty())
throw
NumericError
(
"aph2_fit: feasibility could not be restored"
);
52
}
53
r.
aph
= r.
aphs
.front();
54
return
r;
55
}
56
57
}
// namespace mam
58
}
// namespace line
59
60
#endif
// LINE_API_MAM_APH2_FIT_H
aph2_adjust.h
Nearest APH(2)-feasible values of the second and third moments (matlab/lib/m3a/m3a/aph2/aph2_adjust....
aph2_fitall.h
All APH(2) representations matching three moments (matlab/lib/m3a/m3a/aph2/aph2_fitall....
line::NumericError::NumericError
NumericError(const std::string &what)
Definition
error.h:45
error.h
The exception types the port throws.
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::aph2_fit
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.
Definition
aph2_fit.h:42
line::mam::aph2_fitall
std::vector< Map< T > > aph2_fitall(const T &M1, const T &M2, const T &M3, const T °entol)
All feasible APH(2) fits of (M1, M2, M3).
Definition
aph2_fitall.h:46
line::mam::aph2_adjust
Aph2AdjustResult< T > aph2_adjust(const T &M1, const T &M2, const T &M3, const T &tol)
Feasible (M2, M3) closest to the input, holding M1 fixed.
Definition
aph2_adjust.h:46
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::mam::Aph2AdjustResult
Result of aph2_adjust.
Definition
aph2_adjust.h:36
line::mam::Aph2AdjustResult::M3a
T M3a
Definition
aph2_adjust.h:38
line::mam::Aph2AdjustResult::M2a
T M2a
Definition
aph2_adjust.h:37
line::mam::Aph2FitResult
Result of aph2_fit.
Definition
aph2_fit.h:34
line::mam::Aph2FitResult::adjusted
bool adjusted
true when the moments had to be relaxed
Definition
aph2_fit.h:37
line::mam::Aph2FitResult::aph
Map< T > aph
the selected fit, APHS.front()
Definition
aph2_fit.h:35
line::mam::Aph2FitResult::aphs
std::vector< Map< T > > aphs
every feasible form found
Definition
aph2_fit.h:36
line::mam::Map
A MAP as the pair of matrices (D0, D1).
Definition
map_moment.h:53
line::num_traits
Definition
number.h:111
include
line
api
mam
aph2_fit.h
Generated by
1.18.0