Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Routing Games

Selfish agents choosing routes through a shared network rarely produce the socially optimal outcome. This chapter studies routing games and the Price of Anarchy, quantifying how much individual optimisation can degrade collective performance.

A driver spotting a tempting shortcut on a map.

Figure 1:A route only stays quick for as long as few people take it. Once every driver spots the same shortcut and switches onto it, the shortcut is no quicker than the road it replaced.

Motivating Example: Competing delivery companies

In a busy city, two rival delivery companies, QuickShip and TurboExpress, operate daily distribution routes to deliver packages to the central business district.

Each company starts from its own warehouse, located in different suburbs on opposite sides of the city. Every morning, the companies dispatch their fleets toward the central depot, but must decide how to route their vans:

The travel costs for each route depend on the level of congestion:

Each source has a total demand of r=1/2r = 1 / 2 units of traffic to send to the sink.

This is shown diagrammatically in Figure 2.

Each company decides independently how to distribute its fleet across the available routes, aiming to minimise its own delivery costs. However, since the shared road’s cost depends on total usage, each company’s decision affects the other’s outcome.

This setting creates a routing game, where decentralised decisions lead to interdependent costs. We will analyse this scenario to explore the concept of Nash equilibrium in network routing, and investigate how self-interested routing can result in stable, but potentially inefficient, traffic patterns.

A routing game with 2 sources and 1 sink

Figure 2:The routes available to QuickShip and TurboExpress.

Theory

Definition: Routing Game

A routing game (G,r,c)(G,r,c) is defined on a graph G=(V,E)G=(V,E) with a defined set of sources sis_i and sinks tit_i. Each source-sink pair corresponds to a set of traffic (also called a commodity) rir_i that must travel along the edges of GG from sis_i to tit_i. Every edge ee of GG has associated to it a nonnegative, continuous and nondecreasing cost function (also called latency function) cec_e.

Example: The Routing Game Representation of the Delivery Companies Game

For the routing game in Figure 2:

Definition: Set of Paths

For any given (G,r,c)(G,r,c) we denote by Pi\mathcal{P}_i the set of paths available to commodity ii.

Definition: Feasible Flow

On a routing game we define a flow ff as a vector representing the quantity of traffic along the various paths, ff is a vector index by P\mathcal{P}. We call ff feasible if:

∑P∈PifP=ri\sum_{P\in\mathcal{P}_i}f_P=r_i

Example: Feasible Flows for the Delivery Companies Game

For the routing game in Figure 2:

P1={(s1,a,t),(s1,t)}\mathcal{P}_1=\{(s_1,a,t),(s_1,t)\}

and

P2={(s2,a,t),(s2,t)}\mathcal{P}_2=\{(s_2,a,t),(s_2,t)\}

The set of all possible paths is denoted by P=∪iPi\mathcal{P}=\cup_{i}\mathcal{P}_i.

Definition: Cost function

For any routing game (G,r,c)(G,r,c) we define a cost function C(f)C(f):

C(f)=∑P∈PcP(fP)fPC(f)=\sum_{P\in\mathcal{P}}c_P(f_P)f_P

Where cPc_P denotes the cost function of a particular path PP: cP(x)=∑e∈Pce(x)c_P(x)=\sum_{e\in P}c_e(x). Note that any flow ff induces a flow on edges:

fe=∑P∈P if e∈PfPf_e=\sum_{P\in\mathcal{P}\text{ if }e\in P}f_P

So we can re-write the cost function as:

C(f)=∑e∈Ece(fe)feC(f)=\sum_{e\in E}c_e(f_e)f_e

Example: Cost function for the Delivery Companies Game

For the routing game in Figure 2:

Let f=(α,1/2−α,1/2−β,β)f=(\alpha,1/2-\alpha,1/2-\beta,\beta) as shown in Figure 3.

A routing game with 2 sources and 1 sink with the flow vector shown

Figure 3:The vector ff showing the flow on the game

The cost of f(α,1/2−α,1/2−β,β)f(\alpha,1/2-\alpha,1/2-\beta,\beta) is given by:

C(f)=α2×α+3/2β×β+(1−α−β)×(1−α−β)=α3+3/2β2+α2+2αβ+β2−2α−2β+1\begin{align*} C(f)&=\alpha^2\times\alpha+3/2\beta\times\beta+(1-\alpha-\beta)\times(1-\alpha-\beta)\\ &=\alpha^3+3/2\beta^2+\alpha^2 + 2\alpha\beta + \beta^2 - 2\alpha - 2\beta + 1 \end{align*}

Definition: Optimal Flow

For a routing game (G,r,c)(G,r,c) we define the optimal flow f∗f^* as the solution to the following optimisation problem:

Minimise ∑e∈Ece(fe)fe\sum_{e\in E}c_e(f_e)f_e:

Subject to:

∑P∈PifP=rifor all ife=∑P∈P if e∈PfP for all e∈EfP≥0\begin{align*} \sum_{P\in\mathcal{P}_i}f_P&=r_i&&\text{for all }i\\ f_e&=\sum_{P\in\mathcal{P}\text{ if }e\in P}f_P&&\text{ for all }e\in E\\ f_P&\geq 0 \end{align*}

Minimising a convex function over a rectangle

In the examples of this chapter a flow is described by two numbers, α\alpha and β\beta, each restricted to an interval: 0≤α≤1/20 \leq \alpha \leq 1/2 and 0≤β≤1/20 \leq \beta \leq 1/2. Minimising a function F(α,β)F(\alpha, \beta) over this square comes down to two checks.

  1. Inside the square: if the minimum is not on the boundary, both partial derivatives are zero there:

    ∂F∂α=0and∂F∂β=0.\frac{\partial F}{\partial \alpha} = 0 \qquad\text{and}\qquad \frac{\partial F}{\partial \beta} = 0.
  2. On the boundary: if the minimum is on an edge, then the derivative along that edge is zero, and moving away from the edge into the square cannot decrease FF. For example, on the edge α=1/2\alpha = 1/2 we need ∂F∂β=0\frac{\partial F}{\partial \beta} = 0 and ∂F∂α≤0\frac{\partial F}{\partial \alpha} \leq 0: since FF decreases (or stays the same) as α\alpha increases, the best we can do is push α\alpha as far as it goes. On the edge α=0\alpha = 0 the inequality is reversed: ∂F∂α≥0\frac{\partial F}{\partial \alpha} \geq 0. At a corner, the inequality applies to both variables.

These checks find candidates for a minimum. When FF is convex, any point that passes them is the minimum over the whole square, and no further comparison is needed. All the functions we minimise in this chapter are convex. In particular, the potential function defined below is convex whenever every edge cost is non-decreasing in the flow on that edge.

Example: Optimal Flow for the Delivery Companies Games

In Figure 3 this corresponds to:

Minimise C(α,β)=α3+3/2β2+α2+2αβ+β2−2α−2β+1C(\alpha,\beta)=\alpha^3+3/2\beta^2+\alpha^2 + 2\alpha\beta + \beta^2 - 2\alpha - 2\beta + 1:

Subject to:

0≤αα≤1/20≤ββ≤1/2\begin{align*} 0&\leq\alpha\\ \alpha&\leq 1/2\\ 0&\leq\beta\\ \beta&\leq1/2 \end{align*}

A plot of C(α,β)C(\alpha,\beta) is shown in Figure 4.

A 2 dimensional heatmap.

Figure 4:The plot of (α,β)(\alpha, \beta).

The minimal point looks to be near the right boundary of the square, although it is unclear from the plot whether it is on the boundary or not. We first look for a point inside the square where both partial derivatives are zero, as described in Minimising a convex function over a rectangle. Differentiating CC term by term:

∂C∂α=3α2+2α+2β−2=3α2−2(1−α−β)\frac{\partial C}{\partial \alpha} = 3\alpha^2 + 2\alpha + 2\beta - 2 = 3\alpha^2 - 2(1-\alpha-\beta)
∂C∂β=3β+2α+2β−2=3β−2(1−α−β)\frac{\partial C}{\partial \beta} = 3\beta + 2\alpha + 2\beta - 2 = 3\beta - 2(1-\alpha-\beta)

Setting both of these equal to zero:

3α2−2(1−α−β)=0and3β−2(1−α−β)=03\alpha^2 - 2(1-\alpha-\beta) = 0 \qquad\text{and}\qquad 3\beta - 2(1-\alpha-\beta) = 0

The second equation is linear in β\beta, which gives:

β=2(1−α)5\beta=\frac{2(1-\alpha)}{5}

Substituting this in to the first equation gives:

3α2−6/5(1−α)=03\alpha^2-6/5(1-\alpha)=0

which has solutions:

{−15−115,  115−15}\left\{- \frac{1}{5} - \frac{\sqrt{11}}{5}, \; \frac{\sqrt{11}}{5} - \frac{1}{5}\right\}

Only one of those is positive, substituting it in to (14) gives:

β=1225−21125\beta=\frac{12}{25} - \frac{2 \sqrt{11}}{25}

This point, approximately (0.463,0.215)(0.463, 0.215), lies inside the square. The function CC is convex on the square: its matrix of second derivatives,

(6α+2225),\begin{pmatrix} 6\alpha + 2 & 2\\ 2 & 5 \end{pmatrix},

has a positive top left entry and a positive determinant, 30α+630\alpha + 6, for all α≥0\alpha \geq 0. Thus this point is the minimum and there is no need to check the boundary. The optimal flow is:

f∗=(115−15,  1225−21125)f^* = \left(\frac{\sqrt{11}}{5} - \frac{1}{5}, \; \frac{12}{25} - \frac{2 \sqrt{11}}{25}\right)

If we take a closer look at f∗f^* in our example, we see that traffic from the first commodity travels across two paths: (s1,t)(s_1, t) and (s1,a,t)(s_1, a, t). The cost along the first path is given by:

Cs1,t(f∗)=1225−21125≈0.2146C_{s_1, t}(f^*)=\frac{12}{25} - \frac{2 \sqrt{11}}{25}\approx 0.2146

The cost along the second path is given by:

Cs1,a,t(f∗)=1825−31125≈0.3220C_{s_1, a, t}(f^*)=\frac{18}{25} - \frac{3 \sqrt{11}}{25}\approx 0.3220

Thus traffic going along the second path is experiencing a higher cost. In practice, they would deviate some of their traffic from the second path to the first.

This leads to the definition of a Nash flow.

Definition: Nash Flow

For a routing game (G,r,c)(G,r,c) a flow f~\tilde f is called a Nash flow if and only if for every commodity ii and any two paths P1,P2∈PiP_1,P_2\in\mathcal{P}_i such that fP1>0f_{P_1}>0 then:

cP1(f)≤cP2(f)c_{P_1}(f)\leq c_{P_2}(f)

A Nash flow ensures that all used paths have minimal costs.

Example: Nash Flow for Delivery companies game

For Figure 3 if we assume that both commodities use all paths available to them:

α2=1−α−β3β2=1−α−β\begin{aligned} \alpha^2&=1-\alpha-\beta\\ \frac{3\beta}{2}&=1-\alpha-\beta \end{aligned}

Solving this gives: β=25(1−α)\beta=\frac{2}{5}(1-\alpha) ⇒\Rightarrow x2+35x−35x^{2} + \frac{3}{5} x - \frac{3}{5} this gives

{−310−6910,−310+6910}\left\{- \frac{3}{10} - \frac{\sqrt{69}}{10}, - \frac{3}{10} + \frac{\sqrt{69}}{10}\right\}

Neither of these two values are within our region thus there is no Nash flow where all paths are used.

Let us assume that α=1/2\alpha=1/2 (i.e. commodity 1 does not use Ps1,a,tP_{s_1, a, t}). Assuming that the second commodity uses both available paths we have:

32β=12−β⇒β=15\frac{3}{2}\beta=\frac{1}{2}-\beta\Rightarrow\beta=\frac{1}{5}

Thus we have f~=(1/2,1/5)\tilde f=(1/2,1/5) which gives a cost of C(f~)=11/40C(\tilde f)=11/40 which is higher than the optimal cost!

What if we had assumed that β=1/2\beta=1/2?

This would have given α2=1/2−α\alpha^2=1/2-\alpha which has solutions:

{−12+32,−32−12}\left\{- \frac{1}{2} + \frac{\sqrt{3}}{2}, - \frac{\sqrt{3}}{2} - \frac{1}{2}\right\}

Taking the first value for α\alpha which does lie in the feasible region. The cost of the path Ps2,a,tP_{s_2, a, t} is then approximately 0.134 however the cost of the path Ps2,tP_{s_2, t} is approximately 0.75 thus the second commodity should deviate. We can carry out these same checks with all other possibilities to verify that f~=(1/2,1/5)\tilde f=(1/2,1/5) is a Nash flow.

Definition: Potential Function

Given a routing game (G,r,c)(G,r,c) we define the potential function of a flow as:

Φ(f)=∑e∈E∫0fece(x)dx\Phi(f)=\sum_{e\in E}\int_0^{f_e}c_e(x)dx

Example: Potential Function for the delivery company game

The potential function for Figure 3 is given by:

Φ((α,β))=∫0αx2dx+∫01−α−βxdx+∫0β3/2xdx=α33+3β24+(1−α−β)22\begin{align*} \Phi((\alpha,\beta))&=\int_0^{\alpha}x^2dx + \int_0^{1-\alpha - \beta}xdx + \int_0^{\beta}3/2xdx\\ &=\frac{\alpha^3}{3}+\frac{3\beta^2}{4}+\frac{(1-\alpha-\beta)^2}{2} \end{align*}

Theorem: Nash Flow minimises the potential function

A feasible flow f~\tilde f is a Nash flow for the routing game (G,r,c)(G,r,c) if and only if it is a minima for Φ(f)\Phi(f).

We state this result without proof. The key observation is that differentiating Φ\Phi with respect to the amount of flow moved from one path to another gives the difference between the costs of the two paths. Thus the checks of Minimising a convex function over a rectangle become: two used paths have equal cost, and a path that carries all of a commodity’s traffic is no more expensive than the alternative. This is exactly the definition of a Nash flow.

Definition: Marginal Cost

If cc is a differentiable cost function then we define the marginal cost function c∗c^* as:

c∗=ddx(xc(x))c^* = \frac{d}{dx}\left(x c(x)\right)

Example: The marginal costs for the delivery company game

The marginal costs for Figure 3 are given by:

cs1,t∗(x)=3x2,cs2,t(x)=3x,ca,t(x)=2x,cs1,a(x)=cs2,a=0c^*_{s_1, t}(x)=3x^2, c_{s_2, t}(x)=3x, c_{a, t}(x)=2x, c_{s_1, a}(x)=c_{s_2, a}=0

The corresponding routing game (G,r,c∗)(G, r, c^*) is shown in Figure 5.

A routing game with 2 sources and 1 sink

Figure 5:The routes available to QuickShip and TurboExpress with marginal costs instead of costs.

Theorem: Optimal Flow is a Nash Flow for Marginal Costs

A feasible flow f∗f^* is an optimal flow for (G,r,c)(G,r,c) if and only if f∗f^* is a Nash flow for (G,r,c∗)(G,r,c^*).

We state this result without proof. It follows on comparing the optimality conditions for the two problems: the optimal flow minimises the total cost C(f)=∑efece(fe)C(f) = \sum_e f_e c_e(f_e), whose first-order conditions equate the marginal costs ce∗=ddx(xce(x))c^*_e = \tfrac{d}{dx}(x c_e(x)) across used paths, and these are exactly the equal-cost conditions for a Nash flow of the game with costs c∗c^*.

Exercises

Programming

Scipy has functionality for optimising function within certain boundaries, thanks to Theorem: Nash Flow minimises the potential function this can be used to find not only optimal flows but also Nash flows.

In Appendix: Karush-Kuhn-Tucker Conditions is an example showing how to use Scipy to optimise a function. Here is another one:

     message: Optimization terminated successfully
     success: True
      status: 0
         fun: 0.11666666666666675
           x: [ 5.000e-01  2.000e-01]
         nit: 4
         jac: [-5.000e-02 -9.313e-10]
        nfev: 12
        njev: 4
 multipliers: [ 0.000e+00  0.000e+00  5.000e-02  0.000e+00]

Notable Research

The original paper introducing the notion of Nash flows is Wardrop, 1952. An important phenomenon in this field is Braess’s Paradox, first described in Braess, 1968, which shows that adding capacity to a network can paradoxically increase overall congestion. This effect is not purely theoretical and has been observed in real-world settings Steinberg & Zangwill, 1983Youn et al., 2008.

The inefficiencies that arise in congestion networks due to self-interested behaviour have led to the concept of the Price of Anarchy, defined as C(f~)/C(f∗)C(\tilde f)/C(f^*). This concept was introduced in Roughgarden & Tardos, 2002. Various applications have been explored, including Knight & Harper, 2013, which studied the inefficiencies caused by patients selecting hospitals based on individual preferences.

Conclusion

Table 1 summarises the key concepts.

Table 1:Summary of routing games

ConceptDefinition
Feasible FlowAny flow satisfying demand and non-negativity constraints
Optimal Flow (f∗f^*)Flow minimizing the total system cost $C(f)$
Nash Flow (f~\tilde f)Flow where no player can reduce their cost by unilaterally switching routes
Potential FunctionΦ(f)=∑e∈E∫0fece(x)dx\Phi(f)=\sum_{e\in E}\int_0^{f_e} c_e(x) dx
Marginal Costc∗(x)=ddx(xc(x))c^*(x) = \frac{d}{dx}(x c(x))

Solutions

References
  1. Wardrop, J. G. (1952). Some theoretical aspects of road traffic research. Proceedings of the Institution of Civil Engineers, 1(5), 767–768.
  2. Braess, D. (1968). Über ein Paradoxon aus der Verkehrsplanung. Unternehmensforschung, 12, 258–268.
  3. Steinberg, R., & Zangwill, W. I. (1983). The prevalence of Braess’ paradox. Transportation Science, 17(3), 301–318.
  4. Youn, H., Gastner, M. T., & Jeong, H. (2008). Price of anarchy in transportation networks: efficiency and optimality control. Physical Review Letters, 101(12), 128701.
  5. Roughgarden, T., & Tardos, É. (2002). How bad is selfish routing? Journal of the ACM (JACM), 49(2), 236–259.
  6. Knight, V. A., & Harper, P. R. (2013). Selfish routing in public services. European Journal of Operational Research, 230(1), 122–132.