LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
pfqn_expand.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_PFQN_EXPAND_H
6
#define LINE_API_PFQN_EXPAND_H
7
8
/**
9
* @file
10
* @ingroup api_pfqn
11
* Expand per-station metrics from a reduced model back to the original
12
* station set.
13
*
14
* Templated port of matlab/src/api/pfqn/pfqn_expand.m. The inverse of
15
* pfqn_unique: row i of each output is row mapping(i) of the corresponding
16
* input, so every station of a replicated group receives the metrics computed
17
* once for its representative.
18
*
19
* Arithmetic: EXACT-CAPABLE. The routine copies values and performs no
20
* arithmetic at all, so it is exact in every arithmetic by construction and
21
* carries no transcendental gate.
22
*/
23
24
#include <cstddef>
25
#include <vector>
26
27
#include "
line/num/number.h
"
28
#include "
line/util/error.h
"
29
#include "
line/util/matrix.h
"
30
31
namespace
line
{
32
namespace
pfqn
{
33
34
/** Return value of pfqn_expand, mirroring [QN_full,UN_full,CN_full]. */
35
template
<
class
T>
36
struct
ExpandResult
{
37
Matrix<T>
QN
;
///< (M x R) queue lengths at the original stations
38
Matrix<T>
UN
;
///< (M x R) utilizations
39
Matrix<T>
CN
;
///< (M x R) residence times
40
};
41
42
/**
43
* @brief Expand per-station metrics from a reduced model back to the original
44
* station set.
45
*
46
* @param QN (M' x R) reduced queue lengths
47
* @param UN (M' x R) reduced utilizations
48
* @param CN (M' x R) reduced residence times
49
* @param mapping (M) 0-based unique-station index per original station
50
*/
51
template
<
class
T>
52
ExpandResult<T>
pfqn_expand
(
const
Matrix<T>
& QN,
const
Matrix<T>
& UN,
const
Matrix<T>
& CN,
53
const
std::vector<std::size_t>& mapping) {
54
const
std::size_t R = QN.cols();
55
const
std::size_t M = mapping.size();
56
if
(UN.rows() != QN.rows() || CN.
rows
() != QN.rows() || UN.cols() != R || CN.
cols
() != R)
57
throw
InputError
(
"pfqn_expand: the three metric matrices have different shapes"
);
58
59
ExpandResult<T>
res;
60
res.
QN
=
Matrix<T>
(M, R);
61
res.
UN
=
Matrix<T>
(M, R);
62
res.
CN
=
Matrix<T>
(M, R);
63
for
(std::size_t i = 0; i < M; ++i) {
64
const
std::size_t u = mapping[i];
65
if
(u >= QN.rows())
throw
InputError
(
"pfqn_expand: mapping index out of range"
);
66
for
(std::size_t j = 0; j < R; ++j) {
67
res.
QN
(i, j) = QN(u, j);
68
res.
UN
(i, j) = UN(u, j);
69
res.
CN
(i, j) = CN(u, j);
70
}
71
}
72
return
res;
73
}
74
75
}
// namespace pfqn
76
}
// namespace line
77
78
#endif
// LINE_API_PFQN_EXPAND_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::Matrix
Matrix()
Definition
matrix.h:58
line::Matrix::rows
std::size_t rows() const
Definition
matrix.h:89
error.h
The exception types the port throws.
matrix.h
Dense matrix and non-owning view.
line::pfqn
Definition
cd_peak_scaling.h:43
line::pfqn::pfqn_expand
ExpandResult< T > pfqn_expand(const Matrix< T > &QN, const Matrix< T > &UN, const Matrix< T > &CN, const std::vector< std::size_t > &mapping)
Expand per-station metrics from a reduced model back to the original station set.
Definition
pfqn_expand.h:52
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::pfqn::ExpandResult
Return value of pfqn_expand, mirroring [QN_full,UN_full,CN_full].
Definition
pfqn_expand.h:36
line::pfqn::ExpandResult::CN
Matrix< T > CN
(M x R) residence times
Definition
pfqn_expand.h:39
line::pfqn::ExpandResult::QN
Matrix< T > QN
(M x R) queue lengths at the original stations
Definition
pfqn_expand.h:37
line::pfqn::ExpandResult::UN
Matrix< T > UN
(M x R) utilizations
Definition
pfqn_expand.h:38
include
line
api
pfqn
pfqn_expand.h
Generated by
1.18.0