Introduction

Constructing an effective theory (macroscopic description) of a complex system with many interacting degrees of freedom, would be very helpful for understanding the system behaviour. Thermodynamics is such an example which focuses on the appropriate macroscopic properties of a system and the relevant ways of exchanging its energy with an environment. Specifically, we know that a physical system is better to work close to a reversible process in order to achieve a higher efficiency1. This is expected to be somehow true for biological systems which are out of equilibrium thermodynamic systems working at a nonzero power2. But what about other complex systems like the stock market or a city? We expect an efficient market to be close to a maximal entropy state, where nobody can systematically beat the market to make significant returns in a long run3,4,5. In this paper, however, we focus on a city system to investigate the extent to which the above picture holds for the process of movements in city. We define suitable measures of efficiency and irreversibility for a cycle of movements in the system. Then, by numerical simulations of the model with real and simulated population distributions, we show that the efficiency of movements is negatively correlated with the irreversibility of the process for plausible choices of the model parameters.

The science of city is mainly devoted to the application of concepts and methods of complex systems to cities6,7,8,9. A city is indeed an adaptive dynamical system which grows in size and population, and consumes energy to maintain its function and structure10,11,12,13,14. In particular, there are scaling relations connecting the macroscopic variables of a city such as population, area, energy consumption, gross domestic product, and other state variables6,15,16. These scaling (self-similar) behaviours can be reproduced and explained by some stochastic models of city formation and growth7,17. A city can also be viewed as a multilayer network of interdependent networks like the communication and transport networks8,18. The structure of this multiplex network affects the system dynamics (e.g. spreading processes) and function, and so the city efficiency19,20. City is also a system of agents making decisions based on the model that agents construct from the available information. The difference between this (ideally maximum-entropy) model and the actual one would result to inappropriate decisions and inefficiencies. This inefficiency is usually accompanied by increasing the disorder (uncertainty) or entropy production in the system, which is an essential hallmark of irreversible processes21,22,23.

Consider a cycle of movements from origins (home) to destinations (work) at the morning time and then back from the destinations to origins in the afternoon (see Fig. 1). A measure of efficiency can be defined here by comparing the total travel time of the individuals with the total number of necessary travels along the edges of the network, which is expected to represent the total cost of the movements24. The connectivity structure of the city and its population and work-places distribution, the flux of movements and travel strategies, are among the main factors that affect the above efficiency. Here, however, we are interested in possible relations with the irreversibility of the process. Let us assume that all the origin to destination (OD) movements start in a small time interval ΔTo. The people would arrive at the work places in a time interval ΔTd which is expected to be larger than ΔTo. Here, ΔTd is the time interval in which all arrivals happen. Two main reasons are at work here: the network structure and the flow dynamics. There are for example many shortest OD paths in the network which span a finite range of travel times even in the absence of intensive flows on the edges. In addition, the flows affect the travel times and even for two paths of the same length, the actual travel times could be very different because of differences in the flows. The same reasoning says that the time interval of returning back to home ΔTr should be larger than the destination time interval. This mechanism is responsible for entropy production by increasing the uncertainty in the system and raising the cost (time or energy) we need to bring the system back to its initial state.

Figure 1
figure 1

A cycle of movements from origins (O) to destinations (D). (a) An example of origin to destination path that differs from the destination to origin path, e.g., due to asymmetries in the travel times. (b) Schematic representation of the time intervals ΔTo, ΔTd and ΔTr. The starting times to of the OD trips are distributed in the time interval ΔTo with probability distribution P(to). In a general graph with multiple OD pairs, two trips which start from different origins at the same time may arrive at the same destination in different times. This gives rise to a destination time interval ΔTd which is usually larger than ΔTo and could result in backward flows which are very different from the forward flows.

Now suppose that \(\overrightarrow{{\bf{f}}}\) and \(\mathop{{\bf{f}}}\limits^{\leftarrow}\) represent the (average) flow distributions (on edges) for the forward (OD) and backward (DO) processes, respectively. The backward process is defined by reversing all the origin to destination trips. Then a measure of irreversibility can be defined by the distance or divergence of the two distributions \(D(\overrightarrow{{\bf{f}}}| | \mathop{{\bf{f}}}\limits^{\leftarrow})\). As mentioned above, the destination to origin trips are distributed in a destination time interval ΔTd that is usually larger than the origin time interval ΔTo. As a result, the DO travel times and flows are not necessarily the same as the OD ones. These asymmetries results to differences in the forward and backward flows and contribute to the irreversibility of the process. The above arguments suggest that a measure of irreversibility can be defined by the relative entropy of the forward and backward flow distributions or the relative entropy of the time intervals at the endpoints of the process. In the following, we present and study a minimal model of cyclic movements to make the above concepts and relations more quantitative.

Models and Settings

In this section, we present the main definitions and methods which are used to model the network flow dynamics. Consider a city of N sites with local populations {maa = 1, …, N} and total population M = ∑ama. The connectivity graph of the city is given by G(VE) where V is the set of sites and E is the set of edges. We use the simple growth model introduced in ref. 17 to produce reasonable population distributions for the model cities: start with an active seed of population mseed in the centre of a two-dimensional grid with undirected edges of unite length; A site is active if it has a nonzero population. At each time step, one node a is selected with probability proportional to ma + c0 where c0 > 0. The population at site a increases by one if there is an active site b close to site a, that is |xb − xa| ≤ r0 or |yb − ya| ≤ r0 for some small r0. Here (xaya) are the coordinates of site a. The above process is repeated for 106 iterations, where each iteration consists of N time steps. This model has been used to describe the scaling relations that are dependent on the profile of population in city17. Moreover, the qualitative behaviours of the model are not sensitive to the precise values of the parameters mseedc0 and r0.

Given the population distribution ma, we need a mobility law to construct the flux of movements mab from origins a to destinations b. Note that we do not need to have a direct connection from a to b. There are many works that try to reproduce the observed movements in cities by a simple mobility law25,26,27,28,29. For instance, the generalized gravity law states that mab is proportional to \({m}_{a}{m}_{b}/{r}_{ab}^{\alpha }\) for two sites at distance rab. In this study, we use the following mobility law27:

$${m}_{a\to b}={m}_{a}{p}_{a\to b}={m}_{a}\frac{{m}_{b}/M({r}_{ab})}{{\sum }_{c\ne a}{m}_{c}/M({r}_{ac})},$$
(1)

where M(rab) is the population in the circle of radius rab centred at site b. The ratio mb/M(rab) can be interpreted as the attractiveness of site b for an individual at site a. This model and the related generalizations are able to reproduce well the empirical data.

Finally, the flows Fab of movements on edges (ab) E are determined by a flux distribution problem that satisfies the system constraints and preferences. For instance, the flows can be obtained by minimizing the total travel time subject to the movements mab30,31. Here, instead, we use a more local and selfish strategy, where the movements from origin a to destination b go through the shortest-time path connecting the two nodes. The path is defined as the one that takes the minimum time based on the expected travel times for each edge of the network. The expected times can be obtained in a learning process using the history of the actual travel times.

Later in this section, we shall define a measure of efficiency focusing on the total travel time and the total number of trips. There are measures of transport or commuting efficiency defined in the literature addressing different aspects of the movements20,32,33,34,35,36. The route factor and its generalizations compare the topological distances in the network with the geometrical distances33,35. The excess commuting index on the other hand concerns with distribution of home and work places and compares the actual commuting distances with a theoretical optimal one32,34. Finally, the accessibility of a city can be quantified by the velocity and sociability scores defined in36. Each of these measures focuses on some structural or dynamical properties of the network and the commuting process. In this study, we are specifically interested in the efficiency of the process of movements concerning the travel times and the number of necessary trips (cost of travels).

The movement process

We are interested in a cycle of movements from origins to destinations and back to the origins. This is the basic motif of movement patterns in a city37,38,39,40. Let us assume that we are given the population distribution ma and the fluxes mab. Then, a cycle of the movement process is defined as follows:

  • The starting times of the OD trips are distributed (with a given probability measure) in a time interval ΔTo.

  • The transport services run at time intervals Δt = 1to carry the passengers in no = ΔTot time steps.

  • We obtain the flows Fab(t) at each time step t using a flow dynamics. Here Fab(t) is the number of people moving on edge (ab) in time step t. A simple strategy is to choose the shortest paths according to the expected times \({\widetilde{t}}_{ab}\), which are estimated from the previous cycles. For the initial cycle \({\widetilde{t}}_{ab}(0)={t}_{ab}(0)\), where the tab(0) are the travel times for free lines.

  • Given the flows, then the actual travel times are obtained from

    $${t}_{ab}({F}_{ab})={t}_{ab}(0)\left(1+g{(\frac{{F}_{ab}}{{F}_{ab}(0)})}^{\mu }\right),$$
    (2)

    where \(g{({F}_{ab}/{F}_{ab}(0))}^{\mu }\) is to model the influence of flows on the travel times41,42. The nonnegative parameters g and μ control the above effect. Here Fab(0) is a measure of the line capacity. Note that in general tba(0) ≠ tab(0) and Fba(0) ≠ Fab(0), for example, because of structural asymmetries.

  • The passengers return to their origin after spending time Tw at their destinations. Thus, the return times are distributed in the time interval ΔTr according to the arrival times.

Figure 1(panels a and b) gives an illustration of the above process with the associated time intervals for the trips from one origin to a destination. The relevant quantities here are the total travel time and the total number of active transport services (the cost or number of trips):

$$T={\sum }_{t}{\sum }_{(ab)}{F}_{ab}(t){t}_{ab}(t),$$
(3)
$$C={\sum }_{t}{\sum }_{(ab)}{\mathbb{I}}({F}_{ab}(t) > 0).$$
(4)

Here ∑(ab) denotes a sum over all directed edges of the connectivity graph G. The indicator function \({\mathbb{I}}(.\,)\) is one if the enclosed condition is satisfied, otherwise it is zero. Here we assume that only one service runs on directed edge (ab) if there exist at least one individual that has to travel along the edge. In a more realistic model, the services could have limited capacities and the number of services would depend on the number of passengers.

Given the travel time per person τ = T/M and the cost per person σ = C/M, we define the total efficiency η = ηOD + ηDO, with

$${\eta }_{OD}=\frac{1/{\tau }_{OD}}{{\sigma }_{OD}},\ \ \ \ \ {\eta }_{DO}=\frac{1/{\tau }_{DO}}{{\sigma }_{DO}}.$$
(5)

Note that both the number of trips and the travel times are minimized if: (i) the OD and DO trips occur in one time step (ΔTo, ΔTd Δt) and (ii) the expected travel times \({\widetilde{t}}_{ab}\) are close to the actual travel times (g → 0).

To define a measure of irreversibility, we first define the average forward and backward distributions

$$\overrightarrow{{f}_{ab}}={\sum }_{t\in \Delta {T}_{o}}{w}_{od}(t)\frac{{F}_{ab}(t)}{F(t)},$$
(6)
$$\mathop{{f}_{ab}}\limits^{\leftarrow}={\sum }_{t\in \Delta {T}_{d}}{w}_{do}(t)\frac{{F}_{ba}(t)}{F(t)}.$$
(7)

Here wod(t) and wdo(t) are the fraction of OD and DO movements at time step t, respectively. More precisely, wod(t) = (∑abmab(t))∕M, and recall that starting time of the movements mab are distributed in ΔTo such that \({m}_{a\to b}={\sum }_{t\in \Delta {T}_{o}}{m}_{a\to b}(t)\). Similarly we define the fractions wdo(t) for the DO trips. The normalization factors are F(t) = ∑(ab)Fab(t). Note that the backward flow \(\mathop{{f}_{ab}}\limits^{\leftarrow}\) on directed edge (ab) is defined by the flows Fba on the edge (ba) for the DO trips. Then, the Kullback-Leibler (KL) divergence or the relative entropy of the two probability distributions is given by

$${D}_{KL}(\overrightarrow{{\bf{f}}}| | \mathop{{\bf{f}}}\limits^{\leftarrow})=-\,{\sum }_{(ab)}\overrightarrow{{f}_{ab}}{\rm{ln}}\,(\mathop{{f}_{ab}}\limits^{\leftarrow}/\overrightarrow{{f}_{ab}}).$$
(8)

The KL divergence is nonnegative and it is zero only when the two distributions are the same.

Another measure of entropy production in the process can be defined by considering the expansion of the time intervals ΔTd and ΔTr with respect to the ΔTo. To quantify this we define the relative entropy of the time intervals ΔST = ΔSOD + ΔSDO, where

$$\Delta {S}_{OD}={\rm{ln}}\,({n}_{d})-{\rm{ln}}\,({n}_{o}),$$
(9)
$$\Delta {S}_{DO}={\rm{ln}}\,({n}_{r})-{\rm{ln}}\,({n}_{d}).$$
(10)

The number of time steps in each interval is given by no = ΔTot, nd = ΔTdt, and nr = ΔTr∕Δt.

Results

We take a two-dimensional grid of N = L × L sites for G(VE) with connectivity z = 4 and links of length one. The population distribution (ma) is constructed by simulation of the growth model described in Sec. II with parameters mseed = 1, c0 = 1, r0 = 1. For a real city, the network structure G and population distribution are provided by the available data from43,44 (see Supplemental Fig. 1 for an example). The OD mobilities are obtained by Eq. 1. Given the expected travel times \({\widetilde{t}}_{ab}\), the flows Fab are determined by the shortest path (in time) strategy. We shall assume that the starting time of the OD trips in the time interval ΔTo obeys a centred Gaussian distribution of standard deviation ΔTo/3. The actual travel times are computed by Eq. 2 with Fab(0) = Fba(0) = M/(2|E|). We also assume that tab(0) = tba(0) = 1 for all directed edges in G. Therefore, there is no structural asymmetry in the model. We consider a learning process in which the expected travel times are updated by using the information about the actual travel times in the previous cycle. More precisely, for cycle n we take \({\widetilde{t}}_{ab}(n)=\lambda {t}_{ab}(n-1)+(1-\lambda ){\widetilde{t}}_{ab}(n-1)\), with λ = 1/2 as a damping parameter and \({\widetilde{t}}_{ab}(0)={t}_{ab}(0)\). This means that the expected travel times for the next round are the average of the actual and expected times in the previous round. In other words, we are trying to find a good estimation of the travel times by slowly correcting the expected values according to the new observations. We repeat the cycle for nc = 20 times and report the results at the end of this process.

We first check the behaviour of the proposed observables (DKL, ΔSTη) with the parameters of the model (gμ, ΔTo). Two observables measure the irreversibility of the process: the KL divergence (DKL) and the relative entropy (ΔST). The KL divergence is divided by \({\rm{ln}}\,(2| E| )\) to be able to compare it for different city sizes. The third observable measures the efficiency of the process (η). The parameters of the model that we consider are the time window of starting the OD trips (ΔTo) and the two variables, μ and g, which control the capacity of the lines (the influence of flows on the travel times). In Fig. 2 the results obtained by the simulated population distributions are shown. The DKL and ΔST increase with the parameter g for the given values of μ = 1, 2 (Fig. 2, panel a). Instead, the same two quantities decrease when ΔTo increases (Fig. 2, panel b). In our interpretation, this means that the entropy production or irreversibility of the process increases when the line capacity decreases, and it decreases by enlarging the time window of the OD trips (ΔTo). Instead, the efficiency of the movement process (η) decreases when the capacity of the lines decreases (Fig. 2, panel c) and it increases when ΔTo is widened (Fig. 2, panel d). The same dependence of the quantities DKL, ΔSTη on the parameters gμ is observed when the population distributions of 20 real cities is used (Fig. 3).

Figure 2
figure 2

Variation of the average efficiency and relative entropies with g and ΔTo. Panels (a,c): the behaviour when only g changes with μ and ΔTo = 32 fixed. Panels (b,d): the behaviour when only ΔTo changes with μ and g = 1 fixed. The average is taken over 100 realizations of population distribution and movements (with learning) on a two-dimensional grid of size N = 50 × 50. The errorbars are about the size of the larger points.

Figure 3
figure 3

The average behaviour of the efficiency (η) and the relative entropies (DKL, ΔST) in 20 real cities (the core parts). The data are obtained by numerical simulation of the movements after 20 learning cycles using the population distributions of the cities. The average is taken over the cities for ΔTo = 32. Each curve shows the behaviour for a given value of μ (0, 3).

Figure 4 displays the dependence of η on the DKL (panel a) and ΔST (panel b) when both the parameters g (0, 2) and μ (0, 3) are varied for a fixed ΔTo = 32. The observed behaviours, which are obtained from real population distributions, can well be described by an exponential relation \(\eta \propto \exp (-\beta {D}_{KL})\), with exponent β = 19.3 ± 1.8. Similar behaviour is also observed with the simulated population distributions (Supplemental Figs. 24). For comparison, in Fig. 4 (panel c and panel d) we also show the results obtained with no learning, that is without any knowledge of the actual travel times in the previous cycles. Note that the learning process dose not necessarily increase the system efficiency η, because the aim of learning here is just to find the shortest (time) path. Moreover, as the figure shows, the learning process considerably changes the behaviour of the efficiency with the KL divergence. The relation with the relative entropy ΔST, by contrast, does not qualitatively change by the learning process. The latter solely measures the changes in the size of the time intervals ΔTd and ΔTr which usually grow by increasing g or ΔTo. On the other hand, the KL divergence is affected by both the size of the time intervals and the distribution of the arrival times in these intervals. The destination time interval ΔTd plays a central role in this study; the network structure and the impact of the forward flows on the travel times (Eq. 2) usually give rise to a large ΔTd (larger than ΔTo). An extreme example is the case that all the OD trips start at the same time. And the size of ΔTd directly affects the divergence of the backward flows from the forward ones. Here, both the forward and backward travel times TODTDO are expected to increase with ΔTd (see Supplemental Fig. 5).

Figure 4
figure 4

The average efficiency (η) vs the relative entropies (DKL, ΔST) for 20 real cities (the core parts). Panels (a,b): the behaviour for different values of g (0, 2) and μ (0, 3) for a given ΔTo = 32. Panels (c,d): the behaviour when only g changes with μ and ΔTo fixed.

Finally, we studied the cumulative distribution of the simulated OD times TOD, the normalized flows fab, and the destination time intervals (across the sites), for the core parts of the cities (Supplemental Fig. 6). Interestingly, here we observe a tendency to exhibit scale free behaviours by introducing the impact of the flows on the travel times. Note that distribution of the arrival times in ΔTd is by definition similar to that of TOD. Moreover, distribution of the actual travel times tab is related to that of flows fab after Eq. 2; if \(P({f}_{ab})\propto {f}_{ab}^{-\alpha }\) then one gets \(P({t}_{ab})\propto {t}_{ab}^{-(1+(\alpha -1)/\mu )}\) for tab tab(0). For instance, we find α 2 and \(P({T}_{OD})\propto {T}_{OD}^{-\gamma }\) (TOD Δt) with γ 3/2 for the city Prague when g = 1, μ = 3, ΔTo = 32.

Conclusion

We observed that reasonable definitions of efficiency and irreversibility are negatively correlated in a plausible model of movements in a city. It means that by reducing the process irreversibility one can indirectly enhance the movement efficiency. For the numerical simulation of the process, we used models that try to reproduce the main features of actual population distributions and mobility fluxes. We also used real population distributions of some real cities to compute the associated efficiency and irreversibility from the above model of movements. An empirical estimation of these quantities however needs more detailed information about the forward and backward flows, the travel times and the number of necessary trips.

One should see how much the results of this study are robust to change in definitions of the efficiency and irreversibility. Specifically, other measures of entropy production can be studied within the framework of stochastic thermodynamics23. Also, it would be interesting to see how these quantities are related to the system criticality and predictability45,46,47. The measures we introduced here are suited for the process of movements in the city. One could have such measures of efficiency and entropy production for other processes happening in a city, and so for the whole city. As already mentioned, the main task here is to find out if the negative correlation between the efficiency and irreversibility is a working principle of the cities.