86 std::size_t k,
const T& alpha_a,
const T& alpha_s) {
88 "qsys_gigk_rqt requires transcendental arithmetic");
91 if (alpha_a <= one || alpha_a > T(one + one) || alpha_s <= one || alpha_s > T(one + one))
92 throw InputError(
"qsys_gigk_rqt: tail coefficients must lie in (1,2]");
95 const T rho = lambda / (kk * mu);
103 throw InputError(
"qsys_gigk_rqt: rho must be strictly less than 1 for a finite system time");
106 const T ab = alpha_a < alpha_s ? alpha_a : alpha_s;
107 const T beta = Gamma_a + Gamma_s / detail::num_pow(kk, T(one / ab));
112 const T e = ab / (ab - one);
113 r.
W = (ab - one) / detail::num_pow(ab, e) * detail::num_pow(lambda, T(one / (ab - one))) *
114 detail::num_pow(beta, e) / detail::num_pow(T(one - rho), T(one / (ab - one))) +
117 r.
rhohat = detail::rhohat_from_W(r.
W, lambda);
120 auto obj = [&](
const T& x) -> T {
122 if (y < zero) y = zero;
123 return x / mu + Gamma_s * detail::num_pow(x, T(one / alpha_s)) - kk * y / lambda +
124 Gamma_a * detail::num_pow(T(kk * y), T(one / alpha_a));
129 const T xs = detail::num_pow(T(lambda * beta / (ab * (one - rho))), T(ab / (ab - one)));
132 double xhi = std::max(4.0, std::ceil(4.0 * xstar));
133 if (!(xhi > 0.0) || !std::isfinite(xhi)) xhi = 4.0;
134 const std::size_t NS = 400;
135 std::vector<double> xs;
137 for (std::size_t i = 0; i < NS; ++i) {
138 const double e = std::log10(xhi) *
static_cast<double>(i) /
static_cast<double>(NS - 1);
139 const double x = std::max(1.0, std::floor(std::pow(10.0, e) + 0.5));
140 if (xs.empty() || x != xs.back()) xs.push_back(x);
142 std::size_t imax = 0;
144 for (std::size_t i = 1; i < xs.size(); ++i) {
157 T c = hi - (hi - lo) * invphi;
158 T d = lo + (hi - lo) * invphi;
159 T fc = obj(c), fd = obj(d);
160 for (
unsigned it = 0; it < 500u && hi - lo > tolx; ++it) {
165 c = hi - (hi - lo) * invphi;
171 d = lo + (hi - lo) * invphi;
176 const double cand[2] = {std::floor(xc), std::ceil(xc)};
177 for (
int i = 0; i < 2; ++i) {
178 if (cand[i] >= 1.0) {
180 if (v > best) best = v;
GigkRqtResult< T > qsys_gigk_rqt(const T &lambda, const T &mu, const T &Gamma_a, const T &Gamma_s, std::size_t k, const T &alpha_a, const T &alpha_s)
Robust Queueing Theory (RQT) worst-case system time of a G/G/k FCFS queue.