LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
sim_types.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_SIM_SIM_TYPES_H
6
#define LINE_API_SIM_SIM_TYPES_H
7
8
/**
9
* @file
10
* @ingroup api_sim
11
* Shared arithmetic helpers for the templated simulation output-analysis port.
12
*
13
* This family is the port of matlab/src/api/sim/ (jline.api.sim,
14
* line_solver.api.sim). The domain is named for the statistics of a simulation
15
* output process rather than for any queueing model: nothing in it takes a
16
* NetworkStruct, the input is a sequence of observations such as successive
17
* waiting times exported from a simulation run. It was called `oa`, for output
18
* analysis, in all four codebases until 2026-07-31, so older commits, log
19
* entries and manuals name it that way. This header holds the same role
20
* npfqn_types.h plays for the traffic approximations; no algorithm lives here.
21
*
22
* ARITHMETIC. Every function in this family carries
23
* `static_assert(num_traits<T>::has_transcendental)`, so exact rational
24
* arithmetic is a build error rather than a silent fallback. That is not a
25
* porting shortcut: the standardized time series areas carry the factor
26
* weight/(m sqrt(m)) with the normalizing weight sqrt(12), and the interval
27
* half width is a t quantile times a square root, so the delivered numbers are
28
* irrational in the data. There is nothing for an exact field to preserve.
29
*
30
* The distributional quantiles (normal and Student t) are computed in double
31
* and only then converted to T, exactly as lossn_mci's normal_quantile is: the
32
* significance level alpha and the quantile order p reach these functions as
33
* doubles, so what they determine carries double information and no more,
34
* whatever the working type of the estimator is. The estimator's own
35
* statistical error dwarfs the arithmetic one by many orders of magnitude.
36
*/
37
38
#include <cmath>
39
#include <cstddef>
40
#include <limits>
41
42
#include <boost/math/special_functions/fpclassify.hpp>
43
44
#include "
line/num/number.h
"
45
#include "
line/util/error.h
"
46
47
namespace
line
{
48
namespace
sim
{
49
50
namespace
detail {
51
52
/** exp(v), resolved by ADL so double, cpp_bin_float and mpfr all work. */
53
template
<
class
T>
54
inline
T num_exp(
const
T& v) {
55
using
std::exp;
56
return
exp(v);
57
}
58
59
/** sqrt(v), resolved by ADL. */
60
template
<
class
T>
61
inline
T num_sqrt(
const
T& v) {
62
using
std::sqrt;
63
return
sqrt(v);
64
}
65
66
/** base^exponent for a real-valued exponent, resolved by ADL. */
67
template
<
class
T>
68
inline
T num_pow(
const
T& base,
const
T& exponent) {
69
using
std::pow;
70
return
pow(base, exponent);
71
}
72
73
/** MATLAB isfinite: false for +-Inf and NaN. */
74
template
<
class
T>
75
inline
bool
num_isfinite(
const
T& v) {
76
return
boost::math::isfinite(v);
77
}
78
79
/** MATLAB isnan. */
80
template
<
class
T>
81
inline
bool
num_isnan(
const
T& v) {
82
return
boost::math::isnan(v);
83
}
84
85
/**
86
* MATLAB's NaN as a value of T. This family returns it where the reference
87
* does, i.e. for a variance-parameter estimator with no degrees of freedom and
88
* for a refused interval under force = false; a caller must test it rather than
89
* read the field as a number.
90
*/
91
template
<
class
T>
92
inline
T num_nan() {
93
return
num_traits<T>::from_double(std::numeric_limits<double>::quiet_NaN());
94
}
95
96
}
// namespace detail
97
98
}
// namespace sim
99
}
// namespace line
100
101
#endif
// LINE_API_SIM_SIM_TYPES_H
error.h
The exception types the port throws.
line::sim
Definition
sim_dist.h:44
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
include
line
api
sim
sim_types.h
Generated by
1.18.0