LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_respt_vm.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_VM_H
6
#define LINE_API_FJ_RESPT_VM_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Varma-Makowski light-traffic interpolation for the mean response time of a
12
* K-way fork-join system of M/M/1 branches.
13
*
14
* Templated port of matlab/src/api/fj/fj_respt_vm.m, cross-checked against
15
* FJ_respt.fj_respt_vm in jar/src/main/java/jline/api/fj/FJ_respt.java
16
* (identical).
17
*
18
* R_K = [ H_K + (A_K - H_K) rho ] / (mu - lambda)
19
* A_K = sum_{i=1..K} C(K,i) (-1)^{i-1} sum_{m=1..i} C(i,m) (m-1)! / i^{m+1}
20
*
21
* Every term is rational, so the whole interpolation is exact in the field.
22
* A_K is an alternating sum of binomial coefficients: at K = 30 the largest
23
* term is about 1e8 times the result, so in double roughly eight significant
24
* digits are lost to cancellation and by K = 60 nothing is left. The exact
25
* instantiation is the only way to evaluate A_K at those K, and the only way
26
* to measure the loss in the double one.
27
*/
28
29
#include "
line/api/fj/fj_harmonic.h
"
30
#include "
line/api/fj/fj_types.h
"
31
#include "
line/num/number.h
"
32
#include "
line/util/error.h
"
33
34
namespace
line
{
35
namespace
fj
{
36
37
/**
38
* @brief Varma-Makowski light-traffic interpolation for the mean response
39
* time of a K-way fork-join system of M/M/1 branches.
40
*
41
* @param K number of parallel branches, K >= 1
42
* @param lambda arrival rate
43
* @param mu per-branch service rate
44
* @return approximate mean fork-join response time
45
*/
46
template
<
class
T>
47
T
fj_respt_vm
(
unsigned
K,
const
T& lambda,
const
T& mu) {
48
detail::require_positive_K(K,
"fj_respt_vm"
);
49
const
T one =
num_traits<T>::from_int
(1);
50
const
T rho = lambda / mu;
51
if
(rho >= one)
throw
NumericError
(
"fj_respt_vm: unstable system, rho = lambda/mu >= 1"
);
52
53
const
T H_K =
fj_harmonic<T>
(K);
54
T A_K =
num_traits<T>::from_int
(0);
55
for
(
unsigned
i = 1; i <= K; ++i) {
56
const
T ii =
num_traits<T>::from_int
(
static_cast<
long
>
(i));
57
T inner =
num_traits<T>::from_int
(0);
58
for
(
unsigned
m = 1; m <= i; ++m)
59
inner += detail::fj_binom<T>(i, m) *
num_factorial<T>
(m - 1) /
num_pow_int
(ii, m + 1);
60
const
T term = detail::fj_binom<T>(K, i) * inner;
61
if
((i - 1) % 2 == 0) A_K += term;
62
else
A_K -= term;
63
}
64
return
(H_K + (A_K - H_K) * rho) / (mu - lambda);
65
}
66
67
}
// namespace fj
68
}
// namespace line
69
70
#endif
// LINE_API_FJ_RESPT_VM_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_vm
T fj_respt_vm(unsigned K, const T &lambda, const T &mu)
Varma-Makowski light-traffic interpolation for the mean response time of a K-way fork-join system of ...
Definition
fj_respt_vm.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
line::num_factorial
T num_factorial(unsigned n)
Factorial as a value of T.
Definition
number.h:184
line::num_pow_int
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition
number.h:192
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_respt_vm.h
Generated by
1.18.0