# Optimal Transport in Multilayer Networks for Traffic Flow Optimization
## 2 Materials and Methods
### The Model  
We consider the formalism of optimal transport theory, and in particular, recent works that map the setting of solving a standard optimization problem into that of solving a dynamical system of equations [24; 25; 26; 27; 28; 29; 30; 40]. Specifically, we model two main quantities defined on network edges: (i) fluxes \(F_{e}\) of passengers traveling through an edge \(e\); and (ii) conductivities \(\mu_{e}\), which are quantities determining the flux passing through an edge \(e\). Intuitively, the conductivity \(\mu_{e}\) of an edge can be seen as proportional to the size of the edge \(e\). To keep track of the different routes that passengers have, we consider multi-commodity formalism as in [40], i.e., we distinguish passengers based on their entry station \(a\in\mathcal{S}\), where \(\mathcal{S}\subseteq\mathcal{V}\) is the set of stations where passengers enter, and we denote with \(M=|\mathcal{S}|\) the number of passenger types. With this formalism, we have that the fluxes \(F_{e}\) are \(M\)-dimensional vectors, where the entries \(F_{e}^{a}\) denote a number of passengers of type \(a\) traveling on edge \(e\). The important modeling choice is that the conductivities \(\mu_{e}\) are shared between passengers, thus they are scalar numbers contributing to the cost for all passenger types traveling through \(e\). This formalism can be equally applied to both edge types: intra-layer and inter-super edges. We assume that fluxes are determined by pressure potentials \(p_{u}^{a}\) defined on nodes as follows:  
\[F_{e}^{a}:=\frac{\mu_{e}}{\ell_{e}}(p_{u}^{a}-p_{v}^{a}),\quad e=(u,v)\quad. \tag{1}\]  
We model the number of passengers entering a station \(a\) with a positive real number \(g^{a}\). For notational convenience, we define a \(N\times M\) dimensional matrix of entries \(g_{u}^{a}\) such that \(g_{u}^{a}:=0\) if \(u\
eq a\), and \(g_{u}^{a}:=g^{a}\) if \(u=a\). Similarly, we define with \(l_{u}^{a}\) the number of passengers of type \(a\) exiting at node \(u\). Here, the only constraint is that \(h_{u}^{a}=0\) if \(u=a\) to avoid unrealistic situations where passengers entering in one station exit from the same station. Finally, we define the \(N\times M\)-dimensional source matrix with entries \(S_{u}^{a}=S_{u}^{a}-l_{u}^{a}\), which indicates the number of passengers of type \(a\) entering or exiting a station. Notice that for each \(a\in\mathcal{S}\) we have \(\sum_{u}S_{u}^{a}=0\), meaning the system is isolated, i.e., all the passengers of a certain type who enter the network also exit. With this in mind, we enforce mass conservation by imposing Kirchhoff's law on nodes. To properly enforce this constraint, we need to consider all the edges, both intra-layer and inter-layer edges. This can be compactly written by considering the multilayer  
Figure 1: Example of multilayer structure. We show an example of a 2-layer network with \(N=18\) (\(N_{1}=10\), \(N_{2}=4\) and \(N_{super}=4\)). (**Left**) adjacency matrix \(A\), colors denote the layer type: blue is layer \(1\), red is layer \(2\) and green is the super layer. (**Right**) the 2-layer network with layer \(1\) on the bottom, layer \(2\) on top, and the super nodes in between. network signed incidence matrix \(B\) with entries \(B_{w}=1,-1,0\) if node \(v\in\mathcal{V}\) is the start, end of edge \(e\in\mathcal{E}\), or none of them, respectively. With this in mind, [PERSON]'s law can be written as follows:  
\[\sum_{e}B_{w}F_{e}^{a}=S_{w}^{a},\quad\forall a\in\mathcal{S},\forall v\in \mathcal{V}\quad. \tag{2}\]  
Finally, we assume that the conductivities follow the following dynamics:  
\[\dot{\mu}_{e}=\mu_{e}^{\theta_{w}}\frac{\sum_{a\in\mathcal{S}}(p_{u}^{a}-p_{v} ^{a})^{2}}{\ell_{e}^{2}}-\mu_{e},\quad\forall e\in\mathcal{E}\quad, \tag{3}\]  
where \(q_{e}\) encodes the type of edge, as defined in Section 2.1. The parameter \(0<\beta_{q_{e}}<2\) is important, as it determines the type of optimal transport problem that we aim to solve, which we describe in more detail later.