LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_synch_delay.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_SYNCH_DELAY_H
6
#define LINE_API_FJ_SYNCH_DELAY_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Mean synchronization delay of a 2-way fork-join system of M/M/1 branches,
12
* i.e. the time the first-finishing branch waits at the join.
13
*
14
* Templated port of matlab/src/api/fj/fj_synch_delay.m, cross-checked against
15
* jar/src/main/java/jline/api/fj/FJ_synch_delay.java (identical).
16
*
17
* S_2 = (1/2)(1 - rho/4) R(rho)
18
*
19
* Rational in rho, hence exact in the field. It satisfies
20
* R_2 = R + S_2 exactly, which is the identity worth checking: both sides are
21
* exact rationals, so any discrepancy is a port error and not a rounding one.
22
*/
23
24
#include "
line/api/fj/fj_types.h
"
25
#include "
line/api/qsys/qsys_mm1.h
"
26
#include "
line/num/number.h
"
27
#include "
line/util/error.h
"
28
29
namespace
line
{
30
namespace
fj
{
31
32
/**
33
* @brief Mean synchronization delay of a 2-way fork-join system of M/M/1
34
* branches, i.e. the time the first-finishing branch waits at the join.
35
*
36
* @param lambda arrival rate
37
* @param mu per-branch service rate
38
* @return mean synchronization delay
39
*/
40
template
<
class
T>
41
T
fj_synch_delay
(
const
T& lambda,
const
T& mu) {
42
const
T one =
num_traits<T>::from_int
(1);
43
const
T rho = lambda / mu;
44
if
(rho >= one)
throw
NumericError
(
"fj_synch_delay: unstable system, rho = lambda/mu >= 1"
);
45
const
T R_rho =
qsys::qsys_mm1
(lambda, mu).W;
46
return
num_traits<T>::from_rational
(1, 2) * (one - rho /
num_traits<T>::from_int
(4)) * R_rho;
47
}
48
49
}
// namespace fj
50
}
// namespace line
51
52
#endif
// LINE_API_FJ_SYNCH_DELAY_H
line::NumericError::NumericError
NumericError(const std::string &what)
Definition
error.h:45
error.h
The exception types the port throws.
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_synch_delay
T fj_synch_delay(const T &lambda, const T &mu)
Mean synchronization delay of a 2-way fork-join system of M/M/1 branches, i.e.
Definition
fj_synch_delay.h:41
line::qsys::qsys_mm1
QsysResult< T > qsys_mm1(const T &lambda, const T &mu)
Exact mean response time of the M/M/1 queue.
Definition
qsys_mm1.h:35
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
qsys_mm1.h
Exact mean response time of the M/M/1 queue.
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_synch_delay.h
Generated by
1.18.0