LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_xmax_hz.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_HZ_H
6
#define LINE_API_FJ_XMAX_HZ_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Harrison-Zertal approximation of the maximum of i.i.d. variables.
12
*
13
* Templated port of matlab/src/api/fj/fj_xmax_hz.m.
14
*
15
* X_K^max ~ m1 + ( m2 / (2 m1) ) ( H_K - 1 )
16
*
17
* The correction is the equilibrium mean of the branch law scaled by H_K - 1:
18
* one branch, plus the residual work still owed by the branches that finish
19
* later. Writing m2/(2 m1) = m1 (1+SCV)/2 shows it is exact for the exponential
20
* and reduces to m1 at K = 1 for every branch law.
21
*/
22
23
#include "
line/api/fj/fj_harmonic.h
"
24
#include "
line/api/fj/fj_types.h
"
25
#include "
line/num/number.h
"
26
#include "
line/util/error.h
"
27
28
namespace
line
{
29
namespace
fj
{
30
31
/** [Xmax, resid] of fj_xmax_hz. */
32
template
<
class
T>
33
struct
FJXmaxHzResult
{
34
T
Xmax
;
35
T
resid
;
36
};
37
38
/**
39
* @brief Harrison-Zertal approximation of the maximum of i.i.d. variables.
40
*
41
* @param m1 mean of the branch distribution, m1 > 0
42
* @param m2 second moment of the branch distribution, m2 >= m1^2
43
* @param K number of branches, K >= 1
44
* @return the approximate expected maximum and the equilibrium mean used
45
*/
46
template
<
class
T>
47
FJXmaxHzResult<T>
fj_xmax_hz
(
const
T& m1,
const
T& m2,
unsigned
K) {
48
const
T zero =
num_traits<T>::from_int
(0), two =
num_traits<T>::from_int
(2);
49
if
(!(m1 > zero))
throw
InputError
(
"fj_xmax_hz: the branch mean must be positive"
);
50
if
(m2 < m1 * m1)
51
throw
InputError
(
"fj_xmax_hz: the second moment is below the square of the mean"
);
52
detail::require_positive_K(K,
"fj_xmax_hz"
);
53
FJXmaxHzResult<T>
out;
54
out.
resid
= m2 / (two * m1);
55
out.
Xmax
= m1 + out.
resid
* (
fj_harmonic<T>
(K) -
num_traits<T>::from_int
(1));
56
return
out;
57
}
58
59
}
// namespace fj
60
}
// namespace line
61
62
#endif
// LINE_API_FJ_XMAX_HZ_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_xmax_hz
FJXmaxHzResult< T > fj_xmax_hz(const T &m1, const T &m2, unsigned K)
Harrison-Zertal approximation of the maximum of i.i.d.
Definition
fj_xmax_hz.h:47
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::FJXmaxHzResult
[Xmax, resid] of fj_xmax_hz.
Definition
fj_xmax_hz.h:33
line::fj::FJXmaxHzResult::Xmax
T Xmax
Definition
fj_xmax_hz.h:34
line::fj::FJXmaxHzResult::resid
T resid
Definition
fj_xmax_hz.h:35
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_xmax_hz.h
Generated by
1.18.0