LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_respt_varki.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_VARKI_H
6
#define LINE_API_FJ_RESPT_VARKI_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Varki approximation to the mean response time of a K-way fork-join system of
12
* M/M/1 branches.
13
*
14
* Templated port of matlab/src/api/fj/fj_respt_varki.m, cross-checked against
15
* FJ_respt.fj_respt_varki in jar/src/main/java/jline/api/fj/FJ_respt.java
16
* (identical).
17
*
18
* R_K = (1/mu) [ H_K + rho/(2(1-rho)) ( S1 + (1-2 rho) S2 ) ]
19
* S1 = sum_{i=1..K} 1/(i - rho), S2 = sum_{i=1..K} 1/(i (i - rho))
20
*
21
* Rational in rho, hence exact in the field. Note that the denominators i - rho
22
* are positive for every i >= 1 whenever rho < 1, so the only pole is at
23
* rho = 1.
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 Varki approximation to the mean response time of a K-way fork-join
36
* 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
41
* @return approximate mean fork-join response time
42
*/
43
template
<
class
T>
44
T
fj_respt_varki
(
unsigned
K,
const
T& lambda,
const
T& mu) {
45
detail::require_positive_K(K,
"fj_respt_varki"
);
46
const
T one =
num_traits<T>::from_int
(1), two =
num_traits<T>::from_int
(2);
47
const
T rho = lambda / mu;
48
if
(rho >= one)
throw
NumericError
(
"fj_respt_varki: unstable system, rho = lambda/mu >= 1"
);
49
50
const
T H_K =
fj_harmonic<T>
(K);
51
T S1 =
num_traits<T>::from_int
(0), S2 =
num_traits<T>::from_int
(0);
52
for
(
unsigned
i = 1; i <= K; ++i) {
53
const
T ii =
num_traits<T>::from_int
(
static_cast<
long
>
(i));
54
S1 += one / (ii - rho);
55
S2 += one / (ii * (ii - rho));
56
}
57
return
(one / mu) * (H_K + (rho / (two * (one - rho))) * (S1 + (one - two * rho) * S2));
58
}
59
60
}
// namespace fj
61
}
// namespace line
62
63
#endif
// LINE_API_FJ_RESPT_VARKI_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_respt_varki
T fj_respt_varki(unsigned K, const T &lambda, const T &mu)
Varki approximation to the mean response time of a K-way fork-join system of M/M/1 branches.
Definition
fj_respt_varki.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::num_traits
Definition
number.h:111
include
line
api
fj
fj_respt_varki.h
Generated by
1.18.0