5#ifndef LINE_API_PFQN_PFQN_PBH_H
6#define LINE_API_PFQN_PFQN_PBH_H
54std::vector<T> pbh_residence(
const std::vector<T>& L,
int N,
const T& Z,
int level,
bool optimistic) {
55 const std::size_t K = L.size();
58 for (std::size_t i = 1; i < K; ++i)
59 if (L[i] > L[b]) b = i;
60 const int lv = std::min(level, N);
61 const int n0 = N - lv;
63 for (
const T& x : L) Lsum += x;
65 std::vector<T> Rk(K, zero);
68 if (asym < Lsum) asym = Lsum;
75 if (n0 == 0) Rk.assign(K, zero);
77 for (
int n = n0 + 1; n <= N; ++n) {
79 for (
const T& x : Rk) Rtot += x;
80 if (n == 1 || T(Z + Rtot) == zero) {
84 for (std::size_t i = 0; i < K; ++i) Rk[i] = T(L[i] * T(one + f * Rk[i]));
104 const std::size_t K = L.size();
105 if (K == 0)
throw InputError(
"pfqn_pbh: empty demand vector");
106 if (N < 0)
throw InputError(
"pfqn_pbh: negative population");
107 if (level < 0)
throw InputError(
"pfqn_pbh: negative hierarchy level");
109 T Lmax = L[0], Lsum = zero;
110 for (
const T& x : L) {
112 if (x > Lmax) Lmax = x;
115 const std::vector<T> Ro = detail::pbh_residence(L, N, Z, level,
true);
116 const std::vector<T> Rp = detail::pbh_residence(L, N, Z, level,
false);
118 T Rosum = zero, Rpsum = zero;
119 for (
const T& x : Ro) Rosum += x;
120 for (
const T& x : Rp) Rpsum += x;
125 if (asym < Lsum) asym = Lsum;
126 if (RoC < asym) RoC = asym;
129 if (Lmax == zero)
throw NumericError(
"pfqn_pbh: all demands are zero");
132 if (alt < r.
Xhi) r.
Xhi = alt;
137 for (std::size_t i = 0; i < K; ++i) {
138 r.
Qlo[i] = T(r.
Xlo * Ro[i]);
139 r.
Qhi[i] = T(r.
Xhi * Rp[i]);
NumericError(const std::string &what)
The exception types the port throws.
PbhBounds< T > pfqn_pbk(const std::vector< T > &L, int N, const T &Z, int k)
PB(k), the iterative Eager-Sevcik proportional bound.
PbhBounds< T > pfqn_bjbk(const std::vector< T > &L, int N, const T &Z, int k)
BJB(k), the iterative Balanced Job Bound.
PbhBounds< T > pfqn_pbh(const std::vector< T > &L, int N, const T &Z, int level)
Performance Bound Hierarchy (Eager and Sevcik 1983, ACM TOCS 1(2):99-115) for single-class closed pro...
Conservation laws of a layered queueing network, enumerated from its structure.
Number-type abstraction for the templated API port.
Return value of pfqn_pbh, mirroring [Xlo, Xhi, Qlo, Qhi].