Extending the network calculus algorithmic toolbox for ultimately pseudo-periodic functions: pseudo-inverse and composition

Network Calculus (NC) is an algebraic theory that represents traffic and service guarantees as curves in a Cartesian plane, in order to compute performance guarantees for flows traversing a network. NC uses transformation operations, e.g., min-plus convolution of two curves, to model how the traffic profile changes with the traversal of network nodes. Such operations, while mathematically well-defined, can quickly become unmanageable to compute using simple pen and paper for any non-trivial case, hence the need for algorithmic descriptions. Previous work identified the class of piecewise affine functions which are ultimately pseudo-periodic (UPP) as being closed under the main NC operations and able to be described finitely. Algorithms that embody NC operations taking as operands UPP curves have been defined and proved correct, thus enabling software implementations of these operations. However, recent advancements in NC make use of operations, namely the lower pseudo-inverse, upper pseudo-inverse, and composition, that are well-defined from an algebraic standpoint, but whose algorithmic aspects have not been addressed yet. In this paper, we introduce algorithms for the above operations when operands are UPP curves, thus extending the available algorithmic toolbox for NC. We discuss the algorithmic properties of these operations, providing formal proofs of correctness.


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 worstcase 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 [1,2], Le Boudec and Thiran [3], and Chang [4].Originally devised for the Internet, where it was used to engineer models of service [5][6][7][8][9], it has found applications in several other contexts, from sensor networks [10] to avionic networks [11,12], industrial networks [13][14][15] automotive systems [16] and systems architecture [17,18].
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. 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, [19,20] 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, minplus deconvolution, etc. (see [20] for a complete list).The toolbox was first implemented in the COINC free library [21], which is not available anymore, and later by the commercial library RTaW-Pegase [22].
However, other NC operators, i.e., the composition and lower and upper pseudo-inverse, have been in focus in recent NC literature.[23] 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.In [20,Theorem 8.6], lower pseudo-inverse and composition are used to compute the per-flow service curve for a Weighted Round-Robin scheduler; in [24, Theorem 1], a similar result is shown for a Interleaved Weighted Round-Robin scheduler, using again lower pseudo-inverse and composition; in [25], authors show that several service curves can be found for a flow scheduled in a Deficit Round-Robin scheduler, under different hypotheses regarding crosstraffic.[26,27] use pseudo-inverses and compositions to study properties of IEEE Time-Sensitive Networking (TSN) [28], a standard relevant for many applications.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) [20].Last, we exemplify our findings on a comprehensive proof of concept, showing how to compute the per-flow service curve of [24, Theorem 1], which makes use of all the findings in this paper.The algorithms described in this paper, together with those for known NC operators, are implemented in the Nancy open-source toolbox [29], 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 Network Calculus 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.Extending the NC Algorithmic Toolbox for UPP Functions bits Fig. 1: Example of leaky-bucket shaper, taken from [17].The traffic process A(t) is always below the arrival curve α(t) and its translations along A(t).

Network Calculus Basics
This section briefly introduces Network Calculus (NC).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 wide-sense increasing.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 wide-sense increasing function α is an arrival curve for a flow A if For instance, a leaky-bucket shaper, with a rate ρ and a burst size σ, enforces the concave affine arrival curve γ σ,ρ (t) = σ + ρt, as shown in Figure 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 traffic injected does not overflow the negotiated amount.
Fig. 3: Graphical example of a delay bound.
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.If that node does not create data internally (which is often the case), causality requires that A ≥ D. We say that the flow is guaranteed the (minimum) service curve β if We call the operation on the right the (min-plus) convolution of A and β.The function argument t is omitted whenever it is clear from the context.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 + for some rate R > 0 and latency θ > 0. Notation [•] + denotes max {•, 0}.For instance, a constant-rate server (e.g., a wired link) can be modeled as a rate-latency curve with zero latency.Figure 2 shows the lower bound of D(t) obtained when convolving the input A(t) with a rate-latency service curve.
A point of strength of NC is that service curves are composable: the endto-end service curve of a tandem of nodes traversed by the same flow can be computed as the 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), a tight upper bound on the delay can be computed by combining its arrival curve α and the service curve β itself, as follows: The quantity h(α, β) is in fact the maximum horizontal distance between α and β, as shown in Figure 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.
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 [19,20].The next section describes the generic algorithmic framework exposed in these papers, which we extend in this work.

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 [19,20], a sufficiently generic class of functions useful for NC computations is that of (i) piecewise affine (ii) ultimately pseudo-periodic Q + → Q functions.We define both properties (i) and (ii) separately: Definition 1 (Piecewise Affine Function [19, p. 9]) We say that a function f is piecewise affine (PA) if there exists an increasing sequence (a i ) i∈N which tends to +∞, such that a 0 = 0 and ∀i ≥ 0, f is affine on ]a i , a i+1 [i.e., f (t) ∈ {b i + ρ i t, +∞, −∞} , ∀t ∈ ]a i , a i+1 [ .The a i 's are called breakpoints.
Definition 2 (Ultimately Pseudo-Periodic Function [19, p. 8] ) Let f be a function (3) We call T f the (pseudo-periodic) start or length of the initial transient, d f the (pseudo-periodic) length, and c f the (pseudo-periodic) height.
In [19], this class of functions is shown to be stable w.r.t.all min-plus operations, while functions R + → R are not. 2 Henceforth, we will consider all functions to be 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 Figure 4.
Accordingly, we call a representation R f of a function f the tuple (S, T, d, c), where T, d, c are the values described above, and S is a sequence Definition 4 (Segment) We define a segment as a tuple If r = 0, we call s i a constant segment.
Definition 5 (Sequence) We define a sequence S D f as on ordered set of elements e 1 , . . ., en that alternate between points and segments and describe f in the finite interval D.
For example, given D = [0, T [, then S D f = {p 1 , s 1 , p 2 , . . ., p n , s n } where p 1 = (0, f (0)) and, assuming p n = (t n , f (t n )) for some 0 < t n < T , s n = (t n , T, f (t + n ), f (T − )).Note that, given R f , one can compute f (t) for all t ≥ 0, and also S D f for any interval D. Furthermore, being finite, R f can be used as a data structure to represent f in code.As is discussed in depth in [30], R f is not unique, and using a non-minimal representation of f can affect the efficiency of the computations.Given a sequence S, let n(S) be its cardinality.As it is useful in the following, we define Cut to be an (obvious) algorithm that, given R f 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 pseudoinverse of f , (f ) −1 ↓ (its formal definition is in the next section), we will write , 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 an 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 R f , i.e., R f → R f * .We call this by-curve algorithm.This process can be divided in the following steps: 1. compute valid parameters T f * , d f * and c f * for the result; 2. compute the domain D for the sequence , use an algorithm that computes the resulting sequence from the sequence of the operand.We call this by-sequence algorithm for operator We therefore need to provide the following results: • a proof that the result of the operator [•] * , applied to an UPP function, yields an UPP result; • a way to compute UPP parameters T f * , d f * and c f * from R f ; • a valid domain D, again to be computed from R f ; • a by-sequence algorithm.Combining the above results, we can then construct the by-curve algorithm for operator [•] * , thus allowing us to compute [•] * for any UPP curve. 3orks [19,20] 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.
Note that this definition differs from the one in the literature [19], 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 a f .They occur quite often in NC, e.g., the arrival curve of a leakybucket shaper or a rate-latency service curve are both UA.An Ultimately Constant (UC) function is UA with ρ f = 0.
Unlike UPP, the class of UA functions is not closed with respect to NC operations.For instance, [30] shows that flow-controlled networks with ratelatency (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., [24,25,31]).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., [32].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 [33,34].Throughout this paper, we provide general algorithms for UPP functions.However, we also show what is to be gainedin terms of domain compactness and/or algorithmic efficiency -when we can make stronger assumptions on the operands.
then we call this function a weakly ultimately infinite (wUI) one.
Weakly ultimately infinite functions are infinite starting from a finite abscissa.Typical cases in NC are the service curves of delay elements.Note that the above definition differs from the one of ultimately infinite in [19]: the latter requires f to be infinite in T f (i.e., it has a weak inequality in the lower branch), whereas we do not mandate anything in T f .Therefore, every ultimately infinite function is wUI too, but not vice versa.Our more general definition allows us to better discuss corner cases in Section 4.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 8 (Lower and Upper Pseudo-Inverse [23]) Let f : Q → Q ∪ {−∞} ∪ {∞} be non-decreasing.Then the lower pseudo-inverse is defined as and the upper pseudo-inverse is defined as Note that the lower pseudo-inverse is always left-continuous and the upper pseudo-inverse is right-continuous [23, pp. 64].Moreover, we have in general that [23, pp. 61 The rest of this section is organized as follows.In Section 4.1 we show that the pseudo-inverse of an UPP function is still UPP, and provide expressions to compute its UPP parameters a priori.In Section 4.2 we discuss, first through an visual example and then via pseudo-code, 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.

Properties of pseudo-inverses of UPP functions
We discuss our properties for a generic function f , excluding the cases of UC and wUI 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 [29] computes pseudo-inverses of generic (non-decreasing) UPP functions, including UC and wUI ones.
Theorem 9 Let f be a non-decreasing UPP function that is neither UC nor wUI.Then, its lower pseudo-inverse By definition, it is clear that t 0 ≤ t 1 (t 1 satisfies the condition in the infimum, and t 0 is the smallest to satisfy it).Since f is non-UC and we have by definition where we used in the strict inequality that f is not UC and thus t 0 > T f .Therefore, It follows from Theorem 9 that, in order to compute a representation where Otherwise, let and therefore must end with a constant segment defined in ]x 1 , x 2 [ with ordinate T f + 2 • d f .Such segment must be added manually at the end of A similar result can be derived for the upper pseudo-inverse.
Theorem 10 Let f be a non-decreasing UPP function that is not UC.Then, the upper pseudo-inverse Proof The proof follows the same steps as the one for the lower pseudo-inverse.Let t 0 ≥ T f and x := f (t 0 ).Moreover, we define t By definition, it is clear that t 0 ≤ t 1 (t 0 satisfies the condition in the supremum, and t 1 is the largest to satisfy it).Since f is non-UC and we have by definition t 0 ≥ T f , it follows that where we used in the strict inequality that f is not ultimately constant and thus Similar to the previous theorem, it follows from Theorem 10 that, in order to compute a representation , where differ, for which we can provide the following intuitive explanation.Consider a function f so that 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 ↓ 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 ↑ , however, since f −1 ↑ (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 R f may change when we do not expect it to.From [23, pp. 64], [20, p. 48], we know the following properties: Thus, one may expect that applying the pseudo-inverse twice would lead to a function with the same representation, i.e., that (R f ) . However, as per the discussion above, the start of the pseudo-period of the result would go from an initial T f to T f + d f + c f .This is unavoidable -the above example shows that there exists one case when T f would not be the correct starting point.However, in other cases, T f 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 [30].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 [30].

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 [0, t[, with f (0) = 0.
↑ .The simplest case is when S is continuous and strictly increasing, hence bijective.In this case, both S −1 ↓ and S −1 ↑ 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 slighlty more complicated: a discontinuity in S "maps" to a constant segment in both S −1 ↓ and S −1 ↑ , while a constant segment in S "maps" to a right-discontinuity in S −1 ↓ and a left-discontinuity in S −1 ↑ .This is exemplified in Figure 5.
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 elements 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 ↓ .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 ↓ .These are reported in the same order in Algorithm 1.The rigorous (though cumbersome) mathematical justification for each case is instead postponed to Appendix B for the benefit of the interested reader.
We exemplify the above algorithm with reference to the example in Figure 5.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 B proving the result.Processing each element from left to right, we calculate: • The origin (t 1 , f (t 1 )) = (0, 0) for f −1 ↓ (0) • for the segment s 1 and its predecessor point p 1 = (t  39)).We note that, since S −1 ↓ 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 ↓ in these cases (e.g., 2 and 6).The algorithm for S −1 ↑ , 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 ↑ 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.The for loop starts after the origin The element is a point Append Append Nothing to append (c2) 12: end if 13: Append else f is left-cont.at t i

19:
Append p := (f (t i ), t i ) to O (c4) if e k = s i is constant then Append Nothing to append (c6)

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 pseudo-code to compute f −1 ↓ 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 Pseudo-code for lower pseudo-inverse of a UPP function Input Representation R f of a non-decreasing UPP function f , consisting of sequence S f and parameters T f , d f and c f .
Compute the UPP parameters for the result Theorem 9 2: Regarding the complexity of Algorithm 2, we note that the main cost is . Since Algorithm 1 is a linear scan of the input sequence, the resulting complexity is O n S D f .

Corner cases: UC and wUI functions
We conclude this section by discussing the two corner cases that we had initially left out, i.e., those when f is either UC or wUI.For these, some mathematical inconsistencies need be resolved first.For example: • if f was UC, the current algorithm would yield We treat these two cases in the following propositions.
and its upper pseudo-inverse Note that, if one follows Definition 7, the result of both operators is weakly ultimately infinite, while only f −1 ↑ is ultimately infinite.
Proposition 12 Let f : Q + → Q + ∪ {+∞} be a non-decreasing, weakly ultimately infinite function with T f ∈ Q + .We recall that this is defined as Then, its lower pseudo-inverse In other words, both pseudo-inverses are UC.
Again, by using Definition 7, we show that the above property applies to weakly ultimately infinite functions, not only to ultimately infinite ones.
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.

Composition of UPP Functions
In this section, we discuss the composition operator for UPP functions, i.e., (f •g)(t) = f (g(t)).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 pseudo-code, 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.

Properties of composition of UPP functions
We assume that the inner function g is not wUI. 4We 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 13 Let f and g be two UPP functions with g being non-negative, nondecreasing and not wUI.Then, their composition h := f • g is again UPP with Proof Let k h ∈ N be arbitrary but fixed.Since g is UPP, it holds for all t ≥ Tg that where we used the UPP property of g in the last line.Note that kg where we used that d f > 0.Moreover, since f is UPP, too, we have under this additional assumption of g(t) ≥ T f that and we used that cg ≥ 0 as g is non-decreasing.
We set t ≥ Tg and g(t) ≥ T f , 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 is equivalent to t ≥ g −1 ↓ (T f ) [23, p. 62].Therefore, we require = max g −1 ↓ (T f ), Tg .This concludes the proof.Remark 14 Note that the above is also true for the particular case in which d f ∈ N, cg ∈ N 0 .In fact, it follows that N d f = d f and Dc g = 1 and thus and the properties are then verified since d h dg = d f ∈ N and It follows from Theorem 13 that, in order to compute the representation R h , we only need to compute S D h h where It follows that The reason D f needs to be right-closed is that S Dg g may end with a constant segment.If this happens, ∃t ∈ D g so that g(t) = g ((T h + d h ) − ) thus we will need to compute f g t = f (g ((T h + d h ) − )), and that is in fact the right boundary of D f .On the other hand, if S Dg g ends with a strictly increasing segment, it is safe to have D f right-open.
Hereafter, we show that the above result can be improved when either or both functions are UA.First, we consider the case for which only g is UA.
Proposition 15 Let f and g be two UPP functions that are not wUI, with g being non-negative, non-decreasing, UA, with ρg > 0 (hence not UC).Then, their composition h := f • g is again UPP with Proof Let k h ∈ N be arbitrary but fixed.Since g is assumed to be UA, it holds for all t ≥ T h that Again, in order to compute the representation R h , we only need S D h h , where

It follows that
Here, we observe that domain D f is smaller than the one obtained by applying directly Theorem 13, due to the disappearance of a factor In fact, with Theorem 13 we would have: = 0, As specified in the statement of Proposition 15, we exclude the case for which g is UC.This is because of Equation ( 16) 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 C.
Next, we consider the case in which only f is UA.
Proposition 16 Let f be UA and g be an UPP function that is non-negative, nondecreasing and not wUI.Then, their composition h := f • g is again UPP with Proof Let k h ∈ N be arbitrary but fixed.Since f is assumed to be UA, it holds for all t ≥ T h that Again, for the representation R h , we only compute S D h h , where

It follows that
= g(0), g Again, domain D g is smaller than the one that Theorem 13 would yield, due to the disappearance of a factor For comparison, Theorem 13 yields = 0, When both functions are UA, we obtain a stronger result by showing that the composition is UA again.
Proposition 17 Let f and g be UA functions with g being non-negative, nondecreasing and not wUI.Then, their composition h := f • g is again UA with Proof If f is ultimately −∞ or +∞ or if g is ultimately +∞, the result is trivial.Let us assume that f and g are not wUI.Define T a h := max g −1 ↓ (T a f ), T a g .Then we have that for any t ≥ T a h Considering Equation ( 15), we observe how taking these results into account will yield tighter D f , D g than what we obtain with Theorem 13.
Finally, we mention that, if either or both f and g are UC, then the composition can be simplifed further, even with respect to the above properties.We report the results in Appendix C.

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 S g , representing a non-negative and non-decreasing function g over an interval [0, t[, and S f , representing a function f defined on over the interval [g(0), g(t − )]. 5 Then, S h = S f • S g is the sequence representing h = f • g over the interval [0, t[.We use the example shown in Figure 6, where t = 6 and g(t − ) = 4.
First, we consider the shape of f • g on an interval ]a, b[ ⊂ [0, t[, a, b ∈ Q + .Consider the case in which, for this interval, there exist ρ g , ρ f ∈ Q + so that where we use the shorthand notation with y 0 := lim x→a + g(x).
More broadly speaking, we have segment of g mapping to a segment of f .In the example of Figure 6, ]4, 6[ is such an interval.Then, in this interval we can apply the chain rule and find that h If either of the equations in (23) does not apply, it means that one function has one or more breakpoints over this interval.Assume initially that this be g.Let this finite sets of breakpoints be t 0 , . . ., t n , with a < t 0 < • • • < t n < b.
Then, the intervals ]a, t 0 [ , . . ., ]t n , b[ verify the properties in Equation ( 23) while for any breakpoint t i we can just compute f (g(t i )).A similar reasoning can be done for f : consider the finite set of breakpoints y 0 , . . ., y m , with g(a ).Then, we can use the lower pseudo-inverse of g to find the corresponding t i = g −1 ↓ (y i ). 6The set {t 1 , . . ., t n } ∪ t 1 , . . ., t m , preserving the ascending order, defines a finite set of breakpoints for f • g.Then, we have again a finite set of points (t i , f (g(t i ))), and open intervals for which we compute h as a segment with ρ h = ρ f •ρ g .In the example of Figure 6, ]0, 4[ is such an interval: • for S g we find the set {t 1 = 1} • for S f we find the set • the combined set of breakpoints is then 1 2 , 1 , and the open intervals that verify Equation ( 23) is 0, 1  2 , 1 2 , 1 , ]1, 4[ By generalizing this reasoning, we obtain Algorithm 3.
6 Following the discussion in Section 4, (Sg) −1 ↓ is sufficient for this computation.

Algorithm 3 Pseudo-code for the composition of finite sequences
Input Two finite sequences of elements, S f of f and S g of g, so that S g defined on [0, a[ and S f defined on [g(0), g(a − )].
Return Composition S h = S f • S g consisting of a sequence of elements O = {o 1 , . . ., o m } 1: Define an empty sequence of elements O := { } 2: Let T be an empty, but ordered set of distinct rationals 3: Let P g be the set of points of S g 4: for p i in P g do 5: Add the time t i of p i to T 6: end for 7: Let P f be the set of points of S f , excluding the last point g(a − ) 8: for p i in P f do 9: Given time t i of p i , add t i = g −1 ↓ (t i ) to T preserving the order in T 10: end for 11: for each pair of consecutive (t i , t i+1 ) in T do

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 pseudo-code to compute the composition h = f • g 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 parameters and domains computations.
Regarding the complexity of Algorithm 4, we note that the main cost is computing S h ← S .Note that given the expressions in Theorem 13, 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 R f and R g .Thus, using the specialized properties of Propositions 15 to 17 yields performance improvements, since D f and D g are smaller.
We remark again that the result of the composition may have a nonminimal representation (see the discussion at the end of Section 4.1).

Proof of Concept
In this section, we show how the algorithms computed in this paper allow one to replicate the result appeared in a recent NC paper [24].
The algorithms described in this paper, including variants and corner cases omitted for brevity, are implemented in the publicly available Nancy Algorithm 4 Pseudo-code for composition of UPP functions.
Input Representation R f of a UPP function f , consisting of sequence S f and parameters T f , d f and c f ; Representation R g of a non-negative and nondecreasing UPP function g, consisting of sequence S g and parameters T g , d g and c g Return Representation R h of h = f • g 1: Compute the UPP parameters for the result Theorem 13 2: T h ← max g −1 ↓ (T f ), T g 3: and S

Dg g
Equation ( 15) 6: NC library [29].Nancy is a C# library implementing the UPP model and its operators, as described in [19,20].Moreover, it implements state-of-theart algorithms that improve the efficiency of NC operators, described in [30], 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 [24, Theorem 1], which uses the composition operator, using the same parameters of the example in [24,Figure 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 D. 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, compute the (strict) per-flow service curve for flow i as β i = γ i • β. 7 In the example in [24, Figure 3], β is a constantrate 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 13 and its specialized version for UA inner functions Proposition 15, and that we can expect the latter to be more efficient due to the tighter D f , as explained below Equation (18).
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 13, computing the result took a median of 1.11 seconds.On the other hand, using Proposition 15 the same result is obtained in 0.55 milliseconds in the median, an improvement of three orders of magnitude.Figures 7 and 8 report the code used and the resulting plot.
It is worth noting that [25, 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 [25] make use of composition as well.

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 use 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 [30], 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.

A Properties of Ultimately Affine Functions
Proposition 18 A function f is ultimately affine iff there exist T Proof "⇒" Let f be ultimately affine.Define T = T a f , σ = f (T a f ) and ρ = ρ f .Then, it holds for all t > T that "⇐" Assume f to verify the condition in Equation (24).If f (t) ∈ {−∞, +∞} , the proof is trivial.Let us therefore assume that f (t) = ρt + σ for all t > T .Define T a f = T, ρ f = ρ.Then for all t > 0 This concludes the proof.

B Calculation of Lower Pseudo-Inverses
We report here the rigorous mathematical derivations for cases c1-c8 in Table 1.

Point after segment (cases c1-c4)
In these cases we have, in general, an f such that It holds that and Case c2: ρ = 0 and b 1 = b 2 = b 3 (constant segment without any discontinuity).
It holds that (however, we do not add a value as it is processed in the "segment after point"section) and Case c3: ρ > 0 and b 2 < b 3 (non-constant segment followed by a discontinuity).
and Then it holds that (however, we do not add a value as it is processed in the "point after segment"section) and Case c7: b 1 < b 2 and ρ > 0 (discontinuity followed by a non-constant segment).Then, inf {x | b 2 + ρ (x − t 1 ) ≥ y} = y−b2 ρ , if b 2 < y < b 3 (37) and

C Composition of Ultimately Constant Functions
Proposition 19 Let f and g be two ultimately pseudo-periodic (UPP) functions that are not wUI with g being non-negative, non-decreasing and ultimately constant (UC).Then, their composition h := f • g is again UC with Proof For t ≥ Tg, it holds that h(t) = f (g(t)) = f (g(Tg)) = h(T h ).
Proposition 20 Let f be UC and g be UPP function that is non-negative and nondecreasing.Then, their composition h := f • g is again UC with Proof For t ≥ g −1 ↓ (T f ), it holds that h(t) = f (g(t)) = f (T f ) = h(T h ).
Proposition 21 Let f and g be UC functions with g being non-negative, nondecreasing.Then, their composition h := f • g is again UC with Proof The proof is simply a combination of the previous two propositions.

D Service Curve of a Flow in Interleaved Weighted Round Robin
We report here the statement of Theorem 1 in [24], for ease of reference.We slightly rephrased it to aid comprehension.

Fig. 4 :
Fig. 4: Example of ultimately pseudo-periodic piecewise affine function f and its representation R f . p

1 ↑ 1 ↑.
and therefore S D f −must end with a constant segment defined in ]x 1 , x 2 [ with ordinate T f +d f .Such segment must be added manually at the end of S D f −The alert reader will notice that T f −1 ↓ and T f −1 ↑

Table 1 :Algorithm 1 1 ↓ 1 : 2 : 1 ↓ (e 0 ) 3 :
Cases to be considered in the by-sequence algorithm to compute S Pseudo-code for lower pseudo-inverse of a finite sequence Input Finite sequence of elements S, consisting of e k , k ∈ {1, . . ., n} that is either a point or a segment.Moreover, e 1 is a point at the origin (0, 0).ReturnLower pseudo-inverse S −of S, consisting of a sequence of elements O = {o 1 , . . ., o m } Define an empty sequence of elements O := { } Append p := (0, 0) to O f −for e k in (e 2 , . . ., e n ) do

Fig. 6 :
Fig. 6: Example of composition of two sequences Algorithm 3 is a linear scan of S D f f and S Dg g , the resulting complexity is O n S D f f + n S Dg g

Table 2 :
Performance comparison of composition with and without UA optimization.
Theorem 22 (Strict Per-Flow Service Curves for IWRR) Assume n flows arriving at a server performing interleaved weighted round robin (IWRR) with weights w 1 , ..., wn.Let l min i and l max j denote the minimum and maximum packet size of the respective flow.Let this server offer a super-additive strict service curve β to these n flows.Then,β i (t) := γ i (β(t)) ,is a strict service curve for flow f i , where γ i (t) := β 1,0 ⊗ U i (t), j + w j − w i + + min (p mod w i ) + 1, w j , β 1,0 is a constant-rate function with slope 1, and the stair function ν h,P (t) is defined as ν h,P (t) := h t P , for t ≥ 0.