LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_xmax_approx.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_FJ_XMAX_APPROX_H
6
#define LINE_API_FJ_XMAX_APPROX_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Two-moment approximation to the expected maximum of K i.i.d. samples,
12
* X_K^max ~ mu_X + sigma_X G(K).
13
*
14
* Templated port of matlab/src/api/fj/fj_xmax_approx.m, cross-checked against
15
* FJ_xmax.fj_xmax_approx in jar/src/main/java/jline/api/fj/FJ_xmax.java
16
* (identical).
17
*
18
* MIXED ARITHMETIC. The exponential family uses G(K) = H_K - 1, which is
19
* rational and exact in any field; the uniform, EVD and bound families need
20
* sqrt or log and are only available when T carries transcendental functions.
21
* Asking for one of those at exact arithmetic throws UnsupportedError.
22
*/
23
24
#include "
line/api/fj/fj_gk_bound.h
"
25
#include "
line/api/fj/fj_harmonic.h
"
26
#include "
line/api/fj/fj_types.h
"
27
#include "
line/num/number.h
"
28
#include "
line/util/error.h
"
29
30
namespace
line
{
31
namespace
fj
{
32
33
/**
34
* @brief Two-moment approximation to the expected maximum of K i.i.d.
35
* samples, X_K^max ~ mu_X + sigma_X G(K).
36
*
37
* @param K number of branches, K >= 1
38
* @param mu_X mean of the branch distribution
39
* @param sigma_X standard deviation of the branch distribution, >= 0
40
* @param type which G(K) family to use
41
* @return [Xmax, GK]
42
*/
43
template
<
class
T>
44
FJXmaxApproxResult<T>
fj_xmax_approx
(
unsigned
K,
const
T& mu_X,
const
T& sigma_X,
45
FJDistType
type =
FJDistType::Exp
) {
46
detail::require_positive_K(K,
"fj_xmax_approx"
);
47
if
(sigma_X <
num_traits<T>::from_int
(0))
48
throw
InputError
(
"fj_xmax_approx: sigma_X must be non-negative"
);
49
50
T GK =
num_traits<T>::from_int
(0);
51
if
(type ==
FJDistType::Exp
) {
52
GK =
fj_harmonic<T>
(K) -
num_traits<T>::from_int
(1);
53
}
else
{
54
if
constexpr
(
num_traits<T>::has_transcendental
) {
55
GK =
fj_gk_bound<T>
(K, type);
56
}
else
{
57
throw
UnsupportedError
(
58
"fj_xmax_approx: only the exponential G(K) is rational; the uniform, EVD and "
59
"bound families need sqrt or log and therefore transcendental arithmetic"
);
60
}
61
}
62
return
{T(mu_X + sigma_X * GK), GK};
63
}
64
65
}
// namespace fj
66
}
// namespace line
67
68
#endif
// LINE_API_FJ_XMAX_APPROX_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
line::UnsupportedError::UnsupportedError
UnsupportedError(const std::string &what)
Definition
error.h:51
error.h
The exception types the port throws.
fj_gk_bound.h
G(K) factors for the standardized-maximum approximation X_K^max ~ mu + sigma G(K).
fj_harmonic.h
Harmonic number H_K = sum_{k=1..K} 1/k.
fj_types.h
Shared return types and arithmetic helpers for the templated fork-join port.
line::fj
Definition
fj_amva.h:34
line::fj::fj_gk_bound
FJGKBoundResult< T > fj_gk_bound(unsigned K)
G(K) factors for the standardized-maximum approximation X_K^max ~ mu.
Definition
fj_gk_bound.h:44
line::fj::fj_xmax_approx
FJXmaxApproxResult< T > fj_xmax_approx(unsigned K, const T &mu_X, const T &sigma_X, FJDistType type=FJDistType::Exp)
Two-moment approximation to the expected maximum of K i.i.d.
Definition
fj_xmax_approx.h:44
line::fj::FJDistType
FJDistType
Distribution families for which a G(K) standardized-maximum factor exists.
Definition
fj_types.h:41
line::fj::FJDistType::Exp
@ Exp
Definition
fj_types.h:41
line::fj::fj_harmonic
T fj_harmonic(unsigned K)
Harmonic number H_K = sum_{k=1..K} 1/k.
Definition
fj_harmonic.h:37
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::fj::FJXmaxApproxResult
[Xmax, GK] of fj_xmax_approx.
Definition
fj_types.h:72
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_xmax_approx.h
Generated by
1.18.0