LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fj_respt_closed.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_CLOSED_H
6#define LINE_API_FJ_RESPT_CLOSED_H
7
8/**
9 * @file
10 * @ingroup api_fj
11 * Varki bound on the residence time of a closed fork-join subnetwork.
12 *
13 * Templated port of matlab/src/api/fj/fj_respt_closed.m.
14 *
15 * R_{P_K}(M) <= x [ H_K + A ]
16 *
17 * with A the mean number of jobs an arriving job finds at the subnetwork. In a
18 * closed network made of the parallel subsystem alone every other job is
19 * necessarily inside it, so A = M-1 and the bound is tight at K = 2.
20 */
21
24#include "line/num/number.h"
25#include "line/util/error.h"
26
27namespace line {
28namespace fj {
29
30/** [R, exact] of fj_respt_closed. */
31template <class T>
33 T R;
34 bool exact;
35};
36
37/**
38 * @brief Varki bound on the residence time of a closed fork-join subnetwork.
39 *
40 * @param K number of parallel branches, K >= 1
41 * @param x mean service time of each branch
42 * @param M number of circulating jobs, M >= 1
43 * @param A mean queue length seen on arrival
44 * @return the bound and whether it is known to be tight
45 */
46template <class T>
47FJResptClosedResult<T> fj_respt_closed(unsigned K, const T& x, unsigned M, const T& A) {
48 detail::require_positive_K(K, "fj_respt_closed");
49 const T zero = num_traits<T>::from_int(0);
50 if (!(x > zero)) throw InputError("fj_respt_closed: the mean service time must be positive");
51 if (M < 1) throw InputError("fj_respt_closed: M must be a positive integer");
52 if (A < zero)
53 throw InputError("fj_respt_closed: the arrival-instant queue length must be non-negative");
55 out.R = x * (fj_harmonic<T>(K) + A);
56 out.exact = false;
57 return out;
58}
59
60/**
61 * The isolated parallel subsystem of Theorem 4.1, where A = M-1.
62 *
63 * @param K number of parallel branches, K >= 1
64 * @param x mean service time of each branch
65 * @param M number of circulating jobs, M >= 1
66 * @return the bound, flagged exact at K = 2
67 */
68template <class T>
69FJResptClosedResult<T> fj_respt_closed(unsigned K, const T& x, unsigned M) {
70 if (M < 1) throw InputError("fj_respt_closed: M must be a positive integer");
72 fj_respt_closed<T>(K, x, M, num_traits<T>::from_int(static_cast<long>(M) - 1));
73 out.exact = (K == 2);
74 return out;
75}
76
77} // namespace fj
78} // namespace line
79
80#endif // LINE_API_FJ_RESPT_CLOSED_H
InputError(const std::string &what)
Definition error.h:39
The exception types the port throws.
Harmonic number H_K = sum_{k=1..K} 1/k.
Shared return types and arithmetic helpers for the templated fork-join port.
FJResptClosedResult< T > fj_respt_closed(unsigned K, const T &x, unsigned M, const T &A)
Varki bound on the residence time of a closed fork-join subnetwork.
T fj_harmonic(unsigned K)
Harmonic number H_K = sum_{k=1..K} 1/k.
Definition fj_harmonic.h:37
Number-type abstraction for the templated API port.
[R, exact] of fj_respt_closed.