LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
snc_bound_delay.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_DELAY_H
6#define LINE_API_SNC_BOUND_DELAY_H
7
8/**
9 * @file
10 * @ingroup api_snc
11 * Violation probability of a delay target.
12 *
13 * For a flow with arrival envelope (sigmaA,rhoA) served by an element with
14 * service envelope (sigmaS,rhoS), the virtual delay of the stable station obeys,
15 * for every theta > 0,
16 *
17 * P{D(t) > d} <= exp(-theta*(rhoS*d-sigmaA-sigmaS)) / (1-exp(-theta*(rhoS-rhoA))),
18 *
19 * the horizontal rather than vertical deviation between the arrival and service
20 * envelopes. On the M/M/1 read in job units (`snc_env_poisson` with
21 * `snc_srv_exp`) the optimal theta tends to log(mu/lambda), so the bound
22 * reproduces the exact asymptotic decay rate exp(-(mu-lambda)*d).
23 *
24 * Port of matlab/src/api/snc/snc_bound_delay.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 delay target.
38 *
39 * @param arv arrival envelope
40 * @param srv service envelope
41 * @param d delay target, slots
42 * @param thetamax upper end of the theta search
43 */
44inline SncResult snc_bound_delay(const Envelope& arv, const Envelope& srv, double d,
45 double thetamax = 1e3) {
46 if (d < 0) throw UnsupportedError("snc_bound_delay: d 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 * (p.s.rho * d - p.a.sigma - p.s.sigma)) /
52 (1.0 - std::exp(-theta * (p.s.rho - p.a.rho)));
53 },
54 thetamax);
55 const double eps = (!std::isfinite(r.value) || r.value > 1.0) ? 1.0 : r.value;
56 return SncResult{eps, r.theta};
57}
58
59} // namespace snc
60} // namespace line
61
62#endif // LINE_API_SNC_BOUND_DELAY_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_bound_delay(const Envelope &arv, const Envelope &srv, double d, double thetamax=1e3)
Violation probability of a delay target.
SncResult snc_thetaopt(const std::function< double(double)> &fun, double thetamax=1e3)
Minimizes a Chernoff bound over the free parameter theta.
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