Benedetto Piccoli
email: pic-coli@camden.rutgers.edu

Francesco Rossi
email: francesco.rossi@lsis.org

Keywords:

The Wasserstein distances W p (p ≥ 1), defined in terms of solution to the Monge-Kantorovich problem, are known to be a useful tool to investigate transport equations. In particular, the Benamou-Brenier formula characterizes the square of the Wasserstein distance W 2 as the infimum of the kinetic energy, or action functional, of all vector fields transporting one measure to the other. Another important property of the Wasserstein distances is the Kantorovich-Rubinstein duality, stating the equality between the distance W 1 (µ, ν) of two probability measures µ, ν and the supremum of the integrals in d(µ -ν) of Lipschitz continuous functions with Lipschitz constant bounded by one.

. Here p plays the same role as for the classic Wasserstein distance, while a and b are weights for the transport and the total variation term. In this paper we prove two important properties of the generalized Wasserstein distances: 1) a generalized Benamou-Brenier formula providing the equality between W a,b 2 and the supremum of an action functional, which includes a transport term (kinetic energy) and a source term. 2) a duality à la Kantorovich-Rubinstein establishing the equality between W 1,1 1 and the flat metric.

Introduction

The problem of optimal transportation, also called Monge-Kantorovich problem, has been intensively studied in the mathematical community. Related to this problem, Wasserstein distances in the space of probability measures have revealed to be powerful tools, in particular for dealing with dynamics of measures (like the transport PDE, see e.g. [START_REF] Ambrosio | Hamiltonian ODEs in the Wasserstein Space of Probability Measures[END_REF][START_REF] Ambrosio | Gradient Flows: In Metric Spaces and in the Space of Probability Measures[END_REF]). For a complete introduction to Wasserstein distances, see [START_REF] Villani | Optimal Transport: Old and New, Grundlehren der mathematischen Wissenschaften[END_REF][START_REF] Villani | Topics in Optimal Transportation[END_REF].

The main limit of this approach, at least for its application to dynamics of measures, is that the Wasserstein distances W p (µ, ν) (p ≥ 1) are defined only if the two measures µ, ν have the same mass. For this reason, in [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF] we introduced the generalized Wasserstein distances W a,b p (µ, ν), combining the standard Wasserstein and total variation distances. In rough words, for W a,b p (µ, ν) an infinitesimal mass δµ of µ can either be removed at cost a|δµ|, or moved from µ to ν at cost bW p (δµ, δν). More formally, the definition of the generalized Wasserstein distance that we use in this article 1 is W a,b p (µ, ν) := T a,b p (µ, ν) where M denotes the space of Borel regular measures on R d with finite mass. Recall that the "flat metric" or "bounded Lipschitz distance" (see e.g. [4, §11]), is defined as follows d(µ, ν) := sup

R d f d(µ -ν) | f C 0 ≤ 1, f Lip ≤ 1 .
We first show that the generalized Wasserstein distance W 1,1 1 coincides with the flat metric. This provides the following duality formula:

d(µ, ν) = W 1,1 1 (µ, ν) = inf μ,ν∈M, |μ|=|ν| |µ -μ| + |ν -ν| + W 1 (μ, ν).
This result can be seen as a generalization of the Kantorovich-Rubinstein theorem, which provides the duality:

W 1 (µ, ν) = sup R d f d(µ -ν) | f Lip ≤ 1 .
One interesting field of application of the generalized Wasserstein distances is the study of transport equations with sources, i.e. dynamics of measures given by:

∂ t µ t + ∇ • (v t µ t ) = h t , (1)
where v t is a time-dependent vector field and h t a time-dependent source term. Several authors have studied [START_REF] Ambrosio | Hamiltonian ODEs in the Wasserstein Space of Probability Measures[END_REF] without source term, i.e. h ≡ 0, showing that it is very convenient to use the standard Wasserstein distance in this framework. In particular, Benamou and Brenier showed in [START_REF] Benamou | A computational fluid mechanics solution to the Monge-Kantorovich mass transfer problem[END_REF] that there is a natural equivalence between the minimization of the action functional A [µ, v] := 1 0 dt R d dµ t |v t | 2 and the computation of the Wasserstein distance W 2 . Their fundamental result is recalled in Theorem 4. However, the standard Wasserstein distances do not encompass the case of a non vanishing source h. Indeed, in this case the mass of the measure µ t varies in time, hence W p (µ t , µ s ) may not be defined for t = s. Our second goal is to generalize the Benamou-Brenier formula to this setting. On one side, we use the generalized Wasserstein distances, so allowing mixing creation/removal of mass and transport of mass. On the other side, we define a generalization of the functional A, taking into account both the transport and the creation/removal of mass in [START_REF] Ambrosio | Hamiltonian ODEs in the Wasserstein Space of Probability Measures[END_REF]. More precisely, we define

B a,b [µ, v, h] := a 2 1 0 dt R d d|h t | 2 + b 2 1 0 dt R d dµ t |v t | 2 .
Given the generalizations both for the distance and the functional, we will then prove the generalized Benamou-Brenier formula under the regularity hypotheses recalled in Definition 5:

T a,b 2 (µ 0 , µ 1 ) = inf B a,b [µ, v, h]
µ is a solution of (1) with vector field v, source h and

µ |t=0 = µ 0 , µ |t=1 = µ 1 . ( 2
)
The structure of the paper is the following. In Section 2 we define the generalized Wasserstein distance and recall some useful properties, in particular estimates of the generalized Wasserstein distance under flow action. In Section 3 we prove that W 1,1 1 coincides with the flat metric. Finally, in Section 4 we recall the standard Benamou-Brenier formula and prove the generalized Benamou-Brenier formula (2). 1 Observe that the definition in [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF] was W a,b p (µ, ν) = inf μ,ν∈M a|µ -μ| + a|ν -ν| + bWp(μ, ν). Clearly, the two definitions are extremely similar, and satisfy similar properties: one can indeed observe that , given the vector (a|µ -μ| + a|ν -ν|, bWp(μ, ν)) ∈ R 2 , the definition in [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF] is the 1-norm of such vector, while the definition given in the present article is its p-norm.

Generalized Wasserstein distance

Notation and standard Wasserstein distance

We use M to denote the space of positive Borel regular measures with finite mass2 on R d and M ac 0 to denote the subspace of M of measures with compact support that are absolutely continuous with respect to the Lebesgue measure. When not specified, the domain of integration is the whole space R d , or R d × R d in the case of integrals with two variables.

Given µ, µ 1 Radon measures (i.e. positive Borel measures with locally finite mass), we write µ 1 µ if µ 1 is absolutely continuous with respect to µ, while we write µ 1 ≤ µ if µ 1 (A) ≤ µ(A) for every Borel set A. We denote with |µ| := µ(R d ) the norm of µ (also called its mass). More generally, if µ = µ + -µ - is a signed Borel measure, we define |µ|

:= |µ + | + |µ -|.
By the Lebesgue's decomposition theorem, given two measures µ, ν, one can always write in a unique way µ = µ ac +µ s such that µ ac ν and µ s ⊥ ν, i.e. there exists B such that µ s (B) = 0 and ν(R n \B) = 0. Moreover, there exists a unique f ∈ L 1 (dν) such that dµ ac (x) = f (x) dν(x). Such f is called the Radon-Nikodym derivative of µ with respect to ν. We denote it with D ν µ. For more details, see e.g. [START_REF] Evans | Measure Theory and Fine Properties of Functions[END_REF].

Given a Borel map γ : R d → R d , the push forward of a measure µ ∈ M is defined by:

γ#µ(A) := µ(γ -1 (A)).
Note that the mass of µ is identical to the mass of γ#µ. Therefore, given two measures µ, ν with the same mass, one may look for γ such that ν = γ#µ and it minimizes the cost

I [γ] := |µ| -1 |x -γ(x)| p dµ(x).
This means that each infinitesimal mass δµ is sent to δν and that its infinitesimal cost is the p-th power of the distance between them. Such minimization problem is known as the Monge problem and was first stated in 1781 (see [START_REF] Monge | Mémoire sur la théorie des déblais et de remblais[END_REF]). If µ or ν has an atomic part then we may have no γ such that γ#µ. For instance, the measures µ = 2δ 1 and ν = δ 0 + δ 2 , on the real line have the same mass, but there exists no γ such that ν = γ#µ, since a map γ can not separate masses. A simple condition, that ensures the existence of a minimizing γ, is that µ and ν are absolutely continuous with respect to the Lebesgue measure.

A generalization of the Monge problem is defined as follows. Given a probability measure π on R d ×R d , one can interpret π as a method to transfer a measure µ on R d to another measure on R d as follows: each infinitesimal mass on a location x is sent to a location y with a probability given by π(x, y). Formally, µ is sent to ν if the following properties hold:

|µ| R d dπ(x, •) = dµ(x), |ν| R d dπ(•, y) = dν(y). (3)
Such π is called a transference plan from µ to ν and we denote the set of transference plans from µ to ν as Π(µ, ν).

A condition equivalent to (3) is that, for all f, g ∈ C ∞ c (R d ) it holds |µ| R d ×R d (f (x) + g(y)) dπ(x, y) = R d f (x) dµ(x) + R d g(y)
dν(y). Remark 1 One can use a transference plan π ∈ Π(µ, ν) also to define pairs µ ≤ µ, ν ≤ ν so that µ is transfered to ν . Indeed, given µ ≤ µ, let f the Radon-Nikodym derivative f = D µ µ , that satisfies f ≤ 1 and µ (A) = A f (x)dµ(x) for all Borel sets. Define now π , ν as follows:

π (A × B) := |µ| |µ | A×B f (x)dπ(x, y) for each Borel set A × B, ν (B) := |µ| R d ×{B} f (x)dπ(x, y) for each Borel set B.
It is easy to prove that π ∈ Π(µ , ν ). Similarly, one can define π ∈ Π(µ -µ , ν -ν ) by

π (A × B) := |µ| |µ| -|µ | A×B (1 -f (x))dπ(x, y) for each Borel set A × B.
One can define a cost for π as follows

J [π] := R d ×R d |x -y| p dπ(x, y)
and look for a minimizer of J in Π(µ, ν). Such problem is called the Monge-Kantorovich problem. It is important to observe that such problem is a generalization of the Monge problem. Indeed, given a γ sending µ to ν, one can define a transference plan

π = |µ| -1 (Id × γ)#µ, i.e. dπ(x, y) = µ(R n ) -1 dµ(x)δ y=γ(x) . It also holds J [Id × γ] = I [γ].
The main advantage of this approach is that a minimizer of J in Π(µ, ν) always exists.

A natural space on which J is finite is the space of Borel measures with finite p-moment, that is

M p := µ ∈ M | |x| p dµ(x) < ∞ .
One can thus define on M p the following operator between measures of the same mass3 , called the Wasserstein distance:

W p (µ, ν) = |µ|( min π∈Π(µ,ν) J [π]) 1/p .
It is indeed a distance on the subspace of measures in M p with a given mass, see [START_REF] Villani | Topics in Optimal Transportation[END_REF]. It is easy to prove that W p (kµ, kν) = kW p (µ, ν) for k ≥ 0, by observing that Π(kµ, kν) = Π(µ, ν) and that J [π] does not depend on the mass. Another remarkable property is the following optimality principle.

Proposition 1 Let π ∈ Π(µ, ν) be a transference plan realizing W p (µ, ν). Let µ ≤ µ and ν ≤ ν such that π ∈ Π(µ , ν ) (where π is defined as in Remark 1). Then π realizes W p (µ , ν ) and it holds

W p p (µ, ν) |µ| p-1 = W p p (µ , ν ) |µ | p-1 + W p p (µ -µ , ν -ν ) |µ -µ | p-1 . (4)
Proof Denote with π the restriction of π to µ , ν and with π the restriction of π to µ -µ , µ -ν , as defined in Remark 1. We first prove that π realizes W p (µ , ν ), by contradiction. Assume that there exists π ∈ Π(µ , ν ) such that J [π ] < J [π ]. Then define the transference plan π ∈ Π(µ, ν) as follows:

π(A × B) := |µ | |µ| π (A × B) + |µ| -|µ | |µ| π (A × B) for each Borel set A × B.
A direct computation shows that

|µ|J[π] = |µ |J[π ] + (|µ| -|µ |)J[π ] < |µ |J[π ] + (|µ| -|µ |)J[π ] = |µ|J[π].
Then J[π] < J[π] and π ∈ Π(µ, ν). This is in contradiction with the fact that π realizes W p (µ, ν). By symmetry, we also have that π realizes W p (µ -µ , ν -ν ). Then, the proof of ( 4) is a direct consequence of the fact that |µ|J

[π] = |µ |J[π ] + (|µ| -|µ |)J[π ].

Definition of the generalized Wasserstein distance

In this section, we provide a definition of the generalized Wasserstein distance, which is a slight modification of that given in [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF], together with some useful properties.

Definition 1 Let µ, ν ∈ M be two measures. We define the functionals

T a,b p (µ, ν) := inf μ,ν∈M, |μ|=|ν| a p (|µ -μ| + |ν -ν|) p + b p W p p (μ, ν), (5)
and

W a,b p (µ, ν) := T a,b p (µ, ν) 1/p . (6)
We now provide some properties of W a,b p and T a,b p . Proofs can be adapted from those given in [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF].

Proposition 2

The following properties hold:

1. The infimum in (5) coincides with

inf μ≤µ,ν≤ν, |μ|=|ν| a p (|µ -μ| + |ν -ν|) p + b p W p p (μ, ν),
where we have added the constraint μ ≤ µ, ν ≤ ν.

2. The infimum in ( 5) is attained by some μ, ν.

a p (|µ -μ| p + |ν -ν| p ) + b p W p p (μ, ν),
i.e. by distributing the p-th power on the two L 1 terms. Proofs and properties are similar to the proofs given here. Our choice here is related to the generalization of the Benamou-Brenier formula for W a,b p . We discuss this issue in Remark 4 below.

We also have this useful estimate to bound integrals.

Lemma 1 Let µ, ν ∈ M ac 0 , and f ∈ Lip(R d , R) ∩ L ∞ (R d , R). Then f dµ -f dν ≤ 2 p-1 p max f ∞ a , f Lip b W a,b p (µ, ν) . (7)
Proof Let μ ≤ µ, ν ≤ ν realizing W a,b p (µ, ν). We have f dµ -f dν ≤ f d(µ -μ) + f d(μ -ν) + f d(ν -ν) ≤ ≤ f ∞ |µ -μ| + f Lip W 1 (μ, ν) + f ∞ |ν -ν|, (8)
where we have used that |µ| = sup f dµ | f ∞ = 1 and the Kantorovich-Rubinstein duality formula [START_REF] Villani | Topics in Optimal Transportation[END_REF]Sec. 7.1.2]. Then ( 7) is a direct consequence of (8), by using (x + y) p ≤ 2 p-1 (x p + y p ).

W 1 (µ, ν) = sup f d(µ -ν) | f Lip = 1 . Recall that W 1 (μ, ν) ≤ W p (μ, ν) for p ≥ 1, see e.g.

Topology of the generalized Wasserstein distance

In this section we recall some useful topological results related to the metric space M when endowed with the generalized Wasserstein distance.

Definition 2 A set of measures M is tight if for each ε > 0 there exists a compact K ε such that µ(R d \ K ε ) < ε for all µ ∈ M .
We now recall the following important result about convergence with respect to the generalized Wasserstein distance, see [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF]Theorem 13].

Theorem 1 Let {µ n } be a sequence of measures in R d , and µ n , µ ∈ M. Then W a,b p (µ n , µ) → 0 is equivalent to µ n µ and {µ n } is tight.
We finally recall the result of completeness, see [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF]Proposition 15].

Proposition 3

The space M endowed with the distance W a,b p is a complete metric space.

Estimates of generalized Wasserstein distance under flow actions

In this section we give useful estimates both for the standard and generalized Wasserstein distances W p and W a,b p under flow actions. Similar4 properties were already proved for measures µ, ν ∈ M ac 0 in [7, Sec. 2.1] and [START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF]Sec.1.5]. Generalizations of these estimates to any measures in M are obvious, by using the Kantorovich formulation of the optimal transportation problem.

Proposition 4 Let v t , w t be two time-varying vector fields, uniformly Lipschitz with respect to the space variable, and φ t , ψ t the flow generated by v, w respectively. Let L be the Lipschitz constant of v and w, i.e. |v t (x) -v t (y)| ≤ L|x -y| for all t, and similarly for w. Let µ, ν ∈ M. We have the following estimates for the standard Wasserstein distance

-W p (φ t #µ, φ t #ν) ≤ e Lt W p (µ, ν), -W p (µ, φ t #µ) ≤ t v C 0 |µ|, -W p (φ t #µ, ψ t #ν) ≤ e Lt W p (µ, ν) + e Lt -1 L |µ| sup τ ∈[0,t] v t -w t C 0 .
We have the following estimates for the generalized Wasserstein distance

-W a,b p (φ t #µ, φ t #ν) ≤ e Lt W a,b p (µ, ν), -W a,b p (µ, φ t #µ) ≤ bt v C 0 |µ|, -W a,b p (φ t #µ, ψ t #ν) ≤ e Lt W a,b p (µ, ν) + e Lt -1 L |µ| sup τ ∈[0,t] v t -w t C 0 .
Proof We first prove properties for the standard Wasserstein distance. Property 1. Let π be the transference plan realizing

W p (µ, ν). Observe that φ t is a diffeomorphism of the space R d , then φ t × φ t is a diffeomorphism of the space R d × R d . Since π is a probability density on R d × R d , then one can define π := (φ t × φ t )#π, another probability density on R d × R d .
It is easy to prove that π is indeed a transference plan between φ t #µ and φ t #ν. Then we can use such transference plan π to estimate W p (φ t #µ, φ t #ν). This gives

W p p φ t #µ, φ t #ν ≤ |µ| p |x -y| p dπ (x, y) = |µ| p |φ t (x) -φ t (y)| p dπ(x, y) ≤ ≤ |µ| p e Lpt |x -y| p dπ(x, y) = e Lpt W p p (µ, ν),
where we used the definition of the push-forward in the first equality and the Gronwall lemma in the last inequality. Property 2. Define the transference plan π such that dπ(x, y) = |µ| -1 dµ(x)δ y=φ t (x) on R d × R d . Observe that it is a transference plan between µ and φ t #µ. Then we have

W p p µ, φ t #µ ≤ |µ| p |x -y| p dπ(x, y) = |µ| p |x -φ t (x)| p |µ| -1 dµ(x) ≤ |µ| p ( v C 0 t) p |µ| -1 dµ(x) = = |µ| p ( v C 0 t) p .
Property 3. The proof is similar to proof of Property 1. Let π be the transference plan realizing

W p (µ, ν). Observe that φ t × ψ t is a diffeomorphism of the space R d × R d . Since π is a probability density on R d × R d , then one can define π := (φ t × ψ t )#π, another probability density on R d × R d .
It is easy to prove that π is indeed a transference plan between φ t #µ and ψ t ν. Then we can use such transference plan π to estimate W p (φ t #µ, ψ t #ν). We have

W p p φ t #µ, ψ t #ν ≤ |µ| p |x -y| p dπ (x, y) = |µ| p |φ t (x) -ψ t (y)| p dπ(x, y) ≤ ≤ |µ| p e Lt |x -y| + e Lt -1 L sup τ ∈[0,t] v t -w t C 0 p dπ(x, y),
where we have used Gronwall inequality. Minkowski inequality now gives

W p φ t #µ, ψ t #ν ≤ |µ|e Lt |x -y| p dπ(x, y) 1/p + |µ| e Lt -1 L sup τ ∈[0,t] v t -w t C 0 dπ(x, y) = = e Lt W p (µ, ν) + |µ| e Lt -1 L sup τ ∈[0,t] v t -w t C 0 ,
where we also used dπ(x, y) = 1.

We now prove equivalent properties for the generalized Wasserstein distance. Property 1. Let μ ≤ µ, ν ≤ ν be the choices realizing T a,b p (µ, ν), i.e.

T a,b p (µ, ν) = a p (|µ -μ| + |ν -ν|) p + b p W p p (μ, ν). Then estimate T a,b p (φ t #µ, φ t #ν) with φ t #μ and φ t #ν. Observe that φ t #μ ≤ φ t #µ, φ t #ν ≤ φ t #ν
, and in particular |φ t #µ -φ t #μ| = |µ -μ|, and similarly for the other term. We then have

T a,b p φ t #µ, φ t #ν ≤ a p (|φ t #µ -φ t #μ| + |φ t #ν -φ t #ν|) p + b p W p p (φ t #μ, φ t #ν) ≤ ≤ a p (|µ -μ| + |ν -ν|) p + b p e Lpt W p p (μ, ν) ≤ ≤ e Lpt a p (|µ -μ| + |ν -ν|) p + b p W p p (μ, ν) .
Computing the p-th root, we have the result.

Property 2. To estimate W a,b p (µ, φ t #µ), choose μ = µ, ν = φ t #µ. Then one has W a,b p (µ, φ t #µ) ≤ bW p (µ, φ t #µ).
Using Property 2 for the standard Wasserstein distance, one has the result.

Proof of Property 3 is completely equivalent to Property 1, by using ψ t #ν ≤ ψ t #ν and the corresponding inequality for W p (φ t #μ, ψ t #ν).

3 The generalized Wasserstein distance W 1,1 1 is the flat metric In this section, we provide a dual formulation for the generalized Wasserstein ditance W 1, 1 1 , proving that it coincides with the flat metric. First define the spaces L, K, F as follows:

L := f ∈ C 0 c (R d , R) | f ∞ ≤ 1 , K := f ∈ C 0 c (R d , R) | f Lip ≤ 1 , F := L ∩ K.
We also recall the following dual formulation for L 1 and W 1 distances.

Proposition 5 For all µ, ν ∈ M it holds

|µ -ν| = sup f d(µ -ν) | f ∈ L . For all µ, ν ∈ M with |µ| = |ν| it holds W 1 (µ, ν) = sup f d(µ -ν) | f ∈ K .
The second statement of Proposition 5 is known as the Kantorovich-Rubinstein theorem, see [START_REF] Villani | Topics in Optimal Transportation[END_REF]Theorem 1.14]. Recall the definition of the flat metric:

Definition 3 Let µ, ν ∈ M. Define d(µ, ν) := sup f d(µ -ν) | f ∈ F .
The functional d is a metric on M, called the flat metric.

We now state the main result of this section:

Theorem 2 Let µ, ν ∈ M. Then W 1,1 1 (µ, ν) = d(µ, ν). ( 9
)
The proof is based on some duality properties of convex functionals. For this reason, we first recall some useful definitions and results. For a complete description, see e.g. [START_REF] Rockafellar | Conjugate duality and optimization[END_REF]. In particular, Theorem 3 is Theorem 20.e in [START_REF] Rockafellar | Conjugate duality and optimization[END_REF].

Definition 4 Let X be a Banach space and F : X → R a function. The conjugate function

F * : X * → R is defined by F * (y) := sup x∈X ( y, x -F (x)).
Recalling that a function is closed if the set {f ≤ k} is closed for all k ∈ R, we have:

Theorem 3 Let X be a Banach space. Let F 1 , F 2 : X → R ∪ {+∞} be convex and closed. Assume that there exists a neighborhood U of the origin in X, an open set M in X * and a constant k such that for all sets

V α := {(y 1 , y 2 ) | y i ∈ dom(F * i ), y 1 + y 2 ∈ M, F * 1 (y 1 ) + F * 2 (y 2 ) ≤ α} it holds sup x∈U,(y1,y2)∈Vα y 1 + y 2 , x < k. ( 10
)
Then the conjugate function

F * of F = F 1 + F 2 satisfies F * (y) = min y1+y2=y (F * 1 (y 1 ) + F * 2 (y 2 )) . (11)
Observe that we removed -∞ from the codomain of F 1 , F 2 . This gives that F 1 , F 2 are both proper in the sense of [9, p. 1].

Proof (Proof of Theorem 2.) We define the following functionals on

X = (C 0 c (R n ), • ∞ ): F 1 (f ) := 0 when f ∞ ≤ 1 +∞ elsewhere. and F 2 (f ) := 0 when f Lip ≤ 1 +∞
elsewhere.

The dual space X * is the space of signed Radon measures, see e.g. [5, p.49]. Then, the dual formulation of Proposition 5 gives F * 1 (µ -ν) = |µ -ν| and F * 2 (µ -ν) = W 1 (µ, ν). We now consider F = F 1 + F 2 and study F * (µ -ν): it is easy to prove that it coincides with d(µ, ν), by the definition of the conjugate function.

We now prove that F * (µ -ν) coincides with W 1,1 1 (µ, ν), by using Theorem 3. It is easy to check that F 1 , F 2 are proper, closed and convex functions, and that U := { f ∞ < ε}, M = {|µ| < ε}, k = ε 2 satisfy [START_REF] Villani | Optimal Transport: Old and New, Grundlehren der mathematischen Wissenschaften[END_REF]. Then, condition [START_REF] Villani | Topics in Optimal Transportation[END_REF]

reads as F * (µ -ν) = min (µ1-ν1)+(µ2-ν2)=µ-ν (|µ 1 -ν 1 | + W 1 (µ 2 , ν 2 )), that coincides with W 1,1 1 (µ, ν).

Generalized Benamou-Brenier formula

In this section we generalize the Benamou-Brenier formula (recalled below, see [START_REF] Benamou | A computational fluid mechanics solution to the Monge-Kantorovich mass transfer problem[END_REF]) to W a,b 2 . The interest of such formula is to relate the Wasserstein distance between two measures µ 0 , µ 1 to the minimization of the functional |v t | 2 dµ t among all solutions of the linear transport equation from µ 0 to µ 1 . We first recall the original Benamou-Brenier formula. Observe that we deal with probability measures in M ac 0 . Theorem 4 Let P ac 0 := M ac 0 ∩ P be the space of probability measures that are absolutely continuous with respect with the Lebesgue measure and with compact support, endowed with the weak- * topology.

Fix µ 0 , µ 1 ∈ P ac 0 and let V (µ 0 , µ 1 ) be the set of couples measure-velocity field

(µ, v) := (µ t , v t ) t∈[0,1] such that µ ∈ C([0, 1] , P ac 0 ), v ∈ L 2 (dµ t dt), ∪ t∈[0,1] supp(µ t
) is bounded, and such that they satisfy the following boundary value problem:

∂ t µ t + ∇ • (v t µ t ) = 0 µ |t=0 = µ 0 , µ |t=1 = µ 1 .

Define the action functional

A [µ, v] := 1 0 dt R d dµ t |v t | 2 on V (µ 0 , µ 1 ). Then, it holds W 2 2 (µ 0 , µ 1 ) = inf {A [µ, v] | (µ, v) ∈ V (µ 0 , µ 1 )} . (12)
Such result has been proven to hold also in the larger space of probability measures with finite second order moments, see [START_REF] Ambrosio | Gradient Flows: In Metric Spaces and in the Space of Probability Measures[END_REF]. It is also easy to prove that (12) holds for µ 0 , µ 1 ∈ M ac 0 with the same mass m. Indeed, it is sufficient to use (12) for m -1 µ 0 , m -1 µ 1 and to observe that we have the same degree of homogeneity on the left and right hand sides when multiplying by a constant.

We now prove that a similar result holds for W a,b 2 and the transport equation with source. We first define the space and the functional that we study. Definition 5 For µ 0 , µ 1 ∈ M ac 0 let V (µ 0 , µ 1 ) be the set of triples (measure, velocity field, source term) (µ, v, h) := (µ t , v t , h t ) t∈[0,1] with the following properties: µ ∈ C([0, 1] , M ac 0 ), with M ac 0 endowed with the weak- * topology; v ∈ L 2 (dµ t dt); h ∈ L 1 ([0, 1] , M ac 0 ) in the sense that [START_REF] Ambrosio | Hamiltonian ODEs in the Wasserstein Space of Probability Measures[END_REF] supp(µ t ) is bounded; they satisfy the following boundary value problem:

1 0 dt R d d|h t | < ∞; ∪ t∈[0,
∂ t µ t + ∇ • (v t µ t ) = h t , µ |t=0 = µ 0 , µ |t=1 = µ 1 . (13)
We define the action functional on V (µ 0 , µ 1 ) by

B a,b [µ, v, h] := a 2 1 0 dt R d d|h t | 2 + b 2 1 0 dt R d dµ t |v t | 2 .
Remark 3 Observe that the conditions given above also imply that ∪ t∈[0,1] supp(h t ) ⊂ ∪ t∈[0,1] supp(µ t ), and in particular h t have uniformly bounded support. Indeed, assume by contradiction that ∪ t∈[0,1] supp(h t ) ⊂ ∪ t∈[0,1] supp(µ t ). Looking at h as a functional on C ∞ 0 functions, this means that there exists a function

ψ ∈ C ∞ 0 [0, 1] × R d , R with supp(ψ) ⊂ [0, 1]× R d \ ∪ t∈[0,1] supp(µ t ) and such that 1 0 dt R d dh t ψ(t, x) = 0. By construction, one has 1 0 dt dµ t (∂ t ψ + v • ∇ψ) = 0,
since ψ and its derivatives are identically 0 on the support of µ t for each t ∈ [0, 1]. Moreover (µ, v, h) satisfy (1) in the weak sense. Choosing ψ as a test function, one has 0 = 1 0 dt R d dh t ψ(t, x), giving a contradiction. We now state the generalized Benamou-Brenier formula:

Theorem 5 Let µ 0 , µ 1 ∈ M ac 0 . Then inf B a,b [µ, v, h] | (µ, v, h) ∈ V (µ 0 , µ 1 ) = T a,b 2 (µ 0 , µ 1 ) . ( 14
)
The similarity between B a,b and A is evident. In particular, the standard Benamou-Brenier formula can be recovered as a particular case of Theorem 5 when h ≡ 0 and a → ∞.

a 2 1 0 dt R d dh + t 2 + a 2 1 0 dt R d dh - t 2 + b 2 1 0 dt R d dµ t |v t | 2 .
This means that we have distributed the power 2 on the terms for creation and removal of mass, both for T a,b 2 and B a,b . Proofs given below for Theorem 5 can be easily adapted to this setting.

Proof of Theorem 5. We first prove the inequality B a,b [µ, v, h] ≥ T a,b 2 (µ 0 , µ 1 ). The proof of this inequality is divided in 3 steps.

We first fix the following stronger regularity assumptions for v, h, that will be used in Steps 1 and 2:

the vector field v is uniformly L-Lipschitz with respect to x; it has C 0 -norm uniformly bounded in time, i.e.

M := sup t∈[0,1] v t C 0 < ∞; -the source satisfies h ∈ L ∞ ([0, 1], M ac 0 ), i.e. it satisfies P := sup t∈[0,1] R d d|h t (.)| < ∞. t ∆t 2 ∆t 2∆t 3∆t 1 |µt|, |µ [k] t | |µ0| |µt| |µ [k] t | Fig. 1 Evolution of |µt|, |µ [k] t | for k = 2.
Before the main steps of the proof, we state some simple remarks. First of all, since we deal with approximations of the dynamics given by v, h, then the approximated solution µ [k] could fail to be a positive measure for some times. Then, one needs to replace µ [k] with its positive part all along the proof. For simplicity of notation, this replacement is implict all along the proof. Second, we fix some notations that will be useful all along the proof. Given the initial datum µ 0 , we will prove that all measures studied in the proof have bounded mass, and in particular |µ t |, |µ

[k] t |, |μ [k] t | ≤ |µ 0 | + P . We define m := |µ 0 | + P.
We also define

α := √ 2 max M a , L b , β := 2aP + bM m.
Step 1: In this step, we define an approximate solution µ [k] , together with v k , h k , via a sample and hold method. We will prove that both µ

[k] → µ and B a,b µ [k] , v k , h k → B a,b [µ, v, h] for k → ∞.
Fix k ∈ N and define ∆t := 2 -k . We discretize the time interval [0, 1] in small intervals [n∆t, (n+1)∆t]. The idea of the discretization is first to divide each interval [n∆t, (n + 1)∆t] in three parts: n∆t, n∆t + ∆t 2 , n∆t + ∆t 2 , (n + 1)∆t -∆t 2 , (n + 1)∆t -∆t 2 , (n + 1)∆t .

On the first part we use the negative part h -of h, then the velocity v, then the positive part h + of h. Clearly, each term must be correctly rescaled, to have µ

[k]
(n+1)∆t close to µ (n+1)∆t . We define the following vector field and the source term:

v k n∆t+τ := ∆t ∆t-2∆t 2 v n∆t+ ∆t ∆t-2∆t 2 (τ -∆t 2 ) for τ ∈ (∆t 2 , ∆t -∆t 2 ], 0 for τ ∈ (0, ∆t 2 ] ∪ (∆t -∆t 2 , ∆t], h k n∆t+τ :=      ∆t -1 h - n∆t+∆t -1 τ for τ ∈ (0, ∆t 2 ], 0 for τ ∈ (∆t 2 , ∆t -∆t 2 ], ∆t -1 h + n∆t+∆t -1 (τ -(∆t-∆t 2 )) for τ ∈ (∆t -∆t 2 , ∆t].
Observe that v k and h k will never act at the same time, i.e. v k t = 0 implies h k = 0 and viceversa. A scheme of the evolution of the mass |µ t | is given in Figure 1. We now define µ [k] as the solution of (1) in C([0, 1], M ac 0 ) with velocity field v k , source h k , and initial datum µ

[k] 0 = µ 0 . It is evident that the measure has uniformly bounded mass, in particular |µ

[k] t | ≤ m for all t ∈ [0, 1].
It is also easy to prove the following property: for τ ∈ [0, ∆t] it holds

W a,b 2 µ [k] n∆t , µ [k] n∆t+τ ≤ ∆t(2aP + bM m) =: β∆t. (15) µ [k-1] 0 , µ [k] 0
= 0 and that, for a sufficiently big k, it holds e L∆t ≤ 1 + 2L∆t and 2L∆t ≤ 1. This gives

W a,b 2 µ [k-1] n∆t , µ [k] n∆t ≤ bM P ∆t 2 (2 + 2L∆t) (1 + 2L∆t) n/2 -1 1 + 2L∆t -1 ≤ 2bM P ∆t e n L ∆t -1 2L ≤ ≤ 2bM P 2 -k e L -1 L ,
where we have used that n∆t ≤ 1. Observe that the estimate is independent of n. Applying it recursively, one has

W a,b 2 µ [k] n∆t , µ [k+l] n∆t ≤ 2bM P (e L -1) L 2 -(k+1) 1 -2 -l/2 1 -2 -1/2 .
Finally, take any t ∈ [0, 1]: for each integer k, let n k be the biggest even number such that

n k 2 -k ≤ t. It clearly holds |t -n2 -k | < 2 -k+1 . One has W a,b 2 µ [k] t , µ [k+l] t ≤ W a,b 2 µ [k] t , µ [k] n k 2 -k + W a,b 2 µ [k] n k 2 -k , µ [k+l] n k 2 -k + W a,b 2 µ [k+l] n k 2 -k , µ [k+l] t ≤ ≤ 2β2 -k + 2bM P (e L -1) L 2 -(k+1) 1 -2 -l/2 1 -2 -1/2 + 2β2 -k ,
where we have used (15) twice for the first term and 2 l+1 times for third term. Since the estimate does not depend on t, one has d(µ [k] , µ [k+l] ) ≤ C 1 2 -k with C 1 := 4β + bM P (e L -1)

L √ 2 √
2-1 . Since the estimate does not depend on l and W µ [k] , µ [k+l] → 0 for k → ∞, we have that µ [k] is a Cauchy sequence. Since C([0, 1], M) is complete with respect to W, then there exists a limit µ * := lim k→∞ µ [k] , with µ * ∈ M.

We now prove that µ * = µ. We prove it by proving that it is a weak solution of [START_REF] Ambrosio | Hamiltonian ODEs in the Wasserstein Space of Probability Measures[END_REF]. By uniqueness the result will follow. We have to prove that, for any

5 f t ∈ C ∞ 0 ([0, 1] × R d ), it holds 1 0 dt R d (dµ * t (∂ t f t + v t • ∇f t ) + dh t f t ) = 0. (17)
Observe that µ [k] is a solution of (1) with vector field v k , and source h k . Then

1 0 dt R d dµ [k] t (∂ t f t + v k t • ∇f t ) + dh k t f t = 0.
One can prove (17) by proving the three following limits:

1. lim k 1 0 dt R d dµ * t -dµ [k] t ∂ t f t = 0.
This is a consequence of ( 7). Indeed, one has

lim k 1 0 dt R d dµ * t -dµ [k] t ∂ t f t ≤ 1 0 dt W a,b 2 µ * t , µ [k] t √ 2 max ∂ t f t ∞ a , ∂ t f t Lip b ≤ ≤ W µ * , µ [k] √ 2 max ∂ t f t ∞ a , ∂ t f t Lip b → 0 2. lim k 1 0 dt R d dµ * t v t • ∇f t -dµ [k] t v k t • ∇f t = 0.
We first fix k and ∆t := 2 -k , and estimate

∆t 0 dt R d dµ * n∆t+t v n∆t+t • ∇f n∆t+t - ∆t 0 dτ R d dµ [k] n∆t+τ v k n∆t+τ • ∇f n∆t+τ . (18)
Using the definition of v k n∆t+τ , we have that it is 0 for τ ∈ [0, ∆t 2 ] ∪ (∆t -∆t 2 , ∆t] and that for

τ ∈ (∆t 2 , ∆t -∆t 2 ] it holds v k n∆t+τ = ∆t ∆t-2∆t 2 v n∆t+ ∆t ∆t-2∆t 2 (τ -∆t 2 )
. Then, after the change of variable

τ → t := (τ -∆t 2 ) ∆t ∆t-2∆t 2 , we have ∆t 0 dτ R d dµ [k] n∆t+τ v k n∆t+τ • ∇f n∆t+τ = = ∆t ∆t -2∆t 2 ∆t-∆t 2 ∆t 2 dτ R d dµ [k] n∆t+τ v n∆t+ ∆t ∆t-2∆t 2 (τ -∆t 2 ) • ∇f n∆t+τ = = ∆t ∆t -2∆t 2 ∆t 0 ∆t -2∆t 2 ∆t dt R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t v n∆t+t • ∇f n∆t+∆t 2 + ∆t-2∆t 2 ∆t t .
5 The index t will be useful in the following change of variable in time.

To go back to (18), we estimate for each t ∈ [0, ∆t] the following quantity6 :

R d dµ * n∆t+t v n∆t+t • ∇f n∆t+t - R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t v n∆t+t • ∇f n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ R d dµ * n∆t+t v n∆t+t • ∇f n∆t+t - R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t v n∆t+t • ∇f n∆t+t + + R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t v n∆t+t • ∇f n∆t+t - R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t v n∆t+t • ∇f n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ W a,b 2 µ * n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t √ 2 max M ∇f t ∞ a , L ∇f t Lip b + (19) + µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t M ∇f n∆t+t -∇f n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ∞ .
We estimate the first term of the right hand side of (19) via

W a,b 2 µ * n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ W a,b 2 µ * n∆t+t , µ [k] n∆t+t + W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t . We estimate W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t
by studying three cases:

(a) t ∈ [0, ∆t 2 ]: We observe that the evolution from µ

[k] n∆t+t to µ [k]
n∆t+∆t 2 is given by removal of mass H k [n∆t+t,n∆t+∆t 2 ] , while the evolution from µ

[k] n∆t+∆t 2 to µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t
is given by the push-forward

of the diffeomorphism Φ k n∆t+∆t 2 ,n∆t+∆t 2 + ∆t-2∆t 2 ∆t t
. We then have

W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + +W a,b 2 µ [k] n∆t+∆t 2 , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ |t -∆t 2 |∆t -1 P + b ∆t -2∆t 2 ∆t t v k C 0 m = = |t -∆t 2 |∆t -1 P + bM mt. (20)
(b) t ∈ (∆t 2 , ∆t-∆t 2 ]: We observe that the evolution is given by the push-forward of the diffeomorphism Φ k n∆t+t,n∆t+∆t 2 + ∆t-2∆t 2 ∆t t . We have

W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ b t -∆t 2 + ∆t -2∆t 2 ∆t t v k C 0 m ≤ ≤ b|2t∆t -∆t 2 | ∆t ∆t -2∆t 2 M m. (c) t ∈ [∆t -∆t 2 ,
∆t]: This is similar to case 1. We have

W a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ |t -∆t + ∆t 2 |∆t -1 P + +b ∆t -2∆t 2 ∆t t -(∆t -2∆t 2 ) M m. (21)
We estimate the second term of the right hand side of (19) via7 µ

[k]

n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ m and ∇f n∆t+t -∇f n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ∞ ≤ ∇f t Lip t -∆t 2 + ∆t -2∆t 2 ∆t t = ∇f t Lip 2t∆t -∆t 2 .
Observe that both terms of the right hand side of (19) have a symmetry property: the value in t coincides with the value in ∆t -t. Back to (18) and, by using (19) and the symmetry described above, we have

∆t 0 dt R d dµ * n∆t+t v n∆t+t • ∇f n∆t+t - ∆t 0 dτ R d dµ [k] n∆t+τ v k n∆t+τ • ∇f n∆t+τ ≤ ≤ 2 √ 2 max M ∇f t ∞ a , L ∇f t Lip b ∆t 0 dt W a,b 2 µ * n∆t+t , µ [k] n∆t+t + +2 √ 2 max M ∇f t ∞ a , L ∇f t Lip b ∆t 2 0 dt |t -∆t 2 |∆t -1 P + bM mt + +2 √ 2 max M ∇f t ∞ a , L ∇f t Lip b ∆t/2 ∆t 2 dt b|2t∆t -∆t 2 | ∆t ∆t -2∆t 2 M m + +2 ∆t/2 0 dt mM ∇f t Lip 2t∆t -∆t 2 ≤ CW µ * , µ [k] ∆t + C∆t 3 /2 + +C(∆t -2∆t 2 )∆t 3 /2 + C ∆t/2 0 dt |2t∆t -∆t 2 | + C ∆t/2 0 dt |2t∆t -∆t 2 | (22) with C = 2 √ 2 max M ∇ft ∞ a , L ∇ft Lip b
, ∇f t Lip • max {1, P, 2bM m, M m}. The estimate holds for k ≥ 2, for which it holds ∆t ∆t-2∆t 2 ≤ 2. We simply estimate (22) with CW µ * , µ [k] ∆t + C∆t 3 /2 + C∆t 4 /2 + C∆t 3 /2 + C∆t 3 /2 < CW µ * , µ [k] ∆t + 3C∆t 3 , by using |2t∆t -∆t 2 | ≤ ∆t 2 . Going back to our estimate, using (18) on each interval [n∆t, (n + 1)∆t], we have

lim k 1 0 dt R d dµ * t v t • ∇f t -dµ [k] t v k t • ∇f t ≤ lim k 2 k -1 n=0 ∆t 0 dt R d dµ * n∆t+t v n∆t+t • ∇f n∆t+t + - ∆t 0 dτ R d dµ [k] n∆t+τ v k n∆t+τ • ∇f n∆t+τ ≤ lim k 2 k (CW µ * , µ [k] 2 -k + 3C2 -3k ) = = lim k CW µ * , µ [k] = 0. 3. lim k 1 0 dt R d d(h t -h k t )f t = 0.
We first fix k and ∆t := 2 -k and, using again estimates in Proposition 4, we have

lim k 1 0 dt R d d(h t -h k t )f t ≤ lim k 2 • 2 k P f t Lip (1 -∆t) 2 -2k 2 = 0
We have proved that µ * is a solution of (1), with µ * ∈ C([0, 1], M). Observe now that µ * -µ is a solution of (1) with initial datum 0, vector field v t and source 0. Applying standard result of existence and uniqueness of solutions of (1) with zero source in C([0, 1], M), we have µ

* = µ. Since µ ∈ C([0, 1], M ac 0 ), then µ * ∈ C([0, 1], M ac 0 ) too. We now prove that B a,b µ [k] , v k , h k → B a,b [µ, v, h] for k → ∞. For the velocity term, we decompose ∆t 0 dt R d dµ n∆t+t |v n∆t+t | 2 - ∆t 0 dτ R d dµ [k] n∆t+τ |v k n∆t+τ | 2 ≤ ( 23
) ∆t 0 dt R d dµ n∆t+t |v n∆t+t | 2 - ∆t 0 dt R d dµ [k] n∆t+t |v n∆t+t | 2 + + ∆t 0 dt R d dµ [k] n∆t+t |v n∆t+t | 2 - ∆t 0 dτ R d dµ [k] n∆t+τ |v k n∆t+τ | 2
We can easily estimate the first term by For the second term, we apply the change of variable τ → t = (τ -∆t 2 ) ∆t ∆t-2∆t 2 and find

∆t 0 dt √ 2 max M 2 a , 2LM b W a,b 2 µ t , µ [k] t ≤ 2M αW µ, µ [k] ∆t.
∆t 0 dt R d dµ [k] n∆t+t |v n∆t+t | 2 - ∆t 0 dt R d dµ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t |v n∆t+t | 2 ≤ ≤ 2M α ∆t 0 dtW a,b 2 µ [k] n∆t+t , µ [k] n∆t+∆t 2 + ∆t-2∆t 2 ∆t t ≤ 4M αβ∆t 2 .
Going back to (23), we estimate the right-hand side with 2M α W µ, µ [k] ∆t+4M αβ ∆t 2 ≤ KW µ, µ [k] ∆t+ K∆t 2 , where K := max {2M α, 4M αβ}.

For the source part, the definition of h k easily gives

1 0 dt R d d|h t | 2 - 1 0 dt R d d|h k t | 2 = 0.
Summing up, we have

B a,b µ [k] , v k , h k -B a,b [µ, v, h] ≤ b 2 K W µ, µ [k] + 2 -k , that gives lim k B a,b µ [k] , v k , h k = B a,b [µ, v, h].
Step 2: We now define a μ[k] , together with ṽk , hk , that satisfies the three following properties:

1. μ[k] drives µ 0 to µ [k] 1 , i.e. (μ [k] , ṽk , hk ) ∈ V (µ 0 , µ [k] 1 ); 2. it holds B a,b μ[k] , ṽk , hk ≤ B a,b µ [k] , v k , h k ; 3. it holds T a,b 2 µ 0 , µ [k] 1 ≤ B a,b μ[k] , ṽk , hk .
The idea is that, for each interval [n∆t, (n+1)∆t] we move all the decreasing of mass in [n∆t, n∆t+∆t 2 ), all the transport in [n∆t+∆t 2 , (n+1)∆t-∆t 2 ) and all the increase of mass in [(n+1)∆t-∆t 2 , (n+1)∆t]. We divide this step in three substeps. In the first, we define μ[k] . In the second, we prove the properties stated above. In the third, we prove the result T a,b 2 (µ 0 , µ 1 ) ≤ B a,b [µ, v, h] with the stronger regularity assumptions on v, h recalled at the beginning.

Step 2.1: We now define μ[k] . With this goal, we define three transformations of measures. The transformation induced on the mass is described in Figure 2. Transformation DOWN D: The idea is to replace the increase-decrease of mass with the decreaseincrease. Let (µ, v, h) be given, and t be a time such that: v t = 0 on the interval [ t -∆t

[k] ∆t ≤ μ[k] 0 = µ 0 , μ[k] 1-∆t ≤ μ[k] 1 = µ [k] 1 and μ[k] 1-∆t = Φk [∆t,1-∆t] #μ [k]
∆t to estimate

T a,b 2 µ 0 , µ [k] 1 ≤ a 2 |μ [k] 0 - μ[k] ∆t | + |μ [k] 1 - μ[k] 1-∆t | 2 + b 2 W 2 2 (μ [k] ∆t , μ[k] 1-∆t ). (24)
Using the standard Benamou-Brenier formula (12) for the last term and the change of variable τ → t = (1 -2∆t)τ + ∆t, we have

W 2 2 μ[k] ∆t , μ[k] 1-∆t ≤ (1 -2∆t) 1 0 dt R d dμ [k] t |ṽ k t | 2 ≤ 1 0 dt R d dμ [k] t |ṽ k t | 2 ,
that, applied to (24), gives T a,b 2 µ 0 , µ Step 3. We now prove that T a,b 2 (µ 0 , µ 1 ) ≤ B a,b [µ, v, h], with less regularity requirement. For h, we pass from L ∞ to L 1 regularity. On the side of v, we pass from Lipschitz continuity with respect to space and uniform boundedness to v t ∈ L 2 (dt dµ t ).

First, one can easily pass from the case of h in L ∞ to the case of h in L 1 . The idea is to define µ We now generalize our result to v ∈ L 2 (dt dµ t ). The proof is completely equivalent to the generalization of the proof of the Benamou-Brenier formula given in [START_REF] Villani | Topics in Optimal Transportation[END_REF]Theorem 8.1], Step 2. The main idea is to introduce the variable m t := ρ t v t , where ρ t is the density of µ t , and observe that ρ t |v t | 2 = |m t | 2 /ρ t is a convex function of ρ t , m t . Then, we write B a,b [µ, m, h] with an abuse of notation, and observe that it is convex with respect to its arguments. The presence of the term h makes no difference on this point with respect to [START_REF] Villani | Topics in Optimal Transportation[END_REF]Theorem 8.1], Step 2.

3 .Remark 2

 32 The functional W a,b p is a distance on M. 4. It holds W a,b p (µ, 0) ≤ a|µ|. One could define another metric, similar to W a,b p , by replacing T a,b p with inf μ,ν∈M, |μ|=|ν|

Remark 4

 4 It is possible to find a result similar to Theorem 5 by changing the definition of both T a,b 2 and B a,b . In particular, one can replace T a,b 2 with inf μ,ν∈M, |μ|=|ν| a 2 |µ -μ| 2 + |ν -ν| 2 + b 2 W 2 2 (μ, ν), and B a,b with

3 Fig. 2

 32 Fig. 2 Transformations DOWN Dt 1 , LEFT Lt 2 and RIGHT Rt 3 .

3 . 2 µ 0 , µ [k] 1 ≤

 321 It holds T a,b B a,b μ[k] , ṽk , hk . Observing the explicit structure of μ[k] in which one has remove of mass in [0, ∆t], then transport in [∆t, 1 -∆t], then creation of mass in [1 -∆t, 1] one can take μ

[k] 1 ≤Step 2 . 3 : 2 µ 0 , µ [k] 1 ≤ 2 µ 0 , µ [k] 1 - 2 µ [k] 1 , µ 1 ≤

 1232121211 B a,b μ[k] , ṽk , hk . We now prove T a,b 2 (µ 0 , µ 1 ) ≤ B a,b [µ, v, h]. For each k it holds T a,b B a,b μ[k] , ṽk , hk ≤ B a,b µ [k] , v k , h k . Since lim k |W a,b W a,b 2 (µ 0 , µ 1 ) | ≤ lim k W a,b lim k d(µ [k] , µ) = 0, then lim k T a,b 2 µ 0 , µ [k] 1 = T a,b 2 (µ 0 , µ 1 ). Then T a,b 2 (µ 0 , µ 1 ) = lim k b µ [k] , v k , h k = B a,b [µ, v, h] .

2 µ[k- 1 ]n∆t ≤ 3bM e L/2 1 0 1 0

 2111 [k] as in Step 1, and to provide similar estimates. Instead of a global constant P , one needs to define ∆t ≤ e L∆t W a,b n∆t , µ[k] n∆t + be L∆t ∆tM p k n + b∆tM p k n . dt|h t | 2 -k ,hence, summing up, we haveW µ [k] , µ [k+l] ≤ 4aψ(2 -k+1 ) + C2 -k with C 2 := 4bM m + 6bM e L/2 dt|h t | and ψ(ε) := sup t∈[0,1-ε] t+ε t |h t | that satisfies ψ(ε) → 0 for ε → 0. Hence µ [k] is a Cauchy sequence in C([0, 1], M).Both the proofs that the limit µ * = lim k µ[k] coincides with µ and that B a,b µ k , v k , h k → B a,b [µ, v, h] can be obtained by following the estimates of Part 1.

  2 , t + ∆t 2 ]; ht = 0 on the interval [ t -∆t 2 , t]; h+ t = 0 on the interval [ t, t + ∆t 2 ]. Then replace h with ĥ defined as follows:

		
	ĥt :=	 
		 

h t for t ∈ [0, t -∆t 2 ] ∪ ( t + ∆t 2 , 1], h t+∆t 2 for t ∈ ( t -∆t 2 , t], h t-∆t 2

for t ∈ ( t, t + ∆t 2 ].

The requirement of having finite mass is a simple choice to have finite distances W a,b p (µ, ν).

Remark that in[START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF] we had the mass coefficient |µ| 1/p . The choice here helps to have estimates not depending on p.

Properties proven in[START_REF] Piccoli | Transport equation with nonlocal velocity in Wasserstein spaces: convergence of numerical schemes[END_REF][START_REF] Piccoli | Generalized Wasserstein distance and its application to transport equations with source[END_REF] were not optimal, since we had a coefficient e p+1 p Lt instead of the coefficient e Lt in properties 1 and 3, and a coefficient e Lt/p instead of 1 in property 3.

Here we denote with ∇ft Lip the Lipschitz constant for ∇ft with respect to all t, x-variables, even if for (19) the Lipschitz constant in space is needed only.

Here it is sufficient to use the Lipschitz constant in the time variable.

The result can be proven even without assuming the existence of μ0, μ1, via a double limit and a diagonalization argument.

Acknowledgements The authors thank Luigi Ambrosio for suggesting looking for a generalized Benamou-Brenier formula and acknowledge the support of the NSF Grant #1107444 (KI-Net). This work was partly funded by Carnot STAR Institute in the framework of a researcher exchange program. It was conducted during a visit of F. Rossi to Rutgers University, Camden, NJ, USA. F. Rossi also thanks the institution for its hospitality.

We now prove that µ [k] is a Cauchy sequence with respect to the distance W defined as follows

2 (µ t , ν t ) .

We recall that C([0, 1], M) is complete with respect to W, as a direct consequence of the completeness of M with respect to W a,b 2 , see Proposition 3. First observe that, by substitution, the following formula holds for µ

where We also decompose µ

(n+2)∆t by using properties of composition of Φ k , H k , H k . This gives:

n∆t , i.e. the value of W a,b 2 at the right extreme of the interval of discretization for k -1 with respect to its value at the left extreme. We choose n even. Using estimates in Proposition 4, we have:

We apply the last inequality recursively. First recall that W a,b Keep v. We use the notation Dt for the solution μ of (1) with v and ĥ, i.e. Dt(µ) := μ. We also denote Dt(µ, v, h) := (μ, v, ĥ).

Transformation LEFT L: The idea is to replace the transport-decrease with the decrease-transport. Let (µ, v, h) be given, and t be a time such that:

. Then replace v with v defined as follows:

Also replace h -with ĥdefined as follows:

where Φ [t1,t2] is the flow generated by v. Keep h + . We use the notation Lt for the solution μ of (1) with v and ĥ, i.e. Lt(µ) := μ. We also denote Lt(µ, v, h) := (μ, v, ĥ).

Transformation RIGHT R: The idea is to replace the increase-transport with the transport-increase. Let (µ, v, h) be given, and t be a time such that:

. Then replace v with v defined as follows:

Also replace h + with ĥ+ defined as follows:

Keep h -. We use the notation Rt for the solution μ of (1) with v and ĥ, i.e. Rt(µ) := μ. We also denote Rt(µ, v, h) := (μ, v, ĥ).

We define D as the composition D := Dt n •Dt n-1 •. . .•Dt 2 •Dt 1 where t1 < t2 < . . . < tn are all times in the set 0, ∆t 2 , 2∆t 2 , . . . , (2 2k -1)∆t 2 , 1 such that Dt can be applied. We define L, R similarly. Finally, we define RLD as the composition R • L • D. We apply RLD iteratively to µ [k] . One can observe that, after 2 k -1 iterations, the result is a fixed point for RLD, i.e. RLD(RLD (2 k -1) (µ [k] )) = RLD (2 k -1) (µ [k] ). We define μ[k] := RLD (2 k -1) (µ [k] ) such fixed point.

One can observe that μ[k] is the solution of (1) for a certain ṽk , hk (depending on v k , h k ) of this kind:

Step 2.2: We now prove three properties of μ

1 ). Indeed, transformations D, L, R do not change initial and final times.

Summing up, we have

with h ∈ L 1 (dt dµ t ) and v t ∈ L 2 (dt dµ t ). Inequailty ≤. We now prove the reverse inequality inf

, by giving a sequence (µ k , v k , h k ) realizing the equality at the limit. First of all, observe that there exists 8 a choice μ0 , μ1 such that

and with μ0 ≤ µ 0 , μ1 ≤ ν 1 . Define ψ to be the optimal map realizing W 2 2 (μ 0 , μ1 ), that exists since μ0 , μ1 ∈ M ac 0 . Also define (see [START_REF] Villani | Topics in Optimal Transportation[END_REF])

and recall that (μ, v * ) is the choice realizing the equality in the standard Benamou-Brenier formula (12), i.e.

Then, write a dynamics first driving µ 0 to μ0 via removal of mass, then μ0 to μ1 via push-forward of measure, and finally μ1 to µ 1 with creation of mass. More precisely, fix an integer k, ∆t := 2 -k and define v k , h k as follows:

for t ∈ (∆t, 1 -∆t], ∆t -1 (µ 1 -μ1 )

for t ∈ [1 -∆t, 1].

The corresponding solution µ k of (1) with vector field v k and source h k satisfies (µ k , v k , h k ) ∈ V (µ 0 , µ 1 ) and

One then has

) -1 T a,b 2 (µ 0 , µ 1 ) .

Passing to the limit, we have the result

(µ 0 , µ 1 ) .


Michel Albonico
email: michelalbonico@utfpr.edu.br

Amine Benelallam
email: amine.benelallam@inria.fr

Jean-Marie Mottu
email: jean-marie.mottu@inria.fr

Gerson Suny
email: gerson.sunye@inria.fr

A DSL-based Approach for Elasticity Testing of Cloud Systems

Elastic cloud systems automatically respond to workload changes by (de-)allocating resources according to a conguration specication. Testing such systems requires eort from the tester. In particular, the tester is brought to specify the sequence of resource variations he/she is willing to test the system under, and then, drive the system through this specic sequence of variations while the test is being executed. In this paper, we propose a Domain Specic Language (DSL) aiming at reducing the tester's eort to write and execute elasticity testing. Our DSL abstracts test case specication from the cloud provider's libraries, making our language portable. The DSL compiles into executable code that implicitly orchestrates the execution of elasticity testing. In our preliminary results, we show that our approach reduces the amount of words to specify test cases w.r.t. dedicated libraries. It also shows how much this improvement scales when running a test on multiple cloud providers.

INTRODUCTION

One of the core design principles in cloud-based systems (a.k.a. cloud systems) is resource auto-scaling, also known as elasticity. It is dened as the ability of a cloud infrastructure to vary its resource conguration according to demand (in particular allocating or deallocating resources) [START_REF] Agrawal | Database scalability, elasticity, and autonomy in the cloud[END_REF][START_REF] Badger | Draft Cloud Computing Synopsis and Recommendations[END_REF][START_REF] Herbst | Elasticity in Cloud Computing: What It Is, and What It Is Not[END_REF][START_REF] Bersani | Towards the Formalization of Properties of Cloud-based Elastic Systems[END_REF]. However, due to dynamic resource allocation, a new class of issues may arise and cause the cloud system to fail [START_REF] Albonico | Monitoring-based testing of elastic cloud computing applications[END_REF]. In response to this matter, several work [START_REF] Gambi | Automated testing of cloud-based elastic systems with AUToCLES[END_REF][START_REF] Islam | How a Consumer Can Measure Elasticity for Cloud Platforms[END_REF][START_REF] Gambi | Iterative test suites renement for elastic computing systems[END_REF][START_REF] Gambi | Testing Elastic Computing Systems[END_REF][START_REF] Gambi | Testing elastic systems with surrogate models[END_REF][START_REF] Albonico | Monitoring-based testing of elastic cloud computing applications[END_REF] have been proposed to address elasticity testing of cloud systems.

Gambi et al. [START_REF] Gambi | Testing Elastic Computing Systems[END_REF] propose a conceptual framework for testing elastic cloud systems that helps tester to manage four activities: test case generation, test execution, data analysis, and test evolution. In this paper, we focus on the rst two activities. While, the rst activity generates test cases in order to attend tester's specication, the second activity runs test cases against the cloud system.

These two activities require tester's eort to design and implement test cases, and to deploy and congure cloud system repeatedly to run each test case. In test cases, tester species (a) how the system should be set up before running the test, (b) the test scenario (e.g. which request(s) is sent to verify a specic behavior), (c) how the system is supposed to behave correctly or not. That specication requires information dedicated to the elasticity. This includes the elasticity workow, i. e., through which elasticity conguration the cloud system is led (e. g., sequence of resource allocation and deallocation). To manage the elasticity workow, workload must be properly generated. The deployment and (re-)conguration of the cloud system also includes load generators setup, setting auto-scaling on cloud provider, (re-)starting cloud system components, etc.

Considering elasticity in test cases is complicated since it requires managing many parameters. Cloud providers, such as Amazon Elastic Compute Cloud (EC2) 1 and Google Cloud Compute Engine (CE)2 , usually provide Commandline Interfaces (CLI). CLIs help the tester to setup elasticity when testing since they abstract cloud system deployment, management, including elasticity's parametrization. However, they admit wide variability of cloud system conguration, more than necessary for elasticity testing. Furthermore, each cloud provider has its own CLI, which preclude portable commands (that execute over any cloud provider).

In this paper, we propose a generic Domain Specic Language (DSL) for elasticity setup when testing cloud systems, helping to generate and execute test cases. Our approach alleviates test case generation by centralizing the elasticity setup in this dedicated language, whereas the other part of a test case can be implemented as usual (e.g. in JUnit) This DSL helps tester to set up cloud system and its dependencies, auto-scaling, desired elasticity workow, and test execution schedule. Then, it is compiled to a code that automatically executes elasticity testing, without further tester's interaction. In preliminary results, our DSL reduces the number of words to setup elasticity testing, and requires lower tester's eort to adapt a test case to be executed on several cloud providers.

The paper is organized as follows. Section 2 introduces some background. Section 3 describes the DSLs for elasticity testing setup. Section 3 describes how specications are compiled to executable code. Section 5 discusses about the preliminary results using our approach. Section 6 reports the related work, and Section 7 concludes and lists perspectives.

BACKGROUND

In this section, we describe major aspects of cloud computing elasticity, which help understanding our DSL-based approach. We also remain Thiery et al. [START_REF] Thiery | A DSL for Deployment and Testing in the Cloud[END_REF] DSL for setting up deployment of cloud systems.

Cloud Computing Elasticity

Main cloud infrastructures [START_REF]Cloud Computing Trends: 2016 State of the Cloud Survey[END_REF] admit by default thresholdbased auto-scaling (i. e., elasticity). Figure 1 depicts a typical threshold-based elasticity. In this gure, we see that resource demand (continuous line) varies overtime, such variation essentially follows workload variation. For explanatory reasons, we only consider a resource demand that increases from 0 to 1.5, then decreases to 0. When resource demand exceeds the scale-out threshold and remains higher during the scale-out reaction time, cloud elasticity controller assigns a new resource. The new resource becomes available after a scale-out time, the time cloud infrastructure spends to allocate it. Once the resource is available, the threshold values are updated accordingly. It is similar considering the scale-in, respectively. Except that, as soon as the scale-in begins, the threshold values are updated and the resource is no longer available. Nonetheless, the infrastructure needs a scale-in time to release the resource.

Elasticity States

When applications are deployed on a cloud infrastructure, workload uctuations lead to resource variations (elasticity). These variations drive the application to new, elasticityrelated, states. Figure 2 depicts the runtime lifecycle of an application running on a cloud infrastructure.

At the beginning the application is at the ready state (ry), when the resource conguration is steady (ry s substate). Then, if the application is exposed for a certain time (scale-out reaction time, ry sor substate) to a pressure that breaches the scale-out threshold, the cloud elasticity controller starts adding a new resource. At this point, the application moves to the scaling-out state (so) and remains in this state while the resource is added. After a scaling-out, the application returns to the ready state. It is similar with the scaling-in state (si), respectively.

DSL for Cloud System Deployment

When testing cloud systems considering elasticity, testers rst need to deploy the system under test. Thiery et al. [START_REF] Thiery | A DSL for Deployment and Testing in the Cloud[END_REF] propose a DSL for setting up deployment of cloud systems. Their DSL is divided into two dimensions: deployment bundle, and cloud provider.

Deployment Bundle (DB)

It sets up cloud system components and dependencies. We can set up multiple instances of software bundle. Each software bundle may group either cloud system or testing tool software components. Software component may have dependencies, such as other software component or external les (i. e., conguration les or executable scripts).

Listing 13 shows an example of software bundle setup for a Web application. First of all, we describe software artifacts. In the example, http is installed by a package installer (e. g., apt-get, yum, etc.), while phpapp is an interpreted PHP application, remotely transferred from local (src) to remote (dest) path. After, we describe external les, also with local and remote paths. Finally, we describes software bundles.

In the example, we rst bundles Web application artifacts (app), then the testing tool ones (testingTool). Software bundles are deployed on deployment instances. Each deployment instance starts up an Operational System (OS) on a Virtual Machine (VM) that may have different combinations of computational resource (CPU, memory, etc.). Deployment instances use resource from a cloud provider's geographic zone. Software bundle may require some port conguration, e. g., port 80 for external interactions with Web server. Listing 2 describes an example of Amazon EC2's resource setup. In this DSL, we start by setting up an VM image (image ), which refers to existing cloud provider's image. In the example, we set an hypothetical image identier (ami-1234 ), and describe which Operational System (OS) 4

DSL to Set Up Auto-Scaling (AS)

To enable elasticity, we must set up auto-scaling on cloud provider. Threshold-based auto-scaling is a common strategy among major cloud providers [START_REF]Cloud Computing Trends: 2016 State of the Cloud Survey[END_REF]. It basically consists of varying a cloud resource when a threshold is breached for a while (see Section 2.1). Figure 3 ResourcePool describes the cloud resource (cloudResource) that is varied, and restricts its amount (between minSize 4 This is because we cannot straightforwardly get OS information from cloud provider. and maxSize ). Resource variation is regulated according to the Police properties. Police properties state time constraints (i. e., cool down 5 and reaction time periods), and resource variations (e. g., add one resource) performed when the time constraints are satised. Police is checked every time an alarm (Alarm) is triggered, i. e., threshold is breached. Alarm describes a threshold and resource usage that breaches the threshold. Listing 3 describes an example of threshold-based autoscaling. The resource pool wsrv pool is associated to the websrv deployment instance (see Listing 2), and may have from 1 to 10 instances. As police, we set a cool down period of 60; 000 ms, and a reaction time with same duration, adding one new resource from wsrv pool resource pool. We set the alarm highCPU assuming threshold is breached when the maximum (statistics=Maximum) CPU usage (resource-Type=CPU ) is higher than (comparatorOperator=>) 60% (threshold=60). . . . // O t h e r a l a r m s . g

DSL to Set Up Elasticity Driving (ED)

For some tests, such as regression testing and bug reproduction, it may be necessary to have a deterministic elasticity, reaching or repeating a strict behavior. In a previous work [START_REF] Albonico | Controlling the Elasticity of Web Applications on Cloud Computing[END_REF], we address deterministic elasticity generating proper workload that drives cloud system through required elasticity behavior, i. e., sequence of elasticity states. Despite our previous work successfully drives cloud applications through the given sequence of elasticity states, it requires much tester's eort. Tester has to write substantial amount of code to set up elasticity driving.

Another contribution of our DSL is to abstract elasticity driving setup. Figure 4 illustrates the DSL model. In the model, we have a resource pool (pool), which refers to cloud resource that is driven. It also admits a workload type (workType), and either to generate a sequence of elasticity states (GeneratedFlow) or to preset one (Preset-Flow ). To generate a sequence, we have to set the number of scaling-out (scalingOuts) and scaling-in (scalingIns) a sequence must have. Then, elasticity states are distributed in a way all scaling-in and scaling-out happen, respecting Re-sourcePool 's properties. For a preset sequence, we set the elasticity states in the order we want them to occur. Listing 4 shows an example of elasticity driving setup. In the example, we set up elasticity driving to drive cloud resource in wsrv pool pool using Read workload type. We preset the following sequence of elasticity states: Here, we follow a principle of our previous paper [START_REF] Albonico | Monitoring-based testing of elastic cloud computing applications[END_REF], where some of cloud system's tasks only occur during certain elasticity states. For instance, massive data replication only occurs when new nodes are already added (ready state). Therefore, it is not necessary to test it beforehand, i. e., while resource is being added (scaling-out state).

Our DSL allows tester to set up the execution of test methods during either specic states or all elasticity states. Test methods have test script (testScript) as attribute. A test script can be any executable command, such as a java class (e.g. JUnit) or a shell script. In this way, tester can write generic test methods. Then, he/she associates test methods to elasticity states they must execute along. Listing 5 shows an example of setup of test method schedule. In the example, we set two test methods (test.test1 and test.test2 ) from a Java Archive (JAR) le (test.jar). Then, they are associated to scaling-out state of elasticity driving wsrv drive, and set to execute in parallel. First, tester writes test case setup (TESetup.es) using our DSL and Thiery et al. one (in the gure, divided by specialization). Then, tester selects a cloud provider's mapping le (DSL to CLI Mapping ), which maps elements of our DSL to arguments of cloud provider's CLI. Finally, we compile test case setup into an executable code in cloud provider's CLI.

Listing 6 shows a partial Amazon EC2's mapping le, which describes the EC2's command to deploy instances and one of its arguments: image identier ({image-id). This argument value is mapped from imageId, set in cloud provider's resource setup (see Listing 2). The compilation of this command would result in a code such as: g Theoretically, using mapping le makes our approach portable to any cloud provider that allows command line. We provide mapping les for Amazon EC2, Google CE, and Openstack. Furthermore, we could write mapping les to further cloud providers, which is not a tester's task. A specialist, such as a network manager, writes this le once for all, then tester uses it.

PRELIMINARY RESULTS

In this section, we measure the impact of using our DSL on writing elasticity testing setup. We consider two case studies, already used in previous papers, where we test distinct cloud applications through elasticity: 1) a MongoDB replica set [START_REF] Albonico | Monitoring-based testing of elastic cloud computing applications[END_REF], and 2) a distributed web application [START_REF] Albonico | Controlling the Elasticity of Web Applications on Cloud Computing[END_REF].

The main objective of this work is to alleviate tester's effort considering elasticity when generating test cases. Therefore, we so far provide a way to write elasticity part of test cases, then compile it to executable code. The current study do not go further on elasticity testing execution. However, we plan to do it as part of a future work.

First Case Study (CS1): Testing a Mon-goDB Replicat Set

The rst case study tests MongoDB deployed as a replica set 6 . In this experiment, we drive MongoDB through the following sequence of elasticity states: ready, scalingout, ready, scaling-out, ready, scaling-in, ready, scaling-out, ready, scaling-in, ready, scaling-in, ready, scaling-in, ready.

Here, we consider a test method that tests performance of MongoDB through all elasticity states. The current experiment considers only the elasticity setup of a test case, since testers do not use our DSL to write the rest of the test case (i.e. the test methods referred in TS part of our DSL).

Second Case Study (CS2): Testing a Distributed Web Application

The second case study tests a distributed web application. Its architecture is made by a centralized database server, a load balancer, and n web servers. We drive the web application through 10 scale-out and 10 scale-in in sequence. In our previous paper, we do not test the web application. Here, we consider an hypothetically test case is associated to scaling-out and scaling-in elasticity states. We choose this test method schedule to be dierent than rst case study.

Results

For each case study, we write the elasticity testing setup in our DSL. These setups are compiled to CLI for three dierent cloud providers: Amazon EC2, Google CP, and OpenStack. Then, we compare tester's eort on writing elasticity testing in both, our DSL and CLIs. We measure tester's eort in amount of words: total amount of words, and cumulative amount of new words.

Total Amount of Words

Total amount of words refers to the amount of words in an elasticity testing setup.

Table 1 describes the amount of words of elasticity testing setups for the elasticity testing case studies. Setups written in our DSL contain almost the same amount of words for all cloud providers (only 6 words changed as explained next subsection), while setups written with CLIs dier in amount of words according to cloud provider. Furthermore, setups written in our DSL result in fewer words for all cloud providers and case studies. Considering the amount of words as an eort, our DSL reduces considerably the tester's effort: Amazon EC2 (CS1 % 24%, C S2 % 22%), Google CP (CS1 % 38%, and C S2 % 36%), and OpenStack (CS1 % 43%, and C S 2 % 39%).

Figure 7 depicts the eort in amount of words to write setups for the case studies. In the gure, the dashed line connects CS1 eorts, while the solid line connects CS2 eorts. 6 Furthermore, we see that such lines never cross each other, and the distance between them is almost homogeneous. This is because from CS1 to CS2, the eort varies proportionally (with an approximation between 1:09% and 1:1%) for every setup. This mean the dierence among setups should be constant for other case studies. An encouraging result, which would result in less eort even when writing future elasticity testing setups in our DSL.

Our DSL on all the cloud provider Google CP (no DSL)

Cumulative Amount of New Words

Total amount of new words refers to the cumulative amount of words necessary to re-write an existing elasticity testing setup, making it suitable to other cloud provider. For instance, a tester may execute the same elasticity testing over dierent cloud providers, (re-)writing setups for all of them. We use the following formula to represent: Ci = Ci 1 + (Si Si 1 ), where i denotes the sequence the setup is written, and Si Si 1 denotes the amount of new words from previous to current setup (S).

Graph of Figure 8 illustrates the cumulative amount of new words as case studies setup is (re-)written for a given sequence of cloud providers: Amazon EC2, Google CE, and OpenStack. In the gure, continuous lines illustrate the cumulative amount of new words for setups written in our DSL, while dashed lines illustrate the cumulative amount of new words for setups written with cloud providers' CLIs.

In the graph, we cannot see the variation for setups written in our DSL. This is because using our DSL the variation is slight, only 6 words change from one setup to another. These words refer to cloud provider's resource, such as image identier and zone name, named distinctly among cloud providers. On the other hand, the variation for setups written in cloud providers' CLIs is visible, it more than double from rst to last setup (% £2:1 for both case studies).

RELATED WORK

In literature, there are some model/DSL-based approaches for the deployment and provisioning of cloud systems. However, most of them do not cover elasticity setup. Thiery et al. [START_REF] Thiery | A DSL for Deployment and Testing in the Cloud[END_REF] propose a model-based approach to automate the deployment of cloud systems. Likewise, Kirschnick et al. [START_REF] Kirschnick | Toward an architecture for the automated provisioning of cloud services[END_REF] propose a DSL that is limited to the provisioning and deployment. Other work propose DSLs to deploy Software-as-a-Service (SaaS) [START_REF] Sledziewski | A DSL-Based Approach to Software Development and Deployment on Cloud[END_REF] and Plataform-asa-Service (PaaS) [START_REF] Boujbel | MuScADeL: A Deployment DSL Based on a Multiscale Characterization Framework[END_REF]. None of these approaches address Infrastructure-as-a-Service (IaaS). Goncalves et al. [START_REF] Goncalves | CloudML: An Integrated Language for Resource, Service and Request Description for D-Clouds[END_REF] propose Cloud Modeling Language (CloudML), which models services, resource proles, and developer's requirements. However, their work requires the cloud provider to describe services and resources in CloudML, which is unusual. Finally, there are commercial DSL-based orchestration tools, such as Chef [2] and Puppet [3]. These tools allow not only the deployment and provisioning of cloud systems, but also the elasticity setup. However, these tools are not suitable for elastic testing as they don't support features such as elasticity states and test method schedule specications.

CONCLUSION

In this paper, we propose a DSL-based approach to set up elasticity testing. Its major contributions are portability and reduction of tester's eort to write elasticity testing specications. With a few changes in the setup, elasticity testing is executed over multiple cloud providers. With cloud providers' mapping les, we can easily adapt our approach to execute elasticity testing on any cloud provider. Our approach reduces considerable the amount of words on writing elasticity testing specications. In future work we will focus on automatic resource discovering. For instance, nding the cheapest resource that ts testing requirements. This makes specication in our DSL completely portable: a single specication executed over multiple cloud providers without any change. We also think in new features related to our elasticity testing research that is going on: test case generation, and elasticity controller.

Figure 1 :

 1 Figure 1: Representation of Cloud Computing Elasticity.

Figure 2 :

 2 Figure 2: Elasticity states.

Listing 1 :

 1 Example of software bundle setup written in Thiery et al. DSL. software bundles f s o f t w a r e h t t p d : pkg ' a p a c h e 2 ' ' 2 ' ; s o f t w a r e phpapp : s r c ' . / app / ' , d e s t ' / v a r /www/ app / ' ; . . . // O t h e r s o f t w a r e c o m p o n e n t s . s o u r c e a p a c h e c f g : s r c ' h t t p d . c o n f ' , d e s t ' / e t c / a p a c h e / h t t p d . c o n f ' ; . . . // O t h e r s o u r c e s . b u n d l e w s r v : app phpapp , d e p ( h t t p d , php , mysq ) , s r c ( a p a c h e c f g , c r e a t e d b , a d d s e r v e r ) , p r o v S c r i p t ( c r e a t e d b , a d d s e r v e r ) ; b u n d l e a p p b e n c h : t e s t i n g T o o l a p p b e n c h , d e p ( j a v a ) , s r c ( b e n c h c o n f , b e n c h ) , t e s t S c r i p t ( b e n c h ) ; . . . // O t h e r b u n d l e s . g 2.3.2 Cloud Provider (CP) It sets up cloud providers' resource used for software bundles deployment.

Figure 3 :

 3 Figure 3: Model of threshold-based auto-scaling setup DSL.

Listing 3 :

 3 Example of threshold-based auto-scaling setup written in our DSL. e l a s t i c i t y f p o o l w s r v p o o l : c l o u d R e s o u r c e w e b s r v , m i n S i z e 1 , m a x S i z e 1 0 ; . . . // O t h e r p o o l s . p o l i c e w s r v p o l i c e : r e s o u r c e P o o l s l a v e s , c o o l D o w n 6 0 0 0 0 , r e a c t i o n T i m e 6 0 0 0 0 , s c a l i n g A d j u s t m e n t 1 , a d j u s t m e n t T y p e Add ; . . . // O t h e r p o l i c e s . a l a r m highCPU : r e s o u r c e T y p e CPU, s t a t i s t i c s Maximum , c o m p a r i s o n '> ' , t h r e s h o l d 6 0 , p o l i c e w s r v p o l i c e ;

Figure 5 :

 5 Figure 5: Model of test executions setup DSL.

Figure 6 :

 6 Figure 6: Workow of compilation of elasticity testing specication into executable code.

6 :

 6 Example of command le for Amazon EC2.

  provider AWS f instanceCommand ' aws e c 2 r u n i n s t a n c e s ' : ' i m a g e i d ' i m a g e I d , . . . ;

Figure 7 :

 7 Figure 7: Eort on writing elasticity testing setups.

Figure 8 :

 8 Figure 8: Total amount of new words of elasticity testing setups.

  runs in the image. After, we list available cloud provider's geographical zones (zone). Finally, we set up deployment instances, referring a software bundle, VM image, cloud provider's machine type, port conguration, and geographic zone. Listing 2: Example of cloud provider's resource setup written in Thiery et al. DSL. Despite Thiery et al. DSL allows a variety of cloud system deployment, it does not address cloud computing elasticity and elasticity testing. In this paper, we propose a DSL that complements Thiery et al. work, adding support to set up elasticity and elasticity testing. Our DSL is three-dimensional: auto-scaling, elasticity workow, and test method schedule.

	resources EC2 f
	i m a g e i U 7 0 4 i 3 8 6 :
		i m a g e I d	' ami	1234 ' ,
		o s	' Ubuntu '	' 7 . 0 4 '	' i 3 8 6 ' ;
	z o n e EUWest :
	' eu w e s t	1a ' ,	' eu w e s t	1b ' ;
	i n s t a n c e w e b s r v :
		i m a g e i U 7 0 4 i 3 8 6 , m a c h i n e T y p e m3 . l a r g e ,
		p o r t C o n f i g	' 8 0 ' = ' 0 . 0 . 0 . 0 ' , z o n e EUWest ,
	. . .	b u n d l e w s r v ; // O t h e r i n s t a n c e s . g
	3. ELASTICITY TESTING DSL

  illustrates the model that represents threshold-based auto-scaling setup.

		<< enum >>
	ResourcePool	ResourceType
	minSize : Integer maxSize : Integer cloudResource : Instance	LoadBalancing Queue CPU Network
		Disk
	Police coolDown : Long reactionTime : Long scalingAdjustment : Integer adjustmentType : Adjustment-Type	<< enum >> Statistics Average Maximum Minimum Sum Count
		Growth
	Alarm	<< enum >>
	threshold : Real comparatorOperator : String resourceType : ResourceType statistics : Statistics

Listing 5 :

 5 Example of setup of test method schedule.In this section, we explain the compilation of elasticity testing setup written in our DSL into executable code. Figure6depicts the workow of this compilation.

	tests f
		t e s t t 1 :
		s c r i p t	' j a v a	j a r	. / t e s t . j a r	t e s t . t e s t 1 ' ;
		t e s t t 2 :
		s c r i p t	' j a v a	j a r	. / t e s t . j a r	t e s t . t e s t 2 ' ;
		s u i t e s 1 : s t a t e s s c a l i n g	o u t ,
		d r i v i n g	w s r v d r i v e ,
	g	t e s t m e t h o d ( t 1 , t 2 ) ,	i n	p a r a l l e l ;
	4. COMPILING SPECIFICATION INTO EX-
		ECUTABLE CODE
							Legend
		DB	CP	AS		ED	TS	Setups in
							DSL
			TESetup.es		Incoming Files
							Compiled
		DSL to CLI Mapping	Compiler			Code in CLI Executable	File Outcoming Incoming Compilation
							Cloud
							Interaction
			Infrastructure

Table 1 :

 1 https://docs.mongodb.com/manual/tutorial/deployreplica-set/ Total amount of words of elasticity testing setups.

	Cloud Provider	CS1 CS2
	Our DSL
	All C loud P roviders	246 273
	CLIs
	Amazon EC 2 Google C P OpenStack	326 364 392 433 430 476

https://aws.amazon.com/ec2/

https://cloud.google.com/compute/

Instead of using the syntax of Thiery et al. syntax, we use the same syntax that the one of our proposal to be coherent.

Period within previous scaling activity takes eect, so new variation is not allowed.