LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
snc_perc_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_PERC_DELAY_H
6#define LINE_API_SNC_PERC_DELAY_H
7
8/**
9 * @file
10 * @ingroup api_snc
11 * Delay quantile at a prescribed violation probability.
12 *
13 * Inverts `snc_bound_delay` in d: at fixed theta,
14 *
15 * d(theta) = (sigmaA + sigmaS
16 * - log(eps*(1-exp(-theta*(rhoS-rhoA))))/theta) / rhoS,
17 *
18 * minimized over the feasible thetas. This is the deliverable of the domain: a
19 * statistical delay guarantee, the quantity a service-level objective is written
20 * against, as opposed to the mean delay returned by the queueing-theoretic
21 * solvers.
22 *
23 * Port of matlab/src/api/snc/snc_perc_delay.m.
24 */
25
26#include <cmath>
27
30#include "line/util/error.h"
31
32namespace line {
33namespace snc {
34
35/**
36 * @brief Delay quantile at a prescribed violation probability.
37 *
38 * @param arv arrival envelope
39 * @param srv service envelope
40 * @param eps violation probability, 0 < eps < 1
41 * @param thetamax upper end of the theta search
42 */
43inline SncResult snc_perc_delay(const Envelope& arv, const Envelope& srv, double eps,
44 double thetamax = 1e3) {
45 if (!(eps > 0.0 && eps < 1.0))
46 throw UnsupportedError("snc_perc_delay: eps must lie in (0,1)");
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 (p.a.sigma + p.s.sigma -
52 std::log(eps * (1.0 - std::exp(-theta * (p.s.rho - p.a.rho)))) / theta) /
53 p.s.rho;
54 },
55 thetamax);
56 return SncResult{std::max(r.value, 0.0), r.theta};
57}
58
59} // namespace snc
60} // namespace line
61
62#endif // LINE_API_SNC_PERC_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_thetaopt(const std::function< double(double)> &fun, double thetamax=1e3)
Minimizes a Chernoff bound over the free parameter theta.
SncResult snc_perc_delay(const Envelope &arv, const Envelope &srv, double eps, double thetamax=1e3)
Delay quantile at a prescribed violation probability.
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