LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
qsys_mm1.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_QSYS_MM1_H
6#define LINE_API_QSYS_MM1_H
7
8/**
9 * @file
10 * @ingroup api_qsys
11 * Exact mean response time of the M/M/1 queue.
12 *
13 * Templated port of matlab/src/api/qsys/qsys_mm1.m, cross-checked against
14 * jar/src/main/java/jline/api/qsys/Qsys_mm1.java (identical).
15 *
16 * rho = lambda/mu, W = rho/(1-rho)/lambda
17 *
18 * Pure field arithmetic, so the function is exact for T = Rational.
19 */
20
22#include "line/num/number.h"
23
24namespace line {
25namespace qsys {
26
27/**
28 * @brief Exact mean response time of the M/M/1 queue.
29 *
30 * @param lambda arrival rate
31 * @param mu service rate
32 * @return W = mean response time, rhohat = rho (MATLAB returns the true rho here)
33 */
34template <class T>
35QsysResult<T> qsys_mm1(const T& lambda, const T& mu) {
36 const T one = num_traits<T>::from_int(1);
37 const T rho = lambda / mu;
38 detail::require_no_pole(T(one - rho), "qsys_mm1");
39 const T W = rho / (one - rho) / lambda;
40 return {W, rho};
41}
42
43} // namespace qsys
44} // namespace line
45
46#endif // LINE_API_QSYS_MM1_H
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.
Shared return type and arithmetic helpers for the templated qsys port.
Return value of the qsys family, mirroring MATLAB's [W,rhohat] and the JAR's Ret.qsys.
Definition qsys_types.h:37