1 Introduction

Network Calculus (NC) is an algebraic theory where traffic and service guarantees are represented as functions of time. The I/O transformations that network traversal imposes on an input traffic can be represented as operations of min-plus algebra involving these curves. This allows one to compute worst-case performance guarantees for a flow traversing a network. NC dates back to the early 1990s, and it is mainly due to the work of Cruz (Cruz 1991a; 1991b), Le Boudec and Thiran (Le Boudec and Thiran 2001), and Chang (Chang 2000). Originally devised for the Internet, where it was used to engineer models of service (Le Boudec 1998b; Firoiu et al. 2002; Le Boudec 1998a; Bennett et al. 2002; Fidler and Sander 2004), it has found applications in several other contexts, from sensor networks (Schmitt and Roedig 2005) to avionic networks (Charara et al. 2006; Bauer et al. 2010), industrial networks (Zhang et al. 2019; Maile et al. 2020; Zhao et al. 2021), automotive systems (Rehm et al. 2021), and systems architecture (Andreozzi et al. 2020; Boyer et al. 2020).

NC characterizes constraints on traffic arrivals (due to traffic shaping) and on minimum received service (due to scheduling) as curves, i.e., functions of time.Footnote 1 These curves are then used with operators from min-plus and max-plus algebra to derive further insights about the system. For example, the per-flow service curve of a scheduler, such as Weighted Round Robin, or performance bounds on the traffic such as an end-to-end delay bound. While these operations can be computed with pen and paper for simple examples, in most practical cases the application of NC requires the use of software. To this end, works (Bouillard and Thierry 2008; Bouillard et al. 2018) provide an “algorithmic toolbox” for NC: they show that piecewise affine functions that are ultimately pseudo-periodic (UPP) represent good models for both traffic and service guarantees. Moreover, they prove that this class of functions is closed under the main NC operations and can be described with a finite amount of information. Additionally, they introduce the algorithms that embody the main NC operations, computing UPP results starting from UPP operands. The results in these works cover the main operations used in NC, such as minimum, min-plus convolution, min-plus deconvolution, etc. (see (Bouillard et al. 2018) for a complete list). The toolbox was first implemented in the COINC free library (Bouillard et al. 2009), which is not available anymore, and later by the commercial library RTaW-Pegase (RealTime-at-Work: RTaW-Pegase (min +) library 2022).

However, other NC operators, i.e., the composition and lower and upper pseudo-inverse, have been the focus of recent NC literature. In (Bouillard et al. 2018, Theorem 8.6), lower pseudo-inverse and composition are used to compute the per-flow service curve for a Weighted Round-Robin scheduler; in (Tabatabaee et al. 2021, Theorem 1), a similar result is shown for an Interleaved Weighted Round-Robin scheduler, using again lower pseudo-inverse and composition; in (Tabatabaee and Le Boudec 2022), authors show that several service curves can be found for a flow scheduled in a Deficit Round-Robin scheduler, under different hypotheses regarding cross-traffic. Works (Mohammadpour et al. 2019; 2022) use pseudo-inverses and compositions to study properties of IEEE Time-Sensitive Networking (TSN) (IEEE: Time-sensitive networking (TSN) task group 2020), a standard relevant for many applications. Work (Liebeherr 2017) shows the duality between min-plus and max-plus models, and how the lower and upper pseudo-inverses can be used to switch between the two models. This is exploited in Pollex et al. (2011) to devise an alternative algorithm for min-plus convolution, which transforms it into a max-plus convolution, obtaining a considerable speedup in the settings discussed in that paper. We can therefore obtain the results presented in these papers, using arbitrarily complex UPP curves as inputs.

While the algebraic formulation of these three operations is well known, their algorithmic aspects have not been addressed, to the best of our knowledge. This means that we do not have publicly known algorithms that compute these operations yet. In this paper, we aim to fill this gap and extend the existing algorithm toolbox to include lower- and upper-pseudo inverses and composition of functions.

We show that the UPP class is closed with respect to these operations, and provide algorithms to compute the result of each one. We prove that all of them have linear complexity with respect to the number of segments that represent the operands. We design specialized, more efficient versions of the composition algorithm that leverage characteristics of the operand functions – notably, their being Ultimately Affine (UA) or Ultimately Constant (UC) (Bouillard et al. 2018). Last, we exemplify our findings on a comprehensive proof of concept, showing how to compute the per-flow service curve of (Tabatabaee et al. 2021, Theorem 1). The algorithms described in this paper, together with those for known NC operators, are implemented in the Nancy open-source toolbox (Zippo and Stea 2022a), which, to the best of our knowledge, is the only public one to implement UPP algorithms.

The rest of this paper is organized as follows: Section 2 briefly introduces NC notation and some basic results. Section 3 introduces the definitions and notation used throughout the paper, and discusses the kind of results that we need to provide for each operator to enable their implementation. In Section 4, we present the results for the lower and upper pseudo-inverse operators, including their properties for UPP curves and algorithms to compute them. Section 5 shows our results for the composition operator, including its properties on UPP curves and an algorithm to compute it. In Section 6, we report a proof-of-concept evaluation, by computing the results of a recent NC paper via our algorithms. Finally, Section 7 draws some conclusions and highlights directions for future works.

2 Network calculus basics

This section briefly introduces Network Calculus (NC). We use here the same notation as in (Le Boudec and Thiran 2001), to which the interested reader is referred for a more in-depth explanation. A NC flow is represented by a function of time A(t) that counts the amount of traffic arrived by time t. Such function is necessarily non-decreasing. It is often assumed to be left-continuous, i.e., A(t) represents the number of bits in [0,t[. In particular, A(0) =0.

Flows can be constrained by arrival curves. A non-decreasing function α is an arrival curve for a flow A if

$$ A(t)-A(s) \leq \alpha(t-s), \qquad \forall s \leq t. $$

For instance, a leaky-bucket shaper, with a rate ρ and a burst size σ, enforces the affine arrival curve

$$ \gamma_{\sigma,\rho}(t) = \begin{cases} \sigma + \rho t, & \text{if } t>0, \\ 0, & \text{otherwise,} \end{cases} $$

as shown in Fig. 1. In particular, this means that the long-term arrival rate of the flow cannot exceed ρ. Leaky-bucket shapers are often employed at the entrance of a network, to ensure that the injected traffic does not exceed the negotiated amount.

Fig. 1
figure 1

Example of leaky-bucket shaper, taken from Andreozzi et al. (2020). The traffic process A(t) is always below the arrival curve α(t) and its translations along A(t)

Let A and D be non-decreasing functions that describe the same data flow at the input and output of a lossless network element (or node), respectively. Footnote 2 If that node does not create data internally (which is often the case), causality requires that AD. We say that the node guarantees to the flow a (minimum) service curveβ if

$$ D(t) \geq \inf_{0\leq s\leq t} \left\{ A(s)+\beta(t-s) \right\} =: (A \otimes \beta)(t), \qquad \forall t\geq 0. $$
(1)

We call the operation on the right the min-plus convolution of A and β. Several network elements, such as delay elements, schedulers or links, can be modeled through service curves.

A very frequent case is the one of rate-latency service curves, defined as

$$ \beta_{R, \theta}(t) = R \cdot \left[t-\theta\right]^+ $$

for some rate R > 0 and latency 𝜃 ≥ 0. We write \(\left [\cdot \right ]^+\) to denote \(\max \limits \left \{\cdot , 0\right \}\). For instance, a constant-rate server (e.g., a wired link) can be modeled as a rate-latency service curve with zero latency. Figure 2 shows the lower bound of D obtained by computing Aβ, with β = βR,𝜃.

Fig. 2
figure 2

Graphical interpretation of the convolution operation. A is the input function, βR,𝜃 is a rate-latency service curve, and Aβ is a lower bound on the output

A point of strength of NC is that service curves are composable: the end-to-end service curve of a tandem of nodes traversed by the same flow can be computed as the min-plus convolution of the service curves of each node.

For a flow that traverses a service curve (be it the one of a single node, or the end-to-end service curve of a tandem computed as discussed above), an upper bound on the delay can be computed by combining its arrival curve α and the service curve β itself, as follows:

$$ h(\alpha,\beta) = \sup_{t\geq 0} \left\{\inf \left\{ d\geq 0 \mid \alpha(t-d)\leq \beta(t) \right\} \right\}. $$
(2)

The quantity h(α,β) is in fact the maximum horizontal distance between α and β, as shown in Fig. 3. Therefore, computing the end-to-end service curve of a flow in a tandem traversal is the crucial step towards obtaining its worst-case delay bound.

Fig. 3
figure 3

Graphical example of a delay bound

The above introduction, albeit concise, should convince the alert reader that algorithms for automated manipulation of curves, implementing NC operators, are necessary to reap the benefits of NC algebra in practical scenarios. Many such algorithms have been discussed in (Bouillard and Thierry 2008; Bouillard et al. 2018). The next section describes the generic algorithmic framework exposed in these papers, which we extend in this work.

3 Mathematical background and notation

In this section, we provide an overview of the mathematical background for this paper, including the definitions used and the results we aim to provide.

NC computations can be implemented in software. In order to do so, one needs to provide finite representations of functions and well-formed algorithms for NC operations. According to the widely accepted approach described in Bouillard and Thierry (2008) and Bouillard et al. (2018), a sufficiently generic class of functions useful for NC computations is the set \(\mathcal {U}\) of (i) ultimately pseudo-periodic (ii) piecewise affine \(\mathbb {Q}_{+} \rightarrow \mathbb {Q} \cup \{+\infty , -\infty \}\) functions. We define both properties (i) and (ii) separately:

Definition 1 (Ultimately Pseudo-Periodic Function (Bouillard and Thierry 2008, p. 8) )

Let f be a function \(\mathbb {Q}_{+}\rightarrow \mathbb {Q} \cup \{+\infty , -\infty \}\). Then, f is ultimately pseudo-periodic (UPP) if there exist \(T_{f}\in \mathbb {Q}_{+},d_{f}\in \mathbb {Q}_{+}\setminus \{0\},c_{f}\in \mathbb {Q} ~\cup ~\{+\infty , -\infty \}\) such that Footnote 3

$$ f(t + k \cdot d_{f}) = f(t) + k \cdot c_{f}, \qquad\forall t\ge T_{f},\forall k \in \mathbb{N}. $$
(3)

We call Tf the (pseudo-periodic) start or length of the initial transient, df the (pseudo-periodic) length, and cf the (pseudo-periodic) height.

Definition 2 (Piecewise Affine Function (Bouillard and Thierry 2008, p. 9))

We say that a function f is piecewise affine (PA) if there exists an increasing sequence \((a_{i}), {i\in \mathbb {N}_{0}}\) which tends to \(+\infty \), such that a0 =0 and \(\forall i \in \mathbb {N}_{0}\), it either holds that f(t) = bi + ρit for some \(b_{i}, \rho _{i} \in \mathbb {Q}\), or \(f(t) = +\infty \), or \(f(t) = -\infty \) for all \(t \in \left ]a_{i}, a_{i+1}\right [\). The ai’s are called breakpoints.

In Bouillard and Thierry (2008), this class of functions is shown to be stable w.r.t. all min-plus operations, while functions \(\mathbb {R}_{+} \rightarrow \mathbb {R} \cup \{+\infty , -\infty \}\) are not.Footnote 4

We remark that functions in \(\mathcal {U}\) are not necessarily wide-sense increasing. While NC functions are usually assumed to be so, in order to implement min-plus operations it is sometimes useful to include non-monotonic functions as well. Similarly, functions in \(\mathcal {U}\) can assume infinite values. This is also useful for algebraic manipulations, e.g., to express a function as a minimum of two or more functions.

Throughout this paper, we will consider all functions to be in \(\mathcal {U}\), hence, piecewise affine and UPP. For such functions, it is enough to store a representation of the initial transient part and of one period, which is a finite amount of information. This is exemplified in Fig. 4.

Fig. 4
figure 4

Example of ultimately pseudo-periodic piecewise affine function f and its representation Rf

Accordingly, we call a representationRf of a function f the tuple (S,T,d,c), where T,d,c are the values described above, and S is a sequence of points and open segments describing f in [0,T + d[. We use both points and open segments in order to easily model discontinuities. We will use the umbrella term elements to encompass both when convenient.

Definition 3 (Point)

We define a point as a tuple

$$ p_{i} := (t_{i}, f(t_{i})), \qquad i \in \left\{1, \dots, n\right\}. $$

Definition 4 (Segment)

We define a segment as a tuple

$$ s_{i} := \left( t_{i}, t_{i+1}, f(t_{i}^{+}), f(t_{i+1}^{-})\right), \qquad i \in \left\{1, \dots, n\right\}, $$

which describes f in the open interval \( \left ]t_{i}, t_{i+1} \right [ \) in which it is affine, i.e.,

$$ f(t) = f(t_{i}^{+}) + \frac{f(t_{i+1}^{-}) - f(t_{i}^{+})}{t_{i+1} - t_{i}} \cdot (t - t_{i}) =: b + r \cdot (t - t_{i}) \qquad \text{for all } t \in \left]t_{i}, t_{i+1} \right[, $$

where we used the following shorthand notation for one-sided limits:

$$ f\left( t_{i}^{+}\right) = \lim_{t\to t_{i}^{+}}f\left( t\right),~ f\left( t_{i}^{-}\right) = \lim_{t\to t_{i}^{-}}f\left( t\right). $$

If r =0, we call si a constant segment.

Definition 5 (Sequence)

We define a sequence \({S^{D}_{f}}\) as on ordered set of elements \({e_{1}, \dots , e_{n}}\) that alternate between points and segments and describe f in the finite interval \(D \subset \mathbb {Q}_{+}\).

For example, given \(D = \left [ 0, T \right [\), then \({S^{D}_{f}} = \{p_{1}, s_{1}, p_{2}, \dots , p_{n}, s_{n}\}\) where \(p_{1} = \left (0, f(0)\right )\) and, assuming \(p_{n} = \left (t_{n}, f(t_{n})\right )\) for some 0 < tn < T, \(s_{n} = \left (t_{n}, T, f(t_{n}^{+}), f(T^{-})\right )\).

Note that, given Rf, one can compute f(t) for all t ≥ 0, and also \({S^{D}_{f}}\) for any interval D. Furthermore, being finite, Rf can be used as a data structure to represent f in code. As discussed in depth in Zippo and Stea (2022b), Rf is not unique, and using a non-minimal representation of f can affect the efficiency of the computations. Work (Zippo and Stea 2022b) also describes an efficient algorithm that minimizes a representation Rf (i.e., computes the smallest Tf, df that are required to represent f ). Given a sequence S, let \(n\!\left (S\right )\) be its cardinality. As it is useful in the following, we define Cut to be an (obvious) algorithm that, given Rf and D, computes \({S^{D}_{f}}\). With a little abuse of notation, we use min-plus operators directly on finite sequences such as \({S^{D}_{f}}\). For instance, given the lower pseudo-inverse of f, \(\left (f\right )^{-1}_{\downarrow }\) (its formal definition is in the next section), we will write \(\left ({S^{D}_{f}}\right )^{-1}_{\downarrow }\), to express that we are computing it on f over the limited interval D.

A NC operator can then be defined computationally as an algorithm that takes UPP representations of its input functions and yields a UPP representation of the result, provided that the class of UPP functions is closed with respect to such operator. Considering a generic unitary operator [⋅], in order to compute f we need an algorithm that computes \(R_{f^*}\) from Rf, i.e., \(R_{f} \rightarrow R_{f^*}\). We call this by-curve algorithm. This process can be divided in the following steps:

  1. 1.

    compute valid parameters \(T_{f^*}, d_{f^*}\) and \(c_{f^*}\) for the result;

  2. 2.

    compute \({S^{D}_{f}} \rightarrow S_{f^*}\), i.e., use an algorithm that computes the resulting sequence from the sequence of the operand. We call this by-sequence algorithm for operator [⋅]. In order to run this algorithm, a suitable domain D must be identified, based on the properties of operator [⋅], and, accordingly, one must compute sequence \({S^{D}_{f}} = \text {Cut}(R_{f}, D)\);

  3. 3.

    return \(R_{f^*} = (S_{f^*}, T_{f^*}, d_{f^*}, c_{f^*})\).

We therefore need to provide the following results:

  • a proof that the result of the operator [⋅], applied to a UPP function, yields a UPP result;

  • a way to compute UPP parameters \(T_{f^*}, d_{f^*}\) and \(c_{f^*}\) from Rf;

  • a valid domain D, again to be computed from Rf;

  • a by-sequence algorithm.

Combining the above results, we can then construct the by-curve algorithm for operator [⋅], which allows one to compute [⋅] for any UPP curve.Footnote 5

We exemplify the above by showing the by-curve algorithm for the left shift of a function by τ ≥ 0. Given f(t), whose representation is Rf = (Sf,Tf,df,cf), we want to compute the representation Rg = (Sg,Tg,dg,cg) of g(t) = f(t + τ). Quite intuitively, it is Tg = [Tfτ]+, dg = df, cg = cf. Moreover, the valid domain D where we need to define sequence \({S^{D}_{f}}\) for the by-sequence algorithm is \(D=\left [\tau , \max \limits \{\tau ,T_{f}\} + d_{f}\right [\). We leave it to the interested reader the straightforward (yet tedious) task of deriving sequence Sg from \({S^{D}_{f}}\), i.e., of figuring out the by-sequence algorithm for this operator.

Works (Bouillard and Thierry 2008; Bouillard et al. 2018) provided such computational descriptions for fundamental NC operators such as minimum, sum, convolution, and many others. In this paper, we extend the above toolbox by adding the lower pseudo-inverse, upper pseudo-inverse, and composition operators. To the best of our knowledge, no computational description of the above has been formalized before, despite their relevance in the NC literature.

Before presenting our contribution, we introduce two more definitions that will be used throughout the paper.

Definition 6 (Ultimately Affine Function)

Let f be a function \(\mathbb {Q}_{+}\rightarrow \mathbb {Q} \cup \{+\infty , -\infty \}\). Then, f is Ultimately Affine (UA), if either there exist \({T_{f}^{a}} \in \mathbb {Q}_{+}, \rho _{f} \in \mathbb {Q}\) such that

$$ f(t) = f({T_{f}^{a}}) + \rho_{f} \cdot \left( t - {T_{f}^{a}}\right), \qquad \forall t \ge {T_{f}^{a}}, $$
(4)

or \(f(t) = +\infty \), or \(f(t) = -\infty \) for all \(t \ge {T_{f}^{a}}\).

Note that this definition differs from the one in the literature (Bouillard and Thierry 2008), but we prove their equivalence in Appendix A. UA functions are (obviously) UPP as well, their period being a single segment of slope ρf and arbitrary length starting at \({T_{f}^{a}}\). They occur quite often in NC, e.g., the arrival curve of a leaky-bucket shaper or a rate-latency service curve are both UA. An Ultimately Constant (UC) function is UA with ρf =0. Similarly, an Ultimately Infinite (UI) function is UA with \(f(t) = +\infty \), or \(f(t) = -\infty \) for all \(t \ge {T_{f}^{a}}\).

Unlike UPP, the class of UA functions is not closed with respect to NC operations. For instance, Zippo and Stea (2022b) shows that flow-controlled networks with rate-latency (hence UA) service curves yield closed-loop service curves that are UPP, but not necessarily UA again. Moreover, in many cases, the service curves of individual flows served by Round-Robin schedulers are UPP, but not UA either (see, e.g., Boyer et al. 2012; Tabatabaee et al. 2021; Tabatabaee and Le Boudec 2022). However, there are cases when simpler algorithms for NC operations can be derived if one assumes that operands are UA. For this reason, there are NC toolboxes that only consider UA functions, e.g., Bondorf and Schmitt (2014). A possible approach to NC analysis is thus to approximate UPP (non-UA) functions with UA lower/upper bounds, trading some accuracy for computation time (Guan and Yi 2013; Lampka et al. 2017). Throughout this paper, we provide general algorithms for UPP functions. However, we also show what is to be gained – in terms of domain compactness and/or algorithmic efficiency – when we can make stronger assumptions on the operands.

4 Lower and upper pseudo-inverse of UPP functions

In this section, we discuss the lower and upper pseudo-inverse operators for UPP functions. Henceforth, we will omit the lower or upper attribute when the discussion applies to both.

First, we provide formal definitions.

Definition 7 (Lower and Upper Pseudo-Inverse)

Let \(f\in \mathcal {U}\) be non-decreasing. Then its lower pseudo-inverse is defined as

$$ f^{-1}_{\downarrow}(y):=\inf\left\{t\geq 0 \mid f(t)\geq y\right\}, $$

and its upper pseudo-inverse is defined as

$$ f^{-1}_{\uparrow}(y):=\sup\left\{ t\geq 0 \mid f(t)\leq y\right\}. $$

We can find an equivalent definition as follows.

Proposition 8

Let f𝜖U be non-decreasing. For all y > f(0), its lower pseudoinverse is equal to

$$ f^{-1}_{\downarrow}(y)=\sup \left\{t\geq0\mid f(t)<y\right\}, $$
(5)

and for all yf(0), its upper pseudo-inverse is equal to

$$ f^{-1}_{\uparrow}(y)=\inf \left\{t\geq0\mid f(t)<y\right\}, $$
(6)

Note that Liebeherr (2017) reports a slightly different definition, because functions are defined in \(\mathbb {R} \rightarrow \mathbb {R}\). Our functions in \(\mathcal {U}\) are defined in \(\mathbb {Q}_{+} \rightarrow \mathbb {Q}\), hence our domain is lower bounded. The consequences of this difference are discussed in Appendix B, which also contains a proof of Proposition 8.

Note that the lower pseudo-inverse is left-continuous and the upper pseudo-inverse is right-continuous (Liebeherr 2017, p. 64). Moreover, we have in general that (Liebeherr 2017, p. 61)

$$ f^{-1}_{\downarrow}\leq f^{-1}_{\uparrow}. $$

An example of these operators is shown in Fig. 5.

Fig. 5
figure 5

Example of lower and upper pseudo-inverse of a function f

Figure 5 shows a UPP function and its lower and upper pseudo-inverses. In NC, both pseudo-inverses are useful to switch from min-plus to max-plus algebra and vice versa (Liebeherr 2017). Later on, in Section 5, we provide the examples of Eq. 15 which uses the lower pseudo-inverse in conjunction with the composition operator, and of Algorithm 3 which shows that the lower pseudo-inverse is required to compute the composition between two UPP curves.

The rest of this section is organized as follows. In Section 4.1 we show that the pseudo-inverse of a UPP function is still UPP, and provide expressions to compute its UPP parameters a priori. In Section 4.2 we discuss, first through a visual example and then via pseudocode, how to algorithmically compute the pseudo-inverse. In Section 4.3 we conclude with a summary of the by-curve algorithm, some observations on the algorithmic complexity of this operator. In Section 4.4 we discuss corner cases.

4.1 Properties of pseudo-inverses of UPP functions

We discuss our properties for a generic function f, excluding the cases of UC and UI functions. These two cases are treated separately for ease of presentation. At the end of this section, we report the necessary information for the alert reader to retrace the steps exposed hereafter to include these two corner cases. We remark that the Nancy software library (Zippo and Stea 2022a) computes pseudo-inverses of generic (non-decreasing) UPP functions, including UC and UI ones.

Theorem 9

Let \(f \in \mathcal {U}\) be a non-decreasing function that is neither UC nor UI. Then, its lower pseudo-inverse \(f^{-1}_{\downarrow }(x)=\inf \left \{ t\mid f(t)\ge x\right \} \) is again a function \(\in \mathcal {U}\) with

$$ \begin{array}{@{}rcl@{}} T_{f^{-1}_{\downarrow}} & =&f\left( T_{f}+d_{f}\right), \end{array} $$
(7)
$$ \begin{array}{@{}rcl@{}} d_{f^{-1}_{\downarrow}} & =&c_{f}, \end{array} $$
(8)
$$ \begin{array}{@{}rcl@{}} c_{f^{-1}_{\downarrow}} & =&d_{f}. \end{array} $$
(9)

Proof

Let t1Tf + df and x := f(t1). Moreover, we define

$$ t_{0}:= f^{-1}_{\downarrow}(x)=\inf\left\{ t\mid f(t)\ge x\right\} =\inf\left\{ t\mid f(t)\ge f(t_{1})\right\}. $$

By definition, it is clear that t0t1 (t1 satisfies the condition inside the infimum, and t0 is its largest lower bound). Moreover, since it holds that f(t + df) = f(t) + cf for all tTf, we can conclude that, for all τTf + df,

$$ f(\tau) = f\left( (\tau - d_{f}) + d_{f}\right) = f(\tau - d_{f}) + c_{f}. $$

Thus,

$$ f(\tau - d_{f}) = f(\tau) - c_{f}. $$
(10)

Since f is non-UC (i.e., cf > 0), and we have by definition t1Tf + df, it follows that

$$ f(T_{f})\leq f(t_{1}-d_{f}) \overset{(10)}{=} f(t_{1})-c_{f} < f(t_{1})=f(t_{0}), $$

where we used in the strict inequality that f is not UC and thus t0 > Tf. Therefore, for any \(k \in \mathbb {N}\),

$$ \begin{array}{@{}rcl@{}} f^{-1}_{\downarrow}\left( x+k\cdot d_{f^{-1}_{\downarrow}}\right) & =&\inf\left\{ t\mid f(t)\ge x+k\cdot d_{f^{-1}_{\downarrow}}\right\} \\ & \overset{(8)}{=}&\inf\left\{ t\mid f(t)\ge x+k\cdot c_{f}\right\} \\ & =&\inf\left\{ t\mid f(t)\ge f(t_{1})+k\cdot c_{f}\right\} \\ & =&\inf\left\{ t\mid f(t)\ge f(t_{0})+k\cdot c_{f}\right\} \\ & =&\inf\left\{ t\mid f(t)\ge f(t_{0}+k\cdot d_{f})\right\} \\ & =&t_{0}+k\cdot d_{f}\\ & \overset{(9)}{=}&f^{-1}_{\downarrow}(x)+k\cdot c_{f^{-1}_{\downarrow}}. \end{array} $$

It follows from Theorem 9 that, in order to compute a representation \(R_{f^{-1}_{\downarrow }}\), we need only to compute \(S^{D^{\prime }}_{f^{-1}_{\downarrow }}\) where

$$ D^{\prime} = \left[0, T_{f^{-1}_{\downarrow}} + d_{f^{-1}_{\downarrow}}\right[ = \left[0, f(T_{f} + d_{f}) + c_{f}\right[. $$

If there is no left-discontinuity in Tf + 2 ⋅ df, it follows that

$$ S^{D^{\prime}}_{f^{-1}_{\downarrow}} = \left( {S^{D}_{f}}\right)^{-1}_{\downarrow}, $$

where

$$ D = \left[0, T_{f} + 2 \cdot d_{f}\right[ . $$
(11)

Otherwise, let \(x_{1} = f \left ((T_{f} + 2 \cdot d_{f})^{-} \right )\) and \(x_{2} = f \left (T_{f} + 2 \cdot d_{f} \right )\), then x1 < x2, and therefore \(S^{D^{\prime }}_{f^{-1}_{\downarrow }}\) must end with a constant segment defined in ]x1,x2[ with ordinate Tf + 2 ⋅ df. Such segment must be added manually at the end of \(\left ({S^{D}_{f}}\right )^{-1}_{\downarrow }\).

A similar result can be derived for the upper pseudo-inverse.

Theorem 10

Let \(f \in \mathcal {U}\) be a non-decreasing function that is neither UC nor UI. Then, the upper pseudo-inverse \(f^{-1}_{\uparrow }(x)=\sup \left \{ t\mid f(t)\leq x\right \} \) is again a function \(\in \mathcal {U}\) with

$$ \begin{array}{@{}rcl@{}} T_{f^{-1}_{\uparrow}} & =&f\left( T_{f}\right), \end{array} $$
(12)
$$ \begin{array}{@{}rcl@{}} d_{f^{-1}_{\uparrow}} & =&c_{f}, \end{array} $$
(13)
$$ \begin{array}{@{}rcl@{}} c_{f^{-1}_{\uparrow}} & =&d_{f}. \end{array} $$
(14)

Proof

The proof follows the same steps as the one for the lower pseudo-inverse. Let t0Tf and x := f(t0). Moreover, we define

$$ t_{1}:= f^{-1}_{\uparrow}(x)=\sup\left\{ t\mid f(t)\leq x\right\} =\sup\left\{ t\mid f(t)\leq f(t_{0})\right\}. $$

By definition, it is clear that t0t1 (t0 satisfies the condition in the supremum, and t1 is the largest to satisfy it). Since f is non-UC, and we have by definition t0Tf, it follows that

$$ f(t_{0}+d_{f}) \overset{(3)}{=}f(t_{0})+c_{f} > f(t_{0})=f(t_{1}), $$

where we used in the strict inequality that f is not ultimately constant and thus \(t_{1}<t_{0}+d_{f}<\infty \). Therefore, for any \(k \in \mathbb {N}\),

$$ \begin{array}{@{}rcl@{}} f^{-1}_{\uparrow}\left( x+k\cdot d_{f^{-1}_{\uparrow}}\right) & =&\sup\left\{ t\mid f(t)\leq x+k\cdot d_{f^{-1}_{\uparrow}}\right\} \\ & \overset{(13)}{=}&\sup\left\{ t\mid f(t)\leq x+k\cdot c_{f}\right\} \\ & =&\sup\left\{ t\mid f(t)\leq f(t_{0})+k\cdot c_{f}\right\} \\ & =&\sup\left\{ t\mid f(t)\leq f(t_{1})+k\cdot c_{f}\right\} \\ & =&\sup\left\{ t\mid f(t)\leq f(t_{1}+k\cdot d_{f})\right\} \\ & =&t_{1}+k\cdot d_{f}\\ & \overset{(14)}{=}&f^{-1}_{\uparrow}(x)+k\cdot c_{f^{-1}_{\uparrow}}. \end{array} $$

Similar to the previous theorem, it follows from Theorem 10 that, in order to compute a representation \(R_{f^{-1}_{\uparrow }}\), we need only to compute \(S^{D^{\prime }}_{f^{-1}_{\uparrow }}\), where

$$ D^{\prime} = \left[0, T_{f^{-1}_{\uparrow}} + d_{f^{-1}_{\uparrow}}\right[ = \left[0, f(T_{f}) + c_{f}\right[. $$

If there is no left-discontinuity in Tf + df, it follows that

$$ S^{D^{\prime}}_{f^{-1}_{\uparrow}} = \left( {S^{D}_{f}}\right)^{-1}_{\uparrow}, $$

where

$$ D = \left[0, T_{f} + d_{f}\right[. $$

Otherwise, let \(x_{1} = f \left ((T_{f} + d_{f})^{-} \right )\) and \(x_{2} = f \left (T_{f} + d_{f} \right )\), then x1 < x2, and therefore \(S^{D^{\prime }}_{f^{-1}_{\uparrow }}\) must end with a constant segment defined in ]x1,x2[ with ordinate Tf + df. Such segment must be added manually at the end of \(\left ({S^{D}_{f}}\right )^{-1}_{\uparrow }\). The alert reader will notice that \(T_{f^{-1}_{\downarrow }}\) and \(T_{f^{-1}_{\uparrow }}\) differ, for which we can provide the following intuitive explanation. Consider a function f so that f(t) = k,∀t ∈]a,T + b[ with a < T,b > 0. Then \(f^{-1}_{\downarrow }(k) = a\), as the lower pseudo-inverse “goes backwards” to the start of the constant segment. However, since a < T, the pseudo-periodic property does not apply for f(a), i.e., we cannot say anything about f(a + d). So, in general, we cannot say \(f^{-1}_{\downarrow }\) is pseudo-periodic from f(T), and we instead need to “skip” to the second pseudo-period so that, as in the proof, T < a < T + d. The same does not apply for \(f^{-1}_{\uparrow }\), however, since \(f^{-1}_{\uparrow }(k) = T + b\) as the upper pseudo-inverse “goes forward” to the end of the constant segment and T + b > T, thus we can rely on the pseudo-periodic property of f.

An interesting consequence of this discussion is that the representation Rf may change when we do not expect it to. From (Liebeherr 2017, p. 64), (Bouillard et al. 2018, p. 48), we know the following properties:

  • if f is left-continuous, \(\left (f^{-1}_{\downarrow }\right )^{-1}_{\downarrow } = \left (f^{-1}_{\uparrow }\right )^{-1}_{\downarrow } = f\),

  • if f is right-continuous, \(\left (f^{-1}_{\uparrow }\right )^{-1}_{\uparrow } = \left (f^{-1}_{\downarrow }\right )^{-1}_{\uparrow } = f\).

Thus, one may expect that applying the pseudo-inverse twice would lead to a function with the same representation, i.e., that \(\left (\left ({R_{f}}\right )^{-1}_{\downarrow }\right )^{-1}_{\downarrow } = R_{f}\). However, as per the discussion above, the start of the pseudo-period of the result would wove from an initial Tf to Tf + df + cf. This is unavoidable – the above example shows that there exists one case when Tf would not be the correct starting point. However, in other cases, Tf would be the correct starting point for the pseudo-periodic behavior.

This is an instance of a general issue encountered with algorithms for UPP curves – also discussed in Zippo and Stea (2022b). Generic algorithms, that make no assumptions on the shape of the operands (such as the ones presented here for the pseudo-inverse), may in general yield non-minimal representations of the result. Generally speaking, minimal representations are preferable, since the number of elements in a sequence affects the complexity of the algorithms. However, addressing the issue of representation minimization a priori when implementing NC operators is too hard (if doable at all), since one would need to make a comprehensive list of subcases, and, of course, as many formal proofs of correctness. It is instead considerably more efficient to devise a generic algorithm for an operator, neglecting minimization, and then use a simple algorithm a posteriori that minimizes the representation of the result – see Zippo and Stea (2022b).

4.2 By-sequence algorithm for pseudo-inverses

In this section we discuss the by-sequence algorithms for pseudo-inverses. We recall that with “by-sequence” we mean that the operand, and thus its result, is defined on a limited domain. Without loss of generality, we will focus on a sequence S representing a function f over an interval \(\left [0, t\right [\), with f(0) =0. Then, \(S^{-1}_{\downarrow }\) is the sequence representing \(f^{-1}_{\downarrow }\) over interval \(\left [0, f(t^{-})\right [\). The same applies to \(S^{-1}_{\uparrow }\).

The simplest case is when S is continuous and strictly increasing, hence bijective. In this case, both \(S^{-1}_{\downarrow }\) and \(S^{-1}_{\uparrow }\) are the classic inverse of S, and the algorithm consists of drawing, for each point and segment of S, its reflection over the line y = x. However, when S includes discontinuities and/or constant segments, the algorithm becomes slightly more complicated: a discontinuity in S “maps” to a constant segment in both \(S^{-1}_{\downarrow }\) and \(S^{-1}_{\uparrow }\), while a constant segment in S “maps” to a right-discontinuity in \(S^{-1}_{\downarrow }\) and a left-discontinuity in \(S^{-1}_{\uparrow }\). This is exemplified in Fig. 6.

Fig. 6
figure 6

Example of lower pseudo-inverse of a sequence S. Since S is left-continuous, \(S = \left (S^{-1}_{\downarrow }\right )^{-1}_{\downarrow }\)

We describe Algorithm 1 for the lower pseudo-inverse (the one for the upper pseudo-inverse differs in few details which we briefly discuss later). Algorithm 1 linearly scans S considering one element at a time. Based on the type of element (point or segment), as well as on its topological relationship with its predecessor, it decides what to add to \(S^{-1}_{\downarrow }\).

More in detail, there are eight possible cases, shown in Table 1, which require zero, one, two, or three elements to be added to \(S^{-1}_{\downarrow }\). These are reported in the same order in Algorithm 1. The rigorous (though cumbersome) mathematical justification for each case is instead postponed to Appendix C for the benefit of the interested reader.

Table 1 Cases to be considered in the by-sequence algorithm to compute \(S^{-1}_{\downarrow }\)

We exemplify the above algorithm with reference to the example in Fig. 6. For each of the considered steps, we will reference the case in Table 1, the line of Algorithm 1, and the relevant equations from Appendix C proving the result. Processing each element from left to right, we calculate:

  • The origin (t1,f(t1)) = (0,0) for \( f^{-1}_{\downarrow }(0) \).

  • For the segment s1 and its predecessor point p1 = (t1,f(t1)): this corresponds to Line 22 of the algorithm. Since s1 has a positive slope, we continue in Line 31. As the function is right-continuous at t1, we are in case c8. We go to Line 36 and add a segment \( s = \left (f(t_{1}^{+}), f(t_{2}^{-}), t_{1}, t_{2}\right ) \) to O. It can be verified that this follows Eq. 43.

  • For the point \(p_{2} = \left (t_{2}, f(t_{2})\right )\) and its preceding segment s1, we are in case c4, corresponding to Line 18 and we therefore append the point \( p := \left (f(t_{2}), t_{2}\right ) \) to O. It can be verified that this follows Eq. 35.

  • For the constant segment s2 with preceding point \(p_{2} = \left (t_{2}, f(t_{2})\right )\), we are in case c6, corresponding to Line 28, and no element is added. This follows Eq. 39.

  • For the point \( p_{3} = \left (t_{3}, f(t_{3})\right ) \) with preceding constant segment s2, we are in case c2, corresponding to Line 10, and no element is added. This follows Eq. 31.

  • For a segment s3 with preceding point \(\left (t_{3}, f(t_{3})\right )\), we are in case c8, Line 36, and append \( s := \left (f(t_{3}^{+}), f(t_{4}^{-}), t_{3}, t_{4}\right ) \) to O (verified in Eq. 43).

Algorithm 1
figure e

Pseudocode for lower pseudo-inverse of a finite sequence.

We note that, since \(S^{-1}_{\downarrow }\) is left-continuous, when a continuous sequence of a point, a constant segment, and a point is encountered in S, they all “map” to the inverse of the first (leftmost) point of this sequence. This justifies the fact that nothing has to be added to \(S^{-1}_{\downarrow }\) in these cases (e.g., 2 and 6).

The algorithm for \(S^{-1}_{\uparrow }\), that we omit here for brevity, differs from the one provided only in how constant segments are handled, that is, by appending the inverse of the last (rightmost) point instead of the first (recall that the upper pseudo-inverse is right-continuous). This requires the algorithm for \(S^{-1}_{\uparrow }\) to look ahead to the next element during the linear scan. We leave the (tedious, but simple) task of spelling out the minutiae of this algorithm to the interested reader.

4.3 By-curve algorithm for pseudo-inverses

We can now discuss the by-curve algorithm by combining the results presented in Sections 4.1 and 4.2. In Algorithm 2, we show the pseudocode to compute \(f^{-1}_{\downarrow }\) for a UPP function f. The analogous for upper pseudo-inverse, which we omit for brevity, can be similarly derived from the results in the sections above.

Algorithm 2
figure f

Pseudocode for lower pseudo-inverse of a UPP function.

Regarding the complexity of Algorithm 2, we note that the main cost is computing \(\left ({S^{D}_{f}}\right )^{-1}_{\downarrow }\). Since Algorithm 1 is a linear scan of the input sequence, the resulting complexity is \(\mathcal {O}\left (n\!\left ({S^{D}_{f}}\right )\right )\).

4.4 Corner cases: UC and UI functions

We conclude this section by discussing the two corner cases that we had initially left out, i.e., those when f is either Ultimately Constant (UC) or Ultimately Infinite (UI).

To obtain a representation of a UC or UI function, it is enough to find anyTf for which f(t) = C, \(C \in {\mathbb {Q}}\), (UC) or \(f(t) = +\infty \) (UI) for any tTf. Footnote 6 However, as we show in this section, the infima of the infinitely many points that verify the above play an important role in computing their pseudo-inverses. We provide formal definitions below:

Definition 11

Let \(f \in \mathcal {U}\) be UC, and let \(C := \lim _{t \rightarrow +\infty } f(t)\), \(C \in \mathbb {Q}\), be its (ultimately) constant value. Then, we define

$$ T_{C} := \inf\{T \mid f(t) = C, \forall t \ge T\} $$

to be the infimum of its pseudo-periodic starts.

Note that we use an infimum, instead of a minimum, because f may not be right-continuous in TC. In that case f(t) = C,∀t > TC, but f(TC)≠C.

Definition 12

Let \(f \in \mathcal {U}\) be UI. Then, we define:

$$ T_{I} := \inf\{T \mid f(t) = +\infty, \forall t \ge T\}, $$

and

$$ L = \left\{\begin{array}{ll} f(T_{I}),& \text{if} f(T_{I}) < +\infty, \\ f(T_{I}^{-}),& \text{if} f(T_{I}) = +\infty and T_{I} > 0, \\ 0 ,& otherwise, \end{array}\right. $$

i.e., L is the rightmost finite value of f.

Again, we use the infimum to include functions such that \(f(t) = +\infty , \forall t > T_{I}\), but \(f(T_{I}) = L < +\infty \).

As we assume in this section all functions to be non-decreasing, using Definition 11 we have that a UC function is such that

$$ \begin{array}{@{}rcl@{}} f(t) &< C, \qquad\forall t < T_{C}, \\ f(t) &= C, \qquad\forall t > T_{C}, \end{array} $$

whereas using Definition 12 a UI function is such that

$$ \begin{array}{@{}rcl@{}} f(t) &< +\infty, \qquad \forall t < T_{I}, \\ f(t) &= +\infty, \qquad \forall t > T_{I}. \end{array} $$

For these, some mathematical inconsistencies need be resolved first. For example:

  • if f is UC, Algorithm 2 would yield \(d_{f^{-1}_{\downarrow }} = 0\),

  • if f is UI, it would yield \(T_{f^{-1}_{\downarrow }} = +\infty \).

We treat these two cases in the following propositions.

Proposition 13

Let \(f \in \mathcal {U}\) be a non-decreasing, UC function with \(T_{C} \in \mathbb {Q}_{+}\). If f(TC) < C, its lower pseudo-inverse \( f^{-1}_{\downarrow }(y) \) is

$$ f^{-1}_{\downarrow}(y) = \begin{cases} \inf\left\{ x\mid f(x)\geq y\right\} = T_{C}, & \text{if } f(T_{C}) < y < C,\\ \inf\left\{ x\mid f(x)\geq y\right\} = T_{C}, & \text{if } y = C,\\ \sup\left\{ x\mid f(x) < y\right\} = +\infty, & \text{if } y > C, \end{cases} $$

and its upper pseudo-inverse \( f^{-1}_{\uparrow }(y) \) is

$$ f^{-1}_{\uparrow}(y) = \begin{cases} \inf\left\{ x\mid f(x) > y\right\} = T_{C}, & \text{if } f(T_{C}) < y < C,\\ \sup\left\{ x\mid f(x) \leq y\right\} = +\infty, & \text{if } y = C,\\ \sup\left\{ x\mid f(x) \leq y\right\} = +\infty, & \text{if } y > C. \end{cases} $$

Otherwise, i.e., if f(TC) = C, its lower pseudo-inverse \( f^{-1}_{\downarrow }(y) \) is

$$ f^{-1}_{\downarrow}(y) = \begin{cases} \inf\left\{ x\mid f(x)\geq y\right\} \leq T_{C}, & \text{if } y < C,\\ \inf\left\{ x\mid f(x)\geq y\right\} = T_{C}, & \text{if } y = C,\\ \sup\left\{ x\mid f(x) < y\right\} = +\infty, & \text{if } y > C, \end{cases} $$

and its upper pseudo-inverse \( f^{-1}_{\uparrow }(y) \) is

$$ f^{-1}_{\uparrow}(y) = \begin{cases} \sup\left\{ x\mid f(x) \leq y\right\} \leq T_{C}, & \text{if } y < C,\\ \sup\left\{ x\mid f(x) \leq y\right\} = +\infty, & \text{if } y = C,\\ \sup\left\{ x\mid f(x) \leq y\right\} = +\infty, & \text{if } y > C. \end{cases} $$

In other words, both pseudo-inverses are UI with TI = C.

Proposition 14

Let \(f \in \mathcal {U}\) be a non-decreasing, UI function with \(T_{I} \in \mathbb {Q}_{+}\). Then, its lower pseudo-inverse \( f^{-1}_{\downarrow }(y) \) is

$$ f^{-1}_{\downarrow}(y) = \begin{cases} \inf\left\{ x\mid f(x) \geq y\right\} < T_{I}, & \text{if } y < L,\\ \inf\left\{ x\mid f(x) \geq y\right\} \leq T_{I}, & \text{if } y = L,\\ \inf\left\{ x\mid f(x) \geq y\right\} = T_{I}, & \text{if } y > L, \end{cases} $$

and its upper pseudo-inverse \( f^{-1}_{\uparrow }(y) \) is

$$ f^{-1}_{\uparrow}(y) = \begin{cases} \sup\left\{ x\mid f(x) \leq y\right\} < T_{I}, & if y < L,\\ \sup\left\{ x\mid f(x) \leq y\right\} = T_{I}, & if y = L,\\ \sup\left\{ x\mid f(x) \leq y\right\} = T_{I}, & if y > L. \end{cases} $$

In other words, both pseudo-inverses are UC with TC = L.Footnote 7

Starting from the above results, one can derive the few modifications to the algorithms described so far in this section to include these two corner cases. We leave this simple (yet tedious) task to the interested reader.

5 Composition of UPP functions

In this section, we discuss the composition operator for UPP functions, i.e., (fg)(t) = f(g(t)).

Some explanations are due regarding the physical meaning of the above operation. In NC, functions are usually meant to map time to bits, hence one might legitimately wonder what the physical meaning of composition is in this setting. The answer largely depends on the object of a particular study. For instance, in the already quoted literature examples that employ composition (e.g., Tabatabaee et al. 2021; Tabatabaee and Le Boudec 2022), g maps bits to bits. Specifically, f is the (strict) service curve of a link managed by a round-robin-like scheduler, and g carves out from f the (strict) service curve for the flow under analysis. As another example, (Le Boudec and Thiran 2001, p. 128) shows that the horizontal deviation in Eq. 2 can be computed as:

$$ h(\alpha,\beta){=}\sup_{t\ge0}\left\{\beta^{-1}_{\downarrow}(\alpha(t))-t\right\} . $$
(15)

In the above, α maps time to bits, whereas \(\beta ^{-1}_{\downarrow }\) maps bits to time. Note that the above example also requires pseudo-inverses. We will show later on that pseudo-inversion is required in the algorithm for the composition operator.

This section is organized as follows. In Section 5.1 we show that the composition of UPP functions is again UPP, and provide expressions to compute its UPP parameters a priori. In Section 5.2 we discuss, first via an example and then via pseudocode, how to compute the composition algorithmically. In Section 5.3 we conclude with a summary of the by-curve algorithm and some observations on the algorithmic complexity of this operator.

5.1 Properties of composition of UPP functions

We assume that the inner function g is not UI.Footnote 8 We initially provide the result for generic f and g. Later on, we show that, if either or both are UA or UC, we can improve upon this result.

Theorem 15

Let f and g be two functions \(\in \mathcal {U}\) with g being non-negative, non-decreasing and not UI. Then, their composition h := fg is again a function \(\in \mathcal {U}\) with

$$ \begin{array}{@{}rcl@{}} T_{h} & =\max\left\{ g^{-1}_{\downarrow}(T_{f}),T_{g}\right\} , \end{array} $$
(16)
$$ \begin{array}{@{}rcl@{}} d_{h} & =p_{d_{f}}\cdot d_{g}\cdot q_{c_{g}}, \end{array} $$
(17)
$$ \begin{array}{@{}rcl@{}} c_{h} & =q_{d_{f}}\cdot p_{c_{g}}\cdot c_{f}, \end{array} $$
(18)

where \(p_{d_{f}}, p_{c_{g}}\in \mathbb {N}_{0}\), and \(q_{d_{f}},q_{c_{g}} \in \mathbb {N}\) such that \(d_{f}=\frac {p_{d_{f}}}{q_{d_{f}}}\), and \(c_{g}=\frac {p_{c_{g}}}{q_{c_{g}}}\). Note that cg ≥ 0 as g is non-decreasing.

Proof

Let \(k_{h}\in \mathbb {N}\) be arbitrary but fixed. Since g is UPP, it holds for all tTg that

$$ \begin{array}{@{}rcl@{}} h(t+k_{h}\cdot d_{h}) & =&f\left( g(t+k_{h}\cdot d_{h})\right)\\ & =&f\left( g\left( t+k_{h}\cdot\frac{d_{h}}{d_{g}}\cdot d_{g}\right)\right)\\ & \overset{(3)}{=}&f\left( g(t)+k_{h}\cdot\frac{d_{h}}{d_{g}}\cdot c_{g}\right), \end{array} $$

where we used the UPP property of g in the last line. Note that \(k_{g}:= k_{h}\cdot \frac {d_{h}}{d_{g}}\in \mathbb {N},\) since \(\frac {d_{h}}{d_{g}}\overset {(17)}{=}p_{d_{f}}\cdot q_{c_{g}} \in \mathbb {N},\) where we used the fact that df > 0. Moreover, since f is UPP, too, we have under this additional assumption of g(t) ≥ Tf that

$$ \begin{array}{@{}rcl@{}} h(t+k_{h}\cdot d_{h}) & =&f\left( g(t)+k_{h}\cdot\frac{d_{h}}{d_{g}}\cdot c_{g}\right)\\ & =&f\left( g(t)+k_{h}\cdot\frac{d_{h}\cdot c_{g}}{d_{g}\cdot d_{f}}\cdot d_{f}\right)\\ & \overset{(3)}{=}&f(g(t))+k_{h}\cdot\frac{d_{h}\cdot c_{g}}{d_{g}\cdot d_{f}}\cdot c_{f}\\ & =&h(t)+k_{h}\cdot\frac{d_{h}\cdot c_{g}\cdot c_{f}}{d_{g}\cdot d_{f}}\\ & \overset{(18)}{=}&h(t)+k_{h}\cdot c_{h}. \end{array} $$

Note that \(k_{f}:= k_{h}\cdot \frac {d_{h}\cdot c_{g}}{d_{g}\cdot d_{f}}\in \mathbb {N}_{0}\), since \(\frac {d_{h}\cdot c_{g}}{d_{g}\cdot d_{f}}\overset {(17)}{=}\frac {p_{d_{f}}}{d_{f}}\cdot q_{c_{g}}\cdot c_{g}=q_{d_{f}}\cdot p_{c_{g}}\in \mathbb {N}_{0}\) and we used that cg ≥ 0.

We set tTg and g(t) ≥ Tf, thus ensuring that both f and g are in their periodic part. Exploiting the notion of a lower pseudo-inverse and g being non-decreasing, the latter expression implies that \(t\geq g^{-1}_{\downarrow }(T_{f})\) (Liebeherr 2017, p. 62). Therefore, we require

$$ t\geq T_{h}\overset{(16)}{=}\max\left\{ g^{-1}_{\downarrow}(T_{f}),T_{g}\right\} . $$

This concludes the proof. □

Remark 16

Note that the above is also true for the particular case in which \(d_{f}\in \mathbb {N},c_{g}\in \mathbb {N}_{0}\). In fact, it follows that \(p_{d_{f}}=d_{f}\) and \(q_{c_{g}}=1\) and thus

$$ d_{h}\overset{(17)}{=}p_{d_{f}}\cdot q_{c_{g}}\cdot d_{g}=d_{f}\cdot d_{g}, $$

and the properties are then verified since \(\frac {d_{h}}{d_{g}}=d_{f}\in \mathbb {N}_{0}\) and \(\frac {d_{h}\cdot c_{g}}{d_{g}\cdot d_{f}}=c_{g}\in \mathbb {N}_{0}\). The corresponding ch is cfcg.

It follows from Theorem 15 that, in order to compute the representation Rh, we only need to compute \(S^{D_{h}}_{h}\), where

$$ D_{h} = [0, T_{h} + d_{h}[ = \left[0, \max\left\{ g^{-1}_{\downarrow}(T_{f}),T_{g}\right\} + p_{d_{f}}\cdot d_{g}\cdot q_{c_{g}} \right[. $$

It follows that

$$ S^{D_{h}}_{h} = S^{D_{f}}_{f} \circ S^{D_{g}}_{g}, $$

where

$$ \begin{aligned} D_{g} &= \left[ 0, T_{h} + d_{h} \right[, \\ D_{f} &= \left[ g(0), g\left( (T_{h} + d_{h})^{-}\right) \right]. \end{aligned} $$
(19)

The reason Df needs to be right-closed is that \(S^{D_{g}}_{g}\) may end with a constant segment. If this happens, \(\exists \overline {t} \in D_{g}\) such that \(g(\overline {t}) = g\left ((T_{h} + d_{h})^{-}\right )\), thus we will need to compute \(f \left (g \left (\overline {t} \right ) \right ) = f \left (g\left ((T_{h} + d_{h})^{-}\right ) \right )\), and that is in fact the right boundary of Df. On the other hand, if \(S^{D_{g}}_{g}\) ends with a strictly increasing segment, it is safe to have Df right-open.

Hereafter, we show that the above result can be improved when either or both functions are UA. First, we consider the case when only g is UA.

Proposition 17

Let f and g be two functions \(\in \mathcal {U}\) that are not UI, with g being non-negative, non-decreasing, UA, with ρg > 0 (hence not UC). Then, their composition h := fg is again a function \(\in \mathcal {U}\) with

$$ \begin{array}{@{}rcl@{}} T_{h} & =&\max\left\{ g^{-1}_{\downarrow}(T_{f}),T_{g}\right\} , \\ d_{h} & =& \frac{d_{f}}{\rho_{g}}, \end{array} $$
(20)
$$ \begin{array}{@{}rcl@{}} c_{h} & = &c_{f}. \end{array} $$
(21)

Proof

Let \(k_{h}\in \mathbb {N}\) be arbitrary but fixed. Since g is assumed to be UA, it holds for all tTh that

$$ \begin{array}{@{}rcl@{}} h(t+k_{h}\cdot d_{h}) & =&f\left( g(t+k_{h}\cdot d_{h})\right)\\ & \overset{(4)}{=}& f\left( g(T_{h})+\rho_{g}\cdot\left( t+k_{h}\cdot d_{h}-T_{h}\right)\right)\\ & =&f\left( \rho_{g}\cdot t+g(T_{h})-\rho_{g}\cdot T_{h}+k_{h}\cdot d_{f}\right)\\ & \overset{(3)}{=}& f\left( \rho_{g}\cdot t+g(T_{h})-\rho_{g}\cdot T_{h}\right)+k_{h}\cdot c_{f}\\ & =&f\left( g(T_{h}) + \rho_{g}\cdot\left( t-T_{h}\right)\right) + k_{h}\cdot c_{f}\\ & \overset{(4)}{=}&f\left( g(t)\right) + k_{h}\cdot c_{f}\\ & =&h(t)+k_{h}\cdot c_{h}. \end{array} $$

Again, in order to compute the representation Rh, we only need \(S_{h}^{D_{h}}\), where

$$ D_{h}=\left[0,T_{h} + d_{h}\right[=\left[0,\max\left\{ {g^{-1}_{\downarrow}} (T_{f}),T_{g}\right\} + \frac{d_{f}}{\rho_{g}} \right[. $$

It follows that

$$ S_{h}^{D_{h}}=S_{f}^{D_{f}}\circ S_{g}^{D_{g}}, $$

where

$$ \begin{array}{@{}rcl@{}} D_{g} & =&\left[0,T_{h}+d_{h}\right[\\ &\overset{(20)}{=}& \left[0,T_{h}+\frac{d_{f}}{\rho_{g}}\right[ ,\\ D_{f} & =&\left[g(0),g\left( \left( T_{h}+d_{h}\right)^{-}\right)\right[\\ & \overset{(20)}{=}&\left[g(0),g\left( T_{h}+\frac{d_{f}}{\rho_{g}}\right)\right[\\ & =&\left[g(0),g\left( T_{h}\right)+d_{f}\right[. \end{array} $$
(22)

Here, we observe that domain Df is smaller than the one obtained by applying directly Theorem 15, due to the disappearance of a factor \(q_{d_{f}} \cdot p_{c_{g}} \geq 1\). In fact, with Theorem 15 we would have:

$$ \begin{array}{@{}rcl@{}} D_{g} & =&\left[0,T_{h}+d_{h}\right[\\ & \overset{(17)}{=} &\left[0,T_{h} + p_{d_{f}} \cdot d_{g} \cdot q_{c_{g}}\right[\\ & =& \left[0,T_{h} + q_{d_{f}} \cdot p_{c_{g}} \cdot \frac{d_{f}}{\rho_{g}}\right[ ,\\ D_{f} & =&\left[g(0),g\left( \left( T_{h}+d_{h}\right)^{-}\right)\right[\\ & \overset{(17)}{=}&\left[g(0),g\left( \left( T_{h}+p_{d_{f}} \cdot d_{g} \cdot q_{c_{g}}\right)^{-}\right)\right[\\ & =&\left[g(0),g(T_{h}) + q_{d_{f}} \cdot p_{c_{g}} \cdot d_{f}\right[. \end{array} $$

As specified in the statement of Proposition 17, we exclude the case when g is UC. This is because of Eq. 20 where ρg is in the denominator, hence cannot be zero. However, if g is UC, a stronger proposition can be found as reported in Appendix D.

Next, we consider the case when only f is UA.

Proposition 18

Let \(f \in \mathcal {U}\) be UA and \(g \in \mathcal {U}\) be non-negative, non-decreasing and not UI. Then, their composition h := fg is again \(\in \mathcal {U}\) with

$$ \begin{array}{@{}rcl@{}} T_{h} & =&\max\left\{ g^{-1}_{\downarrow}(T_{f}),T_{g}\right\}, \\ d_{h} & =&d_{g}, \end{array} $$
(23)
$$ \begin{array}{@{}rcl@{}} c_{h} & =& c_{g} \cdot \rho_{f}. \end{array} $$
(24)

Proof

Let \(k_{h}\in \mathbb {N}\) be arbitrary but fixed. Since f is assumed to be UA, it holds for all tTh that

$$ \begin{array}{@{}rcl@{}} h(t+k_{h}\cdot d_{h}) & =&f\left( g(t+k_{h}\cdot d_{h})\right)\\ & \overset{(3)}{=} &f\left( g(t) + k_{h}\cdot c_{g}\right)\\ & \overset{(4)}{=}& f(g(T_{h})) + \rho_{f} \cdot \left( g(t) + k_{h}\cdot c_{g} - g(T_{h})\right)\\ & =&f(g(T_{h})) + \rho_{f} \cdot \left( g(t) - g(T_{h})\right) + k_{h} \cdot c_{g} \cdot \rho_{f}\\ & \overset{(4)}{=}& f(g(t)) + k_{h} \cdot c_{g} \cdot \rho_{f}\\ & =&h(t) + k_{h} \cdot c_{h}. \end{array} $$

Again, for representation Rh, we only compute \(S_{h}^{D_{h}}\), where

$$ D_{h}=\left[0,T_{h} + d_{h}\right[=\left[0,\max\left\{ {g^{-1}_{\downarrow}}(T_{f}),T_{g}\right\} + d_{g} \right[. $$

It follows that

$$ S_{h}^{D_{h}}=S_{f}^{D_{f}}\circ S_{g}^{D_{g}}, $$

where

$$ \begin{array}{@{}rcl@{}} D_{g} & =&\left[0,T_{h}+d_{h}\right[\\ &\overset{(23)}{=}& \left[0,T_{h}+d_{g}\right[ ,\\ D_{f} & =&\left[g(0),g\left( \left( T_{h}+d_{h}\right)^{-}\right)\right]\\ & \overset{(23)}{=} &\left[g(0),g\left( \left( T_{h}+d_{g}\right)^{-}\right)\right]. \end{array} $$
(25)

Again, domain Dg is smaller than the one that Theorem 15 would yield, due to the disappearance of a factor \(p_{d_{f}} \cdot q_{c_{g}} \geq 1\). For comparison, Theorem 15 yields

$$ \begin{array}{@{}rcl@{}} D_{g} & =&\left[0,T_{h}+d_{h}\right[\\ & \overset{(17)}{=}& \left[0,T_{h} + p_{d_{f}} \cdot q_{c_{g}} \cdot d_{g}\right[ ,\\ D_{f} & =&\left[g(0),g\left( \left( T_{h}+d_{h}\right)^{-}\right)\right]\\ & \overset{(17)}{=}& \left[g(0),g\left( \left( T_{h}+p_{d_{f}} \cdot d_{g} \cdot q_{c_{g}}\right)^{-}\right)\right]. \end{array} $$

When both functions are UA, we obtain a stronger result by showing that the composition is UA again.

Proposition 19

Let \(f \in \mathcal {U}\) and \(g\in \mathcal {U}\) be UA functions with g being non-negative, non-decreasing and not UI. Then, their composition h := fg is again UA with

$$ \begin{array}{@{}rcl@{}} {T_{h}^{a}} & =&\max\left\{ g^{-1}_{\downarrow}({T_{f}^{a}}),{T_{g}^{a}}\right\} , \\ \rho_{h} & =&\rho_{f}\cdot\rho_{g}. \end{array} $$
(26)

Proof

If f is UI, the result is trivial. Let us assume that f is not UI. Define \({T_{h}^{a}}:=\max \limits \left \{ g^{-1}_{\downarrow }({T_{f}^{a}}),{T_{g}^{a}}\right \} \). Then we have that, for any \(t \ge {T_{h}^{a}}\),

$$ \begin{array}{@{}rcl@{}} h(t+{T_{h}^{a}}) & =&f\left( g(t+{T_{h}^{a}}) \right)\\ & \overset{(4)}{=}&f\left( g({T_{h}^{a}}) + \rho_{g} \cdot (t - {T_{h}^{a}}) \right)\\ & \overset{(4)}{=}&f(g({T_{h}^{a}})) + \rho_{f} \cdot \left( \left( g({T_{h}^{a}}) + \rho_{g} \cdot (t - {T_{h}^{a}})\right) - g({T_{h}^{a}}) \right)\\ & =& f(g({T_{h}^{a}})) + \rho_{f} \cdot \rho_{g} \cdot (t - {T_{h}^{a}}) \\ & =& h({T_{h}^{a}}) + \rho_{f} \cdot \rho_{g} \cdot (t - {T_{h}^{a}}). \end{array} $$

Considering Eq. 19, we observe how taking these results into account will yield tighter Df,Dg than what we obtain with Theorem 15.

Finally, we mention that, if either or both f and g are UC, then the composition can be simplified further, even with respect to the above properties. We report the results in Appendix D.

5.2 By-sequence algorithm for composition

In this section, we discuss the by-sequence algorithm for the composition. Without loss of generality, we focus on sequences Sg, representing a non-negative and non-decreasing function g over an interval \(\left [0, t\right [\), and Sf, representing a function f defined over the interval \(\left [g(0), g(t^{-})\right ]\).Footnote 9 Then, Sh = SfSg is the sequence representing h = fg over the interval \(\left [0, t\right [\). We use the example shown in Fig. 7, where t =6 and g(t) =4.

Fig. 7
figure 7

Example of composition of two sequences

First, we consider the shape of fg on an interval \(\left ]a,b\right [ \subset \left [0, t\right [\), \(a,b\in \mathbb {Q}_{+}\). Consider the case in which, for this interval, there exist \(\rho _{g},\rho _{f}\in \mathbb {Q}_{+}\) so that

$$ \begin{aligned}g(x) & =g(a^{+})+\rho_{g} \cdot (x-a), \qquad\forall x\in\left]a,b\right[,\\ f(x) & =f\left( g(a^{+}){}^{+}\right)+\rho_{f} \cdot \left( x-g(a^{+})\right), \qquad\forall x\in\left]g(a^{+}),g(b^{-})\right[, \end{aligned} $$
(27)

where we use the shorthand notation

$$ f\left( g(a^{+}){}^{+}\right) = \lim_{x\to a^{+}}f\left( g(x)\right) = \lim_{y\to y_{0}}f(y), $$

with \(y_{0}:=\lim _{x\to a^{+}}g(x)\).

More broadly speaking, we have segment of g mapping to a segment of f. In the example of Fig. 7, ]4,6[ is such an interval. Then, in this interval we can apply the chain rule and find that \(h^{\prime }(x)=f^{\prime }(g(x))\cdot g^{\prime }(x)=\rho _{g}\cdot \rho _{f}\) for all \(x\in \left ]a,b\right [\). Thus, h is also a segment on \(\left ]a,b\right [\).

If either of the equations in Eq. 27 does not apply, it means that one function has one or more breakpoints over this interval. Assume initially that this is g. Let this finite sets of breakpoints be \(t_{0},\dots ,t_{n}\), with a < t0 < ⋯ < tn < b. Then, the intervals \(\left ]a,t_{0}\right [,\dots ,\left ]t_{n},b\right [\) verify the properties in Eq. 27 while for any breakpoint ti we can just compute f(g(ti)). A similar reasoning can be done for f: consider the finite set of breakpoints \(y_{0},\dots ,y_{m}\), with g(a+) < y0 < ⋯ < ym < g(b). Then, we can use the lower pseudo-inverse of g to find the corresponding \(\overline {t}_{i}=g^{-1}_{\downarrow }(y_{i})\).Footnote 10 The set \(\left \{ t_{1},\dots ,t_{n}\right \} \cup \left \{ \overline {t}_{1},\dots ,\overline {t}_{m}\right \}\), preserving the ascending order, defines a finite set of breakpoints for fg. Then, we have again a finite set of points \(\left (t_{i}, f(g(t_{i}))\right )\), and open intervals for which we compute h as a segment with ρh = ρfρg. In the example of Fig. 7, ]0,4[ is such an interval:

  • for Sg we find the set {t1 =1};

  • for Sf we find the set \(\{y_{1} = 1\} \rightarrow \left \{ \overline {t}_{1} = \frac {1}{2} \right \}\);

  • the combined set of breakpoints is then \(\left \{ \frac {1}{2}, 1 \right \}\), and the open intervals that verify Eq. 27 is \(\left \{ \left ]0, \frac {1}{2}\right [, \left ]\frac {1}{2}, 1\right [, ]1, 4[ \right \}\).

By generalizing this reasoning, we obtain Algorithm 3.

Algorithm 3
figure g

Pseudocode for the composition of finite sequences.

5.3 By-curve algorithm for composition

We can now discuss the by-curve algorithm, by combining the results presented in Sections 5.1 and 5.2. In Algorithm 4 we show the pseudocode to compute the composition h = fg of UPP functions f and g, in the most general case. The analogous for the more specialized cases, i.e., ultimately affine or ultimately constant operands, which here we omit for brevity, can be similarly derived by adjusting the parameter and domain computations.

Algorithm 4
figure h

Pseudocode for composition of UPP functions.

Regarding the complexity of Algorithm 4, we note that the main cost is computing \(S_{h} \gets S^{D_{f}}_{f} \circ S^{D_{g}}_{g}\). Since Algorithm 3 is a linear scan of \(S^{D_{f}}_{f}\) and \(S^{D_{g}}_{g}\), the resulting complexity is \(\mathcal {O}\left (n\!\left (S^{D_{f}}_{f}\right ) + n\!\left (S^{D_{g}}_{g}\right )\right )\). Note that given the expressions in Theorem 15, this computational cost highly depends on the numerical properties of the operands, i.e., numerators and denominators of UPP parameters, rather than simply the cardinalities of Rf and Rg. Thus, using the specialized properties of Propositions 17 to 19 yields performance improvements, since Df and Dg are smaller.

We remark again that the result of the composition may have a non-minimal representation (see the discussion at the end of Section 4.1).

6 Proof of concept

In this section, we show how the algorithms presented in this paper allow one to replicate the result appeared in a recent NC paper (Tabatabaee et al. 2021).

The algorithms described in this paper, including variants and corner cases omitted for brevity, are implemented in the publicly available Nancy NC library (Zippo and Stea 2022a). Nancy is a C# library implementing the UPP model and its operators, as described in Bouillard and Thierry (2008) and Bouillard et al. (2018). Moreover, it implements state-of-the-art algorithms that improve the efficiency of NC operators, described in Zippo and Stea (2022b), and lower pseudo-inverse, upper pseudo-inverse and composition operators, described in this paper. Nancy makes extensive use of parallelism. However, the NC operators described in this paper are implemented as sequential.

As a notable example, we implemented the results from (Tabatabaee et al. 2021, Theorem 1), which uses the composition operator, using the same parameters of the example in (Tabatabaee et al. 2021, Fig. 3). The above theorem allows us to compute the service curve for a flow served by an Interleaved Weighted Round-Robin scheduler, once a) the weight of the flow; b) the minimum and maximum packet length for each flow, and c) the (strict) service curve for the entire aggregate of flows β(t) are known. The complete formulation of the theorem – which is rather cumbersome – is postponed to Appendix E. For the purpose of this proof of concept, the important bit is that computing the service curve of the flow involves computing a function γi that takes into account flow i’s characteristics (e.g., weight, packet lengths), and then, given β as the (strict) service curve of the server regulated by IWRR, computing the (strict) per-flow service curve for flow i as βi = γiβ.Footnote 11 In the example in (Tabatabaee et al. 2021, Fig. 3), β is a constant-rate service curve, thus UA, while γi is, in general, a UPP function. On the one hand, this confirms that limiting NC algorithms to UA curves only is severely constraining – in this example, one could not compute flow i’s service curve without an algorithm that handles UPP curves. On the other hand, it means that we can obtain the same result by applying both Theorem 15 and its specialized version for UA inner functions Proposition 17, and that we can expect the latter to be more efficient due to the tighter Df, as explained below Eq. 22.

Our experiments confirm the above intuition. We run the computation on a laptop computer (i7-10750H, 32 GB RAM). As shown in Table 2, when using Theorem 15, computing the result took a median of 1.11 seconds. On the other hand, using Proposition 17 the same result is obtained in 0.55 milliseconds in the median, an improvement of three orders of magnitude. Listing 1 and Fig. 8 report, respectively, the code used and the resulting plot.

Table 2 Performance comparison of composition with and without UA optimization
Fig. 8
figure 8

Plot of the resulting service curve βi

It is worth noting that (Tabatabaee and Le Boudec 2022, Theorem 1) describes a similar result for the Deficit Round-Robin scheduler, under similar hypotheses, still making use of composition, with the outer curve being non-UA. The derivations in this section apply to this case as well, with minimal obvious modifications. Several other results in (Tabatabaee and Le Boudec 2022) make use of composition as well.

Listing 1
figure i

Code used to replicate the results of (Tabatabaee et al. 2021, Theorem 1)

7 Conclusions

Automated computation of Network Calculus operations is necessary to carry out analyses of non-trivial network scenarios. Therefore, algorithms that transform representations of operand functions into result functions are required for each “useful” NC operator. Recently, pseudo-inverses and composition operators have been repeatedly used in NC papers. To the best of our knowledge, these operators lacked an algorithmic description that would allow their implementation in software.

This paper fills the above gap, by providing algorithms for lower and upper pseudo-inverses and composition of operators. We have presented algorithms that work under general assumptions (i.e., UPP operands), as well as specialized ones that leverage the fact that operands are UA (or UC) to compute results faster. We have discussed the complexity of these algorithms, as well as corner cases, with a rigorous mathematical exposition. Beside the theoretical contribution, we provided a practical one by including the above algorithms (together with the others known from the literature) in an open-source free library called Nancy. This allows researchers to experiment with our results to study complex scenarios, or support the generation of novel theoretical insight.

Future work on this topic will include studying the computational and numerical properties of NC operators. As the example in Section 6 shows (not to mention those in (Zippo and Stea 2022b), by the same authors), exploiting more knowledge on the operands allows one to compute the same results via specialized versions of the algorithms, often in considerably shorter times (some by orders of magnitude). We believe that this is an avenue of research worth pursuing, with the aim of enabling larger-scale real-world performance studies.