LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
snc_conv.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_CONV_H
6#define LINE_API_SNC_CONV_H
7
8/**
9 * @file
10 * @ingroup api_snc
11 * Min-plus convolution of two service envelopes (tandem concatenation).
12 *
13 * Two stations traversed in series offer the flow their min-plus convolution.
14 * For independent servers with exponential-form envelopes, summing the geometric
15 * series over the intermediate epoch gives
16 *
17 * rho = min(rho1,rho2),
18 * sigma = sigma1 + sigma2 - log(1-exp(-theta*|rho1-rho2|))/theta.
19 *
20 * This is the pay-bursts-only-once result: the end-to-end burst term grows
21 * additively rather than the per-station delay bounds being summed. The series
22 * diverges at equal rates, so those are handled by shifting the slower server
23 * down by `delta`, the usual regularization; delta trades rate against burst and
24 * is an argument so it can be optimized jointly with theta.
25 *
26 * Port of matlab/src/api/snc/snc_conv.m. Original: F. Ciucu, A. Burchard,
27 * J. Liebeherr, IEEE Trans. Inf. Theory 52(6), 2300-2312, 2006.
28 */
29
30#include <algorithm>
31#include <cmath>
32#include <limits>
34#include "line/util/error.h"
35
36namespace line {
37namespace snc {
38
39/**
40 * @brief Min-plus convolution of two service envelopes (tandem
41 * concatenation).
42 *
43 * @param s1 envelope of the first station
44 * @param s2 envelope of the second station
45 * @param theta Chernoff parameter, theta > 0
46 * @param delta rate separation used when the two rates coincide; a nonpositive
47 * value selects the default 1e-2*min(rho1,rho2)
48 */
49inline Env snc_conv(const Env& s1, const Env& s2, double theta, double delta = -1.0) {
50 if (theta <= 0) throw UnsupportedError("snc_conv: theta must be positive");
51 if (delta <= 0) delta = 1e-2 * std::min(s1.rho, s2.rho);
52 if (delta <= 0) throw UnsupportedError("snc_conv: delta must be positive");
53 if (!std::isfinite(s1.rho) || !std::isfinite(s2.rho))
54 return Env{std::numeric_limits<double>::infinity(), std::min(s1.rho, s2.rho)};
55 double gap = std::fabs(s1.rho - s2.rho);
56 double rho;
57 if (gap <= delta) {
58 gap = delta; // equal rates: shift the slower server down to close the series
59 rho = std::min(s1.rho, s2.rho) - delta;
60 } else {
61 rho = std::min(s1.rho, s2.rho);
62 }
63 if (rho <= 0) return Env{std::numeric_limits<double>::infinity(), rho};
64 return Env{s1.sigma + s2.sigma - std::log(1.0 - std::exp(-theta * gap)) / theta, rho};
65}
66
67} // namespace snc
68} // namespace line
69
70#endif // LINE_API_SNC_CONV_H
UnsupportedError(const std::string &what)
Definition error.h:51
The exception types the port throws.
Env snc_conv(const Env &s1, const Env &s2, double theta, double delta=-1.0)
Min-plus convolution of two service envelopes (tandem concatenation).
Definition snc_conv.h:49
Shared types of the stochastic network calculus domain.
The pair (sigma, rho) of an envelope evaluated at one theta.
Definition snc_types.h:42