LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sn_has_bursty_arrival.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_SN_SN_HAS_BURSTY_ARRIVAL_H
6#define LINE_API_SN_SN_HAS_BURSTY_ARRIVAL_H
7
8/**
9 * @file
10 * @ingroup api_sn
11 * Port of matlab/src/api/sn/sn_has_bursty_arrival.m.
12 *
13 * True iff some external (Source) arrival process is non-renewal (bursty). A MAP
14 * (D0, D1) is renewal iff D1 equals its rank-one renewal form t0*pie, with
15 * t0 = -D0 e = D1 e and pie the embedded stationary vector; any departure from
16 * that form signals correlation between successive inter-arrival times. A
17 * single-phase arrival (Poisson) is renewal by construction. This is the exact
18 * test SolverMVA.resolveMethod uses to upgrade method='default' to 'rqna'.
19 *
20 * ARITHMETIC: field. map_pie is a linear solve; no transcendental appears.
21 */
22
23#include <cmath>
24#include <cstddef>
25
29#include "line/num/number.h"
30
31namespace line {
32namespace api {
33
34template <class T>
36 for (std::size_t i = 0; i < sn.nstations; ++i) {
37 if (sn.stations[i].nodetype != qn::NodeType::Source) continue;
38 for (std::size_t r = 0; r < sn.nclasses; ++r) {
39 if (!sn.disabled.empty() && sn.disabled[i][r]) continue;
40 const lang::Distrib<T>& d = sn.service[i][r];
41 if (d.disabled || !d.has_map()) continue;
42 // Read the (D0, D1) pair directly rather than via dist_to_map: a
43 // non-MAP arrival is renewal (skipped above), and dist_to_map's
44 // Replayer branch instantiates the transcendental aph_fit, which
45 // would forbid this field-arithmetic predicate under Rational.
47 m.D0 = d.D0;
48 m.D1 = d.D1;
49 const std::size_t n = m.D1.rows();
50 if (n <= 1) continue; // single-phase arrival is Poisson, hence renewal
51 const std::vector<T> pie = mam::map_pie(m);
52 // t0 = D1 e (row sums of D1), renewal form D1ren = t0 * pie.
53 std::vector<T> t0(n, num_traits<T>::from_int(0));
54 for (std::size_t a = 0; a < n; ++a) {
55 T acc = num_traits<T>::from_int(0);
56 for (std::size_t b = 0; b < n; ++b) acc = T(acc + m.D1(a, b));
57 t0[a] = acc;
58 }
59 double diff2 = 0.0, norm2 = 0.0;
60 for (std::size_t a = 0; a < n; ++a)
61 for (std::size_t b = 0; b < n; ++b) {
62 const double dd = num_traits<T>::to_double(m.D1(a, b));
63 const double rr = num_traits<T>::to_double(T(t0[a] * pie[b]));
64 diff2 += (dd - rr) * (dd - rr);
65 norm2 += dd * dd;
66 }
67 if (std::sqrt(diff2) > 1e-8 * std::max(1.0, std::sqrt(norm2))) return true;
68 }
69 }
70 return false;
71}
72
73} // namespace api
74} // namespace line
75
76#endif // LINE_API_SN_SN_HAS_BURSTY_ARRIVAL_H
A network plus its refreshed NetworkStruct.
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
bool sn_has_bursty_arrival(const qn::NetworkStruct< T > &sn)
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
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
bool has_map() const
True when the type carries a (D0,D1) pair of its own.
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
Definition lang_types.h:759
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