LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
pfqn_qzgbup.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_QZGBUP_H
6
#define LINE_API_PFQN_PFQN_QZGBUP_H
7
8
/**
9
* @file
10
* @ingroup api_pfqn
11
* Geometric-bound upper bound on the queue length at station i.
12
*
13
* Templated port of matlab/src/api/pfqn/pfqn_qzgbup.m. Single-class model: L is the
14
* per-station demand vector, N the population, Z the think time.
15
*
16
* All operations stay in the field, so the bound is exact in rational
17
* arithmetic: a bound computed exactly is worth having, since a bound violated
18
* only by rounding is indistinguishable from a real violation.
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_xzabaup.h
"
28
29
namespace
line
{
30
namespace
pfqn
{
31
32
/** As the lower bound, with Y from the ABA upper bound and the sigma term. */
33
template
<
class
T>
34
T
pfqn_qzgbup
(
const
std::vector<T>& L,
const
T& N,
const
T& Z, std::size_t i) {
35
if
(i >= L.size())
throw
InputError
(
"pfqn_qzgbup: station index out of range"
);
36
const
T one =
num_traits<T>::from_int
(1);
37
T Ltot =
num_traits<T>::from_int
(0), L2 =
num_traits<T>::from_int
(0), Lmax = L[0];
38
for
(
const
T& d : L) {
39
Ltot += d;
40
L2 += d * d;
41
if
(d > Lmax) Lmax = d;
42
}
43
const
T sigma = L2 / Ltot;
44
const
T Nm1 = N - one;
45
const
T xup =
pfqn_xzabaup
(L, Nm1, Z);
46
const
T cap = one / Lmax;
47
const
T alt = N / (Z + Ltot + sigma * (Nm1 - Z * xup));
48
const
T Yi = L[i] * (cap < alt ? cap : alt);
49
if
(Yi < one) {
50
const
long
Nl =
static_cast<
long
>
(
num_traits<T>::to_double
(N));
51
return
Yi / (one - Yi) -
num_pow_int
(Yi,
static_cast<
unsigned
>
(Nl + 1)) / (one - Yi);
52
}
53
return
N;
54
}
55
56
}
// namespace pfqn
57
}
// namespace line
58
59
#endif
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
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_xzabaup
T pfqn_xzabaup(const std::vector< T > &L, const T &N, const T &Z)
X <= min(1/Lmax, N/(sum(L)+Z)): capacity bound and population bound.
Definition
pfqn_xzabaup.h:33
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
line::num_pow_int
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition
number.h:192
number.h
Number-type abstraction for the templated API port.
pfqn_xzabaup.h
Asymptotic-bound-analysis upper bound on throughput.
line::num_traits
Definition
number.h:111
include
line
api
pfqn
pfqn_qzgbup.h
Generated by
1.18.0