LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
map_joint_derivative.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_JOINT_DERIVATIVE_H
6
#define LINE_API_MAM_MAP_JOINT_DERIVATIVE_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* Derivatives at the origin of a MAP's complementary CDF and of its joint
12
* inter-arrival density.
13
*
14
* Templated port of matlab/src/api/mam/map_ccdf_derivative.m and
15
* matlab/src/api/mam/map_jointpdf_derivative.m. Both are the building blocks
16
* of the joint-moment analysis of networks of MAP/MAP/1 queues in
17
* A. Horvath, G. Horvath, M. Telek, "A Joint Moments Based Analysis of
18
* Networks of MAP/MAP/1 Queues".
19
*
20
* The CCDF of the inter-arrival time of a MAP is F^c(t) = pie exp(D0 t) e, so
21
* its i-th derivative at 0 is
22
*
23
* nu_i = pie D0^i e.
24
*
25
* The joint density of a run of consecutive inter-arrival times is
26
* f(t_1,...,t_k) = pie exp(D0 t_1) D1 ... exp(D0 t_k) D1 e, so the mixed
27
* partial derivative of orders (i_1,...,i_k) at the origin is
28
*
29
* gamma = pie (D0^{i_1} D1) (D0^{i_2} D1) ... (D0^{i_k} D1) e.
30
*
31
* ARITHMETIC. Both are finite products of the descriptor matrices with the
32
* embedded arrival vector pie, which is itself a linear solve, so the whole
33
* computation is rational in the entries of D0 and D1. Neither is gated:
34
* they instantiate at Rational, where the derivatives come out as exact
35
* fractions. That matters here because these derivatives alternate in sign
36
* and grow like i! ||D0||^i, so at double a moderately stiff MAP loses most
37
* of its significant digits by i = 6, and only the exact instantiation can
38
* tell a genuine near-cancellation from an accumulation of rounding.
39
*/
40
41
#include <cstddef>
42
#include <vector>
43
44
#include "
line/api/mam/map_moment.h
"
45
#include "
line/num/number.h
"
46
#include "
line/util/error.h
"
47
#include "
line/util/linalg.h
"
48
#include "
line/util/matrix.h
"
49
50
namespace
line
{
51
namespace
mam
{
52
53
/**
54
* Derivative of order i at 0 of the MAP's complementary CDF, nu = pie D0^i e.
55
* Order 0 returns pie e = 1.
56
*/
57
template
<
class
T>
58
T
map_ccdf_derivative
(
const
Map<T>
& m,
unsigned
i) {
59
const
std::size_t n = m.
order
();
60
if
(n == 0)
throw
InputError
(
"map_ccdf_derivative: empty MAP"
);
61
const
std::vector<T> pie =
map_pie
(m);
62
const
std::vector<T> v =
vecmul
(pie,
matpow
(m.
D0
, i));
63
T s =
num_traits<T>::from_int
(0);
64
for
(
const
T& x : v) s += x;
65
return
s;
66
}
67
68
/**
69
* Mixed partial derivative at the origin of the joint density of consecutive
70
* inter-arrival times, gamma = pie prod_j (D0^{i_j} D1) e.
71
*
72
* An empty index set returns pie e = 1, matching the MATLAB loop over an
73
* empty vector.
74
*/
75
template
<
class
T>
76
T
map_jointpdf_derivative
(
const
Map<T>
& m,
const
std::vector<unsigned>& iset) {
77
const
std::size_t n = m.
order
();
78
if
(n == 0)
throw
InputError
(
"map_jointpdf_derivative: empty MAP"
);
79
std::vector<T> g =
map_pie
(m);
80
for
(std::size_t k = 0; k < iset.size(); ++k) {
81
g =
vecmul
(g,
matpow
(m.
D0
, iset[k]));
82
g =
vecmul
(g, m.
D1
);
83
}
84
T s =
num_traits<T>::from_int
(0);
85
for
(
const
T& x : g) s += x;
86
return
s;
87
}
88
89
}
// namespace mam
90
}
// namespace line
91
92
#endif
// LINE_API_MAM_MAP_JOINT_DERIVATIVE_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
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_ccdf_derivative
T map_ccdf_derivative(const Map< T > &m, unsigned i)
Derivative of order i at 0 of the MAP's complementary CDF, nu = pie D0^i e.
Definition
map_joint_derivative.h:58
line::mam::map_jointpdf_derivative
T map_jointpdf_derivative(const Map< T > &m, const std::vector< unsigned > &iset)
Mixed partial derivative at the origin of the joint density of consecutive inter-arrival times,...
Definition
map_joint_derivative.h:76
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
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::matpow
Matrix< T > matpow(const Matrix< T > &A, unsigned k)
Integer matrix power, by repeated squaring.
Definition
linalg.h:89
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::D1
Matrix< T > D1
Definition
map_moment.h:55
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_joint_derivative.h
Generated by
1.18.0