LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fj_respt_2way.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_2WAY_H
6#define LINE_API_FJ_RESPT_2WAY_H
7
8/**
9 * @file
10 * @ingroup api_fj
11 * Exact mean response time of a 2-way fork-join system of M/M/1 branches.
12 *
13 * Templated port of matlab/src/api/fj/fj_respt_2way.m, cross-checked against
14 * FJ_respt.fj_respt_2way in jar/src/main/java/jline/api/fj/FJ_respt.java
15 * (identical; the JAR inlines qsys_mm1 as 1/(mu-lambda), which is the same
16 * value MATLAB's qsys_mm1 returns).
17 *
18 * R_2 = (H_2 - rho/8) R(rho) = ((12 - rho)/8) / (mu - lambda)
19 *
20 * Rational in rho, hence exact in the field. This is the only fork-join
21 * response time in the family that is exact rather than an approximation, so
22 * it is the natural calibration point for the approximations around it.
23 */
24
27#include "line/num/number.h"
28#include "line/util/error.h"
29
30namespace line {
31namespace fj {
32
33/**
34 * @brief Exact mean response time of a 2-way fork-join system of M/M/1
35 * branches.
36 *
37 * @param lambda arrival rate
38 * @param mu per-branch service rate
39 * @return mean 2-way fork-join response time
40 */
41template <class T>
42T fj_respt_2way(const T& lambda, const T& mu) {
43 const T one = num_traits<T>::from_int(1);
44 const T rho = lambda / mu;
45 if (rho >= one) throw NumericError("fj_respt_2way: unstable system, rho = lambda/mu >= 1");
46 const T R_rho = qsys::qsys_mm1(lambda, mu).W;
47 return (num_traits<T>::from_int(12) - rho) / num_traits<T>::from_int(8) * R_rho;
48}
49
50} // namespace fj
51} // namespace line
52
53#endif // LINE_API_FJ_RESPT_2WAY_H
NumericError(const std::string &what)
Definition error.h:45
The exception types the port throws.
Shared return types and arithmetic helpers for the templated fork-join port.
T fj_respt_2way(const T &lambda, const T &mu)
Exact mean response time of a 2-way fork-join system of M/M/1 branches.
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
Number-type abstraction for the templated API port.
Exact mean response time of the M/M/1 queue.