LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_respt_nt.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_RESPT_NT_H
6
#define LINE_API_FJ_RESPT_NT_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Nelson-Tantawi approximation to the mean response time of a K-way fork-join
12
* system of M/M/1 branches.
13
*
14
* Templated port of matlab/src/api/fj/fj_respt_nt.m, cross-checked against
15
* FJ_respt.fj_respt_nt in jar/src/main/java/jline/api/fj/FJ_respt.java
16
* (identical apart from the K > 32 accuracy warning, which MATLAB emits and
17
* neither the JAR nor this port does).
18
*
19
* R_K = [ H_K/H_2 + (1 - H_K/H_2) 4 rho/11 ] (3/2 - rho/8) / (mu - lambda)
20
*
21
* Rational in rho, hence exact in the field. At K = 2 it reduces exactly to
22
* fj_respt_2way, an identity that only holds bit-for-bit in exact arithmetic.
23
*/
24
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 Nelson-Tantawi approximation to the mean response time of a K-way
35
* fork-join system of M/M/1 branches.
36
*
37
* @param K number of parallel branches, K >= 2
38
* @param lambda arrival rate
39
* @param mu per-branch service rate
40
* @return approximate mean fork-join response time
41
*/
42
template
<
class
T>
43
T
fj_respt_nt
(
unsigned
K,
const
T& lambda,
const
T& mu) {
44
if
(K < 2)
throw
InputError
(
"fj_respt_nt: the Nelson-Tantawi approximation requires K >= 2"
);
45
const
T one =
num_traits<T>::from_int
(1);
46
const
T rho = lambda / mu;
47
if
(rho >= one)
throw
NumericError
(
"fj_respt_nt: unstable system, rho = lambda/mu >= 1"
);
48
49
const
T H_K =
fj_harmonic<T>
(K);
50
const
T H_2 =
fj_harmonic<T>
(2);
51
const
T ratio = H_K / H_2;
52
const
T S_K = ratio + (one - ratio) * (
num_traits<T>::from_int
(4) * rho /
num_traits<T>::from_int
(11));
53
const
T R2f =
num_traits<T>::from_rational
(3, 2) - rho /
num_traits<T>::from_int
(8);
54
return
S_K * R2f / (mu - lambda);
55
}
56
57
}
// namespace fj
58
}
// namespace line
59
60
#endif
// LINE_API_FJ_RESPT_NT_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
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_harmonic
T fj_harmonic(unsigned K)
Harmonic number H_K = sum_{k=1..K} 1/k.
Definition
fj_harmonic.h:37
line::fj::fj_respt_nt
T fj_respt_nt(unsigned K, const T &lambda, const T &mu)
Nelson-Tantawi approximation to the mean response time of a K-way fork-join system of M/M/1 branches.
Definition
fj_respt_nt.h:43
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_respt_nt.h
Generated by
1.18.0