LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
map_pdf.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_MAP_PDF_H
6
#define LINE_API_MAM_MAP_PDF_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* Probability density of the inter-arrival time of a MAP.
12
*
13
* Templated port of matlab/lib/kpctoolbox/map/map_pdf.m. Conditional on the
14
* phase pie seen by an arrival the inter-arrival time is phase-type with
15
* representation (pie, D0), so f(t) = pie exp(D0 t) (-D0) e. The JAR has no
16
* counterpart of this function.
17
*
18
* ARITHMETIC: exp(D0 t) is a tolerance-controlled approximation, so this
19
* requires transcendental arithmetic; pie itself is exact.
20
*/
21
22
#include <cstddef>
23
#include <vector>
24
25
#include "
line/api/mam/map_moment.h
"
26
#include "
line/num/number.h
"
27
#include "
line/util/error.h
"
28
#include "
line/util/expm.h
"
29
#include "
line/util/linalg.h
"
30
#include "
line/util/matrix.h
"
31
32
namespace
line
{
33
namespace
mam
{
34
35
/**
36
* Probability density of the inter-arrival time at the given points.
37
*
38
* @param m the MAP (D0, D1)
39
* @param tset evaluation times, each >= 0
40
* @return f(t) in the order of tset
41
*/
42
template
<
class
T>
43
std::vector<T>
map_pdf
(
const
Map<T>
& m,
const
std::vector<T>& tset) {
44
static_assert
(
num_traits<T>::has_transcendental
,
"map_pdf requires transcendental arithmetic"
);
45
const
std::vector<T> pie =
map_pie
(m);
46
const
T zero =
num_traits<T>::from_int
(0);
47
Matrix<T>
negD0 = m.
D0
;
48
for
(std::size_t i = 0; i < negD0.
rows
(); ++i)
49
for
(std::size_t j = 0; j < negD0.
cols
(); ++j) negD0(i, j) = -negD0(i, j);
50
const
std::vector<T> e =
ones<T>
(m.
order
());
51
const
std::vector<T> negD0e =
mulvec
(negD0, e);
52
53
std::vector<T> out;
54
out.reserve(tset.size());
55
for
(std::size_t k = 0; k < tset.size(); ++k) {
56
if
(tset[k] < zero)
throw
InputError
(
"map_pdf: negative evaluation point"
);
57
std::vector<T> v = pie;
58
if
(!(tset[k] == zero)) v =
vecmul
(pie,
expm
(m.
D0
, tset[k]));
59
T s = zero;
60
for
(std::size_t i = 0; i < v.size(); ++i) s += v[i] * negD0e[i];
61
out.push_back(s);
62
}
63
return
out;
64
}
65
66
}
// namespace mam
67
}
// namespace line
68
69
#endif
// LINE_API_MAM_MAP_PDF_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
line::Matrix
Definition
matrix.h:56
line::Matrix::cols
std::size_t cols() const
Definition
matrix.h:90
line::Matrix::rows
std::size_t rows() const
Definition
matrix.h:89
error.h
The exception types the port throws.
expm.h
Matrix exponential by scaling and squaring with a diagonal Pade approximant.
linalg.h
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
map_moment.h
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
matrix.h
Dense matrix and non-owning view.
line::mam
Definition
amap2_adjust_gamma.h:78
line::mam::map_pie
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
Definition
map_moment.h:89
line::mam::map_pdf
std::vector< T > map_pdf(const Map< T > &m, const std::vector< T > &tset)
Probability density of the inter-arrival time at the given points.
Definition
map_pdf.h:43
line
Definition
aoi_dist2ph.h:52
line::vecmul
std::vector< T > vecmul(const std::vector< T > &v, const Matrix< T > &A)
Row vector times matrix, v A.
Definition
linalg.h:50
line::mulvec
std::vector< T > mulvec(const Matrix< T > &A, const std::vector< T > &v)
Matrix times column vector, A v.
Definition
linalg.h:62
line::ones
std::vector< T > ones(std::size_t n)
Column vector of ones, the ubiquitous e in MAP algebra.
Definition
linalg.h:104
line::expm
Matrix< T > expm(const Matrix< T > &A)
Matrix exponential exp(A).
Definition
expm.h:141
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::Map::D0
Matrix< T > D0
Definition
map_moment.h:54
line::mam::Map::order
std::size_t order() const
Definition
map_moment.h:57
line::num_traits
Definition
number.h:111
include
line
api
mam
map_pdf.h
Generated by
1.18.0