LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
snc_bound_backlog.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_SNC_BOUND_BACKLOG_H
6#define LINE_API_SNC_BOUND_BACKLOG_H
7
8/**
9 * @file
10 * @ingroup api_snc
11 * Violation probability of a backlog level.
12 *
13 * For a flow with arrival envelope (sigmaA,rhoA) served by an element with
14 * service envelope (sigmaS,rhoS), the backlog of the stable station obeys, for
15 * every theta > 0,
16 *
17 * P{B(t) > b} <= exp(-theta*(b-sigmaA-sigmaS)) / (1-exp(-theta*(rhoS-rhoA))),
18 *
19 * the union bound over the start of the backlogged period summed as a geometric
20 * series on the unit-slot time axis. The returned value is the infimum over
21 * theta, clipped at 1, and is an UPPER BOUND on the tail, never an estimate of
22 * it: the decay rate is asymptotically exact and the prefactor is loose.
23 *
24 * Port of matlab/src/api/snc/snc_bound_backlog.m.
25 */
26
27#include <cmath>
28
31#include "line/util/error.h"
32
33namespace line {
34namespace snc {
35
36/**
37 * @brief Violation probability of a backlog level.
38 *
39 * @param arv arrival envelope
40 * @param srv service envelope
41 * @param b backlog level, units of the envelopes
42 * @param thetamax upper end of the theta search
43 */
44inline SncResult snc_bound_backlog(const Envelope& arv, const Envelope& srv, double b,
45 double thetamax = 1e3) {
46 if (b < 0) throw UnsupportedError("snc_bound_backlog: b must be nonnegative");
47 const SncResult r = snc_thetaopt(
48 [&](double theta) {
49 const detail::SncPair p = detail::snc_pair(arv, srv, theta);
50 if (!p.ok) return std::numeric_limits<double>::infinity();
51 return std::exp(-theta * (b - p.a.sigma - p.s.sigma)) /
52 (1.0 - std::exp(-theta * (p.s.rho - p.a.rho)));
53 },
54 thetamax);
55 // no feasible theta, or the bound is vacuous at this level
56 const double eps = (!std::isfinite(r.value) || r.value > 1.0) ? 1.0 : r.value;
57 return SncResult{eps, r.theta};
58}
59
60} // namespace snc
61} // namespace line
62
63#endif // LINE_API_SNC_BOUND_BACKLOG_H
UnsupportedError(const std::string &what)
Definition error.h:51
The exception types the port throws.
std::function< Env(double)> Envelope
An envelope as a function of the Chernoff parameter.
Definition snc_types.h:48
SncResult snc_thetaopt(const std::function< double(double)> &fun, double thetamax=1e3)
Minimizes a Chernoff bound over the free parameter theta.
SncResult snc_bound_backlog(const Envelope &arv, const Envelope &srv, double b, double thetamax=1e3)
Violation probability of a backlog level.
Minimizes a Chernoff bound over the free parameter theta.
Shared types of the stochastic network calculus domain.
A bound together with the theta that attains it.
Definition snc_types.h:51
double value
The bound: a violation probability, a quantile or a mean bound.
Definition snc_types.h:53
double theta
The minimizing theta, NaN when no feasible theta exists.
Definition snc_types.h:55