LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
aph2_assemble.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_ASSEMBLE_H
6#define LINE_API_MAM_APH2_ASSEMBLE_H
7
8/**
9 * @file
10 * @ingroup api_mam
11 * Assemble an APH(2) from its canonical parameters
12 * (matlab/lib/m3a/m3a/aph2/aph2_assemble.m).
13 *
14 * l1 and l2 are the MEAN holding times of the two phases (not rates) and p1
15 * is the probability of continuing from phase 1 to phase 2:
16 *
17 * D0 = [ -1/l1 p1/l1 ; 0 -1/l2 ]
18 * D1 = [ (1-p1)/l1 0 ; 1/l2 0 ]
19 *
20 * Pure field arithmetic -- four reciprocals and three products -- so this is
21 * exact at Rational and is deliberately NOT gated on transcendental
22 * arithmetic. The moment-matching step that produces l1, l2, p1 is the part
23 * that needs a square root; see aph2_fitall.h.
24 */
25
27#include "line/num/number.h"
28#include "line/util/error.h"
29#include "line/util/matrix.h"
30
31namespace line {
32namespace mam {
33
34/** APH(2) with phase means l1, l2 and continuation probability p1. */
35template <class T>
36Map<T> aph2_assemble(const T& l1, const T& l2, const T& p1) {
37 const T zero = num_traits<T>::from_int(0);
38 const T one = num_traits<T>::from_int(1);
39 if (l1 == zero || l2 == zero) throw InputError("aph2_assemble: zero phase mean");
40 Map<T> m;
41 m.D0 = Matrix<T>(2, 2, zero);
42 m.D1 = Matrix<T>(2, 2, zero);
43 m.D0(0, 0) = -one / l1;
44 m.D0(0, 1) = p1 / l1;
45 m.D0(1, 1) = -one / l2;
46 m.D1(0, 0) = (one - p1) / l1;
47 m.D1(1, 0) = one / l2;
48 return m;
49}
50
51} // namespace mam
52} // namespace line
53
54#endif // LINE_API_MAM_APH2_ASSEMBLE_H
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
Map< T > aph2_assemble(const T &l1, const T &l2, const T &p1)
APH(2) with phase means l1, l2 and continuation probability p1.
Number-type abstraction for the templated API port.
A MAP as the pair of matrices (D0, D1).
Definition map_moment.h:53
Matrix< T > D1
Definition map_moment.h:55
Matrix< T > D0
Definition map_moment.h:54