LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
map_mark.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_MARK_H
6
#define LINE_API_MAM_MAP_MARK_H
7
8
/**
9
* @file
10
* @ingroup api_mam
11
* Mark the arrivals of a MAP with class probabilities
12
* (matlab/lib/kpctoolbox/map/map_mark.m).
13
*
14
* The unmarked inter-arrival process is unchanged: Dc = prob(c) * D1, so the
15
* class of an arrival is drawn independently of the phase. This is the
16
* phase-independent special case of mmap_mark in mmap_lambda.h, which takes a
17
* per-phase weight matrix instead.
18
*
19
* MATLAB warns and renormalizes when the probabilities do not sum to one;
20
* this port renormalizes silently but rejects a non-positive total, since a
21
* zero total has no meaningful normalization. Pure field arithmetic, exact at
22
* Rational: no transcendental gate.
23
*/
24
25
#include <vector>
26
27
#include "
line/api/mam/map_moment.h
"
28
#include "
line/api/mam/mmap_lambda.h
"
29
#include "
line/num/number.h
"
30
#include "
line/util/error.h
"
31
#include "
line/util/matrix.h
"
32
33
namespace
line
{
34
namespace
mam
{
35
36
/** MMAP with the same inter-arrival process and arrivals marked by prob. */
37
template
<
class
T>
38
Mmap<T>
map_mark
(
const
Map<T>
& m,
const
std::vector<T>& prob) {
39
const
T zero =
num_traits<T>::from_int
(0);
40
if
(prob.empty())
throw
InputError
(
"map_mark: empty marking probabilities"
);
41
T s = zero;
42
for
(
const
T& p : prob) {
43
if
(p < zero)
throw
InputError
(
"map_mark: negative marking probability"
);
44
s += p;
45
}
46
if
(s == zero)
throw
InputError
(
"map_mark: marking probabilities sum to zero"
);
47
Mmap<T>
out;
48
out.
D0
= m.
D0
;
49
out.
D1
= m.
D1
;
50
for
(std::size_t c = 0; c < prob.size(); ++c) {
51
Matrix<T>
Dc(m.
D1
.rows(), m.
D1
.cols());
52
const
T w = prob[c] / s;
53
for
(std::size_t i = 0; i < Dc.
rows
(); ++i)
54
for
(std::size_t j = 0; j < Dc.
cols
(); ++j) Dc(i, j) = w * m.
D1
(i, j);
55
out.
Dc
.push_back(Dc);
56
}
57
return
mmap_normalize
(out);
58
}
59
60
}
// namespace mam
61
}
// namespace line
62
63
#endif
// LINE_API_MAM_MAP_MARK_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.
map_moment.h
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
matrix.h
Dense matrix and non-owning view.
mmap_lambda.h
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
line::mam
Definition
amap2_adjust_gamma.h:78
line::mam::mmap_normalize
Mmap< T > mmap_normalize(const Mmap< T > &in)
Clamp negative off-diagonal and per-class entries to zero and rebuild D1 and the diagonal of D0 from ...
Definition
mmap_lambda.h:190
line::mam::map_mark
Mmap< T > map_mark(const Map< T > &m, const std::vector< T > &prob)
MMAP with the same inter-arrival process and arrivals marked by prob.
Definition
map_mark.h:38
line
Definition
aoi_dist2ph.h:52
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::Mmap
An MMAP: the underlying MAP plus the per-class arrival matrices.
Definition
mmap_lambda.h:45
line::mam::Mmap::D0
Matrix< T > D0
Definition
mmap_lambda.h:46
line::mam::Mmap::D1
Matrix< T > D1
Definition
mmap_lambda.h:47
line::mam::Mmap::Dc
std::vector< Matrix< T > > Dc
per-class matrices, sum_c Dc = D1
Definition
mmap_lambda.h:48
line::num_traits
Definition
number.h:111
include
line
api
mam
map_mark.h
Generated by
1.18.0