LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fj_respt_nosplit.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_NOSPLIT_H
6#define LINE_API_FJ_RESPT_NOSPLIT_H
7
8/**
9 * @file
10 * @ingroup api_fj
11 * Mean response time of the distributed no-splitting parallel system.
12 *
13 * Templated port of matlab/src/api/fj/fj_respt_nosplit.m.
14 *
15 * A job of K tasks is routed in one piece to a single server chosen uniformly
16 * among the K, so each server is an M/E_K/1 queue of arrival rate lambda/K and
17 * service the sum of K exponential stages of rate mu. Pollaczek-Khinchine then
18 * reduces to
19 *
20 * R = [ K - (K-1) rho/2 ] / (mu - lambda), rho = lambda/mu,
21 *
22 * the reference against which the splitting policies are judged. At K = 1 it
23 * collapses to the M/M/1 response time.
24 */
25
27#include "line/num/number.h"
28#include "line/util/error.h"
29
30namespace line {
31namespace fj {
32
33/** [R, rho] of fj_respt_nosplit. */
34template <class T>
36 T R;
37 T rho;
38};
39
40/**
41 * @brief Mean response time of the distributed no-splitting parallel system.
42 *
43 * @param K number of servers, equal to the number of tasks per job
44 * @param lambda total job arrival rate
45 * @param mu per-server task service rate, mu > lambda
46 * @return the mean job response time and the per-server utilization
47 */
48template <class T>
49FJResptNosplitResult<T> fj_respt_nosplit(unsigned K, const T& lambda, const T& mu) {
50 detail::require_positive_K(K, "fj_respt_nosplit");
51 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1),
53 if (!(lambda > zero)) throw InputError("fj_respt_nosplit: the arrival rate must be positive");
54 if (!(mu > zero)) throw InputError("fj_respt_nosplit: the service rate must be positive");
55
57 out.rho = lambda / mu;
58 if (out.rho >= one)
59 throw NumericError("fj_respt_nosplit: unstable system, rho = lambda/mu >= 1");
60 const T Kt = num_traits<T>::from_int(static_cast<long>(K));
61 // M/M/1 response time at the same utilization
62 const T Rmm1 = one / (mu - lambda);
63 out.R = (Kt - (Kt - one) * out.rho / two) * Rmm1;
64 return out;
65}
66
67} // namespace fj
68} // namespace line
69
70#endif // LINE_API_FJ_RESPT_NOSPLIT_H
InputError(const std::string &what)
Definition error.h:39
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.
FJResptNosplitResult< T > fj_respt_nosplit(unsigned K, const T &lambda, const T &mu)
Mean response time of the distributed no-splitting parallel system.
Number-type abstraction for the templated API port.
[R, rho] of fj_respt_nosplit.