LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_gk_bound.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_GK_BOUND_H
6
#define LINE_API_FJ_GK_BOUND_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* G(K) factors for the standardized-maximum approximation X_K^max ~ mu + sigma G(K).
12
*
13
* Templated port of matlab/src/api/fj/fj_gk_bound.m. The JAR carries the same
14
* four values in jline.api.fj.GKBoundResult, computed inside
15
* FJ_xmax.fj_xmax_approx (identical formulas).
16
*
17
* exponential: G(K) = H_K - 1
18
* uniform: G(K) = sqrt(3) (K-1)/(K+1)
19
* evd: G(K) = sqrt(6) ln(K) / pi
20
* upper bound: G(K) = (K-1)/sqrt(2K-1) (David 1970)
21
*
22
* static_assert(num_traits<T>::has_transcendental) -- three of the four
23
* involve sqrt or log, so the struct as a whole is only defined for the
24
* inexact number types. The exponential entry alone is rational and is
25
* reachable exactly through fj_harmonic.
26
*/
27
28
#include "
line/api/fj/fj_harmonic.h
"
29
#include "
line/api/fj/fj_types.h
"
30
#include "
line/num/number.h
"
31
#include "
line/util/error.h
"
32
33
namespace
line
{
34
namespace
fj
{
35
36
/**
37
* @brief G(K) factors for the standardized-maximum approximation X_K^max ~ mu
38
* + sigma G(K).
39
*
40
* @param K number of branches, K >= 1
41
* @return all four G(K) factors, matching MATLAB's 'all' mode
42
*/
43
template
<
class
T>
44
FJGKBoundResult<T>
fj_gk_bound
(
unsigned
K) {
45
static_assert
(
num_traits<T>::has_transcendental
,
46
"fj_gk_bound requires transcendental arithmetic"
);
47
detail::require_positive_K(K,
"fj_gk_bound"
);
48
const
T one =
num_traits<T>::from_int
(1);
49
const
T Kt =
num_traits<T>::from_int
(
static_cast<
long
>
(K));
50
FJGKBoundResult<T>
r;
51
r.
K
= K;
52
r.
exponential
=
fj_harmonic<T>
(K) - one;
53
r.
uniform
= detail::num_sqrt(T(
num_traits<T>::from_int
(3))) * (Kt - one) / (Kt + one);
54
r.
evd
= detail::num_sqrt(T(
num_traits<T>::from_int
(6))) * detail::num_log(Kt) / detail::num_pi<T>();
55
r.
upper_bound
= (Kt - one) / detail::num_sqrt(T(
num_traits<T>::from_int
(2) * Kt - one));
56
return
r;
57
}
58
59
/** Single-family accessor, matching MATLAB's 'exp'/'uniform'/'evd'/'bound' modes. */
60
template
<
class
T>
61
T
fj_gk_bound
(
unsigned
K,
FJDistType
type) {
62
const
FJGKBoundResult<T>
all =
fj_gk_bound<T>
(K);
63
switch
(type) {
64
case
FJDistType::Exp
:
return
all.
exponential
;
65
case
FJDistType::Uniform
:
return
all.
uniform
;
66
case
FJDistType::Evd
:
return
all.
evd
;
67
case
FJDistType::Bound
:
return
all.
upper_bound
;
68
}
69
throw
InputError
(
"fj_gk_bound: unknown distribution type"
);
70
}
71
72
}
// namespace fj
73
}
// namespace line
74
75
#endif
// LINE_API_FJ_GK_BOUND_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
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::FJDistType
FJDistType
Distribution families for which a G(K) standardized-maximum factor exists.
Definition
fj_types.h:41
line::fj::FJDistType::Bound
@ Bound
Definition
fj_types.h:41
line::fj::FJDistType::Evd
@ Evd
Definition
fj_types.h:41
line::fj::FJDistType::Exp
@ Exp
Definition
fj_types.h:41
line::fj::FJDistType::Uniform
@ Uniform
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::FJGKBoundResult
All four G(K) factors of fj_gk_bound in its 'all' mode.
Definition
fj_types.h:62
line::fj::FJGKBoundResult::exponential
T exponential
Definition
fj_types.h:64
line::fj::FJGKBoundResult::upper_bound
T upper_bound
Definition
fj_types.h:67
line::fj::FJGKBoundResult::uniform
T uniform
Definition
fj_types.h:65
line::fj::FJGKBoundResult::K
unsigned K
Definition
fj_types.h:63
line::fj::FJGKBoundResult::evd
T evd
Definition
fj_types.h:66
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_gk_bound.h
Generated by
1.18.0