LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fj_xmax_exp.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_XMAX_EXP_H
6#define LINE_API_FJ_XMAX_EXP_H
7
8/**
9 * @file
10 * @ingroup api_fj
11 * Expected maximum of K i.i.d. exponential service times.
12 *
13 * Templated port of matlab/src/api/fj/fj_xmax_exp.m, cross-checked against
14 * FJ_xmax.fj_xmax_exp in jar/src/main/java/jline/api/fj/FJ_xmax.java
15 * (identical).
16 *
17 * X_K^max = H_K / mu
18 *
19 * Exact in closed form and rational, so this is the oracle the rest of the
20 * xmax family is checked against: fj_xmax_2 at equal rates, fj_xmax_hyperexp
21 * at mu1 = mu2 and fj_xmax_erlang at k = 1 must all reproduce it exactly.
22 */
23
26#include "line/num/number.h"
27#include "line/util/error.h"
28
29namespace line {
30namespace fj {
31
32/**
33 * @brief Expected maximum of K i.i.d. exponential service times.
34 *
35 * @param K number of branches, K >= 1
36 * @param mu branch service rate, mu > 0
37 * @return H_K / mu
38 */
39template <class T>
40T fj_xmax_exp(unsigned K, const T& mu) {
41 detail::require_positive_K(K, "fj_xmax_exp");
42 if (mu <= num_traits<T>::from_int(0)) throw InputError("fj_xmax_exp: the service rate mu must be positive");
43 return fj_harmonic<T>(K) / mu;
44}
45
46} // namespace fj
47} // namespace line
48
49#endif // LINE_API_FJ_XMAX_EXP_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.
T fj_harmonic(unsigned K)
Harmonic number H_K = sum_{k=1..K} 1/k.
Definition fj_harmonic.h:37
T fj_xmax_exp(unsigned K, const T &mu)
Expected maximum of K i.i.d.
Definition fj_xmax_exp.h:40
Number-type abstraction for the templated API port.