LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
snc_env_tokenbucket.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_ENV_TOKENBUCKET_H
6#define LINE_API_SNC_ENV_TOKENBUCKET_H
7
8/**
9 * @file
10 * @ingroup api_snc
11 * Deterministic token-bucket arrival envelope.
12 *
13 * A flow policed by a (b,r) token bucket satisfies `A(s,t) <= b + r*(t-s)` with
14 * probability one, so the envelope is constant in theta. This is the
15 * deterministic network calculus arrival curve read as a degenerate MGF
16 * envelope, so it mixes freely with the stochastic ones.
17 *
18 * Port of matlab/src/api/snc/snc_env_tokenbucket.m.
19 */
20
22#include "line/util/error.h"
23
24namespace line {
25namespace snc {
26
27/**
28 * @brief Deterministic token-bucket arrival envelope.
29 *
30 * @param b bucket depth, units of work
31 * @param r token rate, work per slot
32 */
33inline Env snc_env_tokenbucket(double b, double r) {
34 if (b < 0 || r < 0)
35 throw UnsupportedError("snc_env_tokenbucket: b and r must be nonnegative");
36 return Env{b, r};
37}
38
39/**
40 * @brief Deterministic token-bucket arrival envelope.
41 *
42 * @param theta accepted and ignored, for signature compatibility
43 */
44inline Env snc_env_tokenbucket(double b, double r, double theta) {
45 if (theta <= 0) throw UnsupportedError("snc_env_tokenbucket: theta must be positive");
46 return snc_env_tokenbucket(b, r);
47}
48
49/** The same envelope as a function of theta. */
50inline Envelope snc_env_tokenbucket_fn(double b, double r) {
51 return [b, r](double theta) { return snc_env_tokenbucket(b, r, theta); };
52}
53
54} // namespace snc
55} // namespace line
56
57#endif // LINE_API_SNC_ENV_TOKENBUCKET_H
UnsupportedError(const std::string &what)
Definition error.h:51
The exception types the port throws.
Envelope snc_env_tokenbucket_fn(double b, double r)
The same envelope as a function of theta.
std::function< Env(double)> Envelope
An envelope as a function of the Chernoff parameter.
Definition snc_types.h:48
Env snc_env_tokenbucket(double b, double r)
Deterministic token-bucket arrival envelope.
Shared types of the stochastic network calculus domain.
The pair (sigma, rho) of an envelope evaluated at one theta.
Definition snc_types.h:42