LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
pfqn_xzgsbup.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_PFQN_PFQN_XZGSBUP_H
6
#define LINE_API_PFQN_PFQN_XZGSBUP_H
7
8
/**
9
* @file
10
* @ingroup api_pfqn
11
* Geometric-square-root bound, upper bound on throughput.
12
*
13
* Templated port of matlab/src/api/pfqn/pfqn_xzgsbup.m. Single-class model: L is the
14
* per-station demand vector, N the population, Z the think time.
15
*
16
* Needs a square root, so it is available in double and high-precision
17
* arithmetic only; the static_assert makes an exact instantiation a compile
18
* error rather than a silent approximation.
19
*/
20
21
#include <algorithm>
22
#include <vector>
23
24
#include "
line/num/number.h
"
25
#include "
line/util/error.h
"
26
#include "
line/util/matrix.h
"
27
#include "
line/api/pfqn/pfqn_qzgbup.h
"
28
29
namespace
line
{
30
namespace
pfqn
{
31
32
/** X = 2N / (R + sqrt(R^2 - 4 Z Lmax N)), R from the geometric queue bound. */
33
template
<
class
T>
34
T
pfqn_xzgsbup
(
const
std::vector<T>& L,
const
T& N,
const
T& Z) {
35
static_assert
(
num_traits<T>::has_transcendental
,
36
"pfqn_xzgsbup requires transcendental arithmetic (square root)"
);
37
const
T one =
num_traits<T>::from_int
(1);
38
T Ltot =
num_traits<T>::from_int
(0), Lmax = L[0];
39
for
(
const
T& d : L) {
40
Ltot += d;
41
if
(d > Lmax) Lmax = d;
42
}
43
T R = Z + Ltot + Lmax * (N - one);
44
for
(std::size_t i = 0; i < L.size(); ++i)
45
if
(L[i] < Lmax) R += (L[i] - Lmax) *
pfqn_qzgbup
(L, T(N - one), Z, i);
46
T disc = R * R -
num_traits<T>::from_int
(4) * Z * Lmax * N;
47
if
(disc <
num_traits<T>::from_int
(0)) disc =
num_traits<T>::from_int
(0);
48
using
std::sqrt;
49
return
num_traits<T>::from_int
(2) * N / (R + sqrt(disc));
50
}
51
52
}
// namespace pfqn
53
}
// namespace line
54
55
#endif
error.h
The exception types the port throws.
matrix.h
Dense matrix and non-owning view.
line::pfqn
Definition
cd_peak_scaling.h:43
line::pfqn::pfqn_xzgsbup
T pfqn_xzgsbup(const std::vector< T > &L, const T &N, const T &Z)
X = 2N / (R + sqrt(R^2 - 4 Z Lmax N)), R from the geometric queue bound.
Definition
pfqn_xzgsbup.h:34
line::pfqn::pfqn_qzgbup
T pfqn_qzgbup(const std::vector< T > &L, const T &N, const T &Z, std::size_t i)
As the lower bound, with Y from the ABA upper bound and the sigma term.
Definition
pfqn_qzgbup.h:34
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
pfqn_qzgbup.h
Geometric-bound upper bound on the queue length at station i.
line::num_traits
Definition
number.h:111
include
line
api
pfqn
pfqn_xzgsbup.h
Generated by
1.18.0