LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_bounds.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_BOUNDS_H
6
#define LINE_API_FJ_BOUNDS_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Upper and lower bounds on the mean response time of a K-way fork-join system
12
* of M/M/1 branches.
13
*
14
* Templated port of matlab/src/api/fj/fj_bounds.m, cross-checked against
15
* jar/src/main/java/jline/api/fj/FJ_bounds.java (identical).
16
*
17
* Rmax = H_K / (mu (1 - rho)) (Thomasian 2014, Eq. 1)
18
* Rmin = (1/mu) [ H_K + sum_{j=1..K} (1/j) rho/(j - rho) ] (Eq. 2)
19
*
20
* Both are rational functions of rho = lambda/mu, so the pair is exact in the
21
* field. That matters because the bounds are meant to bracket the true mean:
22
* a rounded Rmin can exceed a rounded Rmax when the two are close, which the
23
* exact instantiation never does.
24
*/
25
26
#include "
line/api/fj/fj_harmonic.h
"
27
#include "
line/api/fj/fj_types.h
"
28
#include "
line/num/number.h
"
29
#include "
line/util/error.h
"
30
31
namespace
line
{
32
namespace
fj
{
33
34
/**
35
* @brief Upper and lower bounds on the mean response time of a K-way
36
* fork-join system of M/M/1 branches.
37
*
38
* @param K number of parallel branches, K >= 1
39
* @param lambda arrival rate
40
* @param mu per-branch service rate, mu > lambda for stability
41
* @return Rmax (pessimistic) and Rmin (optimistic) bounds
42
*/
43
template
<
class
T>
44
FJBoundsResult<T>
fj_bounds
(
unsigned
K,
const
T& lambda,
const
T& mu) {
45
detail::require_positive_K(K,
"fj_bounds"
);
46
const
T one =
num_traits<T>::from_int
(1);
47
const
T rho = lambda / mu;
48
if
(rho >= one)
throw
NumericError
(
"fj_bounds: unstable system, rho = lambda/mu >= 1"
);
49
50
const
T H_K =
fj_harmonic<T>
(K);
51
const
T Rmax = H_K / (mu * (one - rho));
52
53
T S_K =
num_traits<T>::from_int
(0);
54
for
(
unsigned
j = 1; j <= K; ++j) {
55
const
T jj =
num_traits<T>::from_int
(
static_cast<
long
>
(j));
56
S_K += (one / jj) * (rho / (jj - rho));
57
}
58
const
T Rmin = (one / mu) * (H_K + S_K);
59
return
{Rmax, Rmin};
60
}
61
62
}
// namespace fj
63
}
// namespace line
64
65
#endif
// LINE_API_FJ_BOUNDS_H
line::NumericError::NumericError
NumericError(const std::string &what)
Definition
error.h:45
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_bounds
FJBoundsResult< T > fj_bounds(unsigned K, const T &lambda, const T &mu)
Upper and lower bounds on the mean response time of a K-way fork-join system of M/M/1 branches.
Definition
fj_bounds.h:44
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::FJBoundsResult
[Rmax, Rmin] of fj_bounds: pessimistic and optimistic response-time bounds.
Definition
fj_types.h:48
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_bounds.h
Generated by
1.18.0