Skip to article frontmatterSkip to article content

Routing Games

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 1.

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 1: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 1:

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}. Furthermore we call ff feasible if:

PPifP=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 1:

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}=\bigcup_{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)=PPcP(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)=ePce(x)c_P(x)=\sum_{e\in P}c_e(x). Note that any flow ff induces a flow on edges:

fe=PP if ePfPf_e=\sum_{P\in\mathcal{P}\text{ if }e\in P}f_P

So we can re-write the cost function as:

C(f)=eEce(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 1:

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

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

Figure 2: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αβ+β22α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 ff^* as the solution to the following optimisation problem:

Minimise eEce(fe)fe\sum_{e\in E}c_e(f_e)f_e:

Subject to:

PPifP=rifor all ife=PP if ePfP for all eEfP0\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*}

Example: Optimal Flow for the Delivery Companies Games

In Figure 2 this corresponds to:

Minimise C(α,β)=α3+3/2β2+α2+2αβ+β22α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 3.

A 2 dimensional heatmap.

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

The minimal point looks to be near the right boundary of the square, although it is unclear if it is on the boundary or not. It is in fact not on the boundary taking this fact as an assumption, identity the optimal flow using the Karush-Kuhn-Tucker conditions.

Let us first define the Lagrangian:

L(α,β,λ)=C(α,β)λ1αλ2(α1/2)λ3βλ4β\mathcal{L}(\alpha,\beta,\lambda)=C(\alpha,\beta)-\lambda_1\alpha-\lambda_2(\alpha-1/2)-\lambda_3\beta-\lambda_4\beta

If ff^* is the minimal point then the complementary slackness implies that λi=0\lambda_i=0 for all ii, since this point does not sit on any boundary which would make the corresponding constraint function gi(f)=0g_i(f^*)=0.

Thus:

L(α,β,λ)=C(α,β)\mathcal{L}(\alpha,\beta,\lambda)=C(\alpha,\beta)

We note that the feasiblity constraints all hold for ff^* so we are left to check stationarity:

Lα=Cα=3α22(1αβ)=0\frac{\partial \mathcal{L}}{\partial \alpha}=\frac{\partial C}{\partial \alpha}=3\alpha^2-2(1-\alpha-\beta)=0

and

Lα=Cβ=3β2(1αβ)=0\frac{\partial \mathcal{L}}{\partial \alpha}=\frac{\partial C}{\partial \beta}=3\beta-2(1-\alpha-\beta)=0

which gives:

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

Substituting this in to the first equation gives:

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

which has solutions:

{15115,115+15}\left\{- \frac{1}{5} - \frac{\sqrt{11}}{5}, - \frac{\sqrt{11}}{5} + \frac{1}{5}\right\}

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

β=122521125\beta=\frac{12}{25} - \frac{2 \sqrt{11}}{25}

thus the optimal flow is:

f=(115+15,122521125)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 ff^* 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)=122521125.2146C_{s_1, t}(f^*)=\frac{12}{25} - \frac{2 \sqrt{11}}{25}\approx.2146

The cost along the second path is given by:

Cs1,a,t(f)=182531125.3220C_{s_1, a, t}(f^*)=\frac{18}{25} - \frac{3 \sqrt{11}}{25}\approx .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,P2P_iP_1,P_2\in\mathcal{P}\_i such that f_P1>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 2 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+35x35x^{2} + \frac{3}{5} x - \frac{3}{5} this gives

{3106910,6910+310}\left\{- \frac{3}{10} - \frac{\sqrt{69}}{10}, - \frac{\sqrt{69}}{10} + \frac{3}{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,3212}\left\{- \frac{1}{2} + \frac{\sqrt{3}}{2}, - \frac{\sqrt{3}}{2} - \frac{1}{2}\right\}

Taking the second 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 .134 however the cost of the path Ps2,tP_{s_2, t} is approximately .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)=eE0fece(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 2 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).

Definition: Marginal Cost

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

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

Example: The marginal costs for the delivery company game

The marginal costs for Figure 2 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 4.

A routing game with 2 sources and 1 sink

Figure 4: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 ff^* is an optimal flow for (G,r,c)(G,r,c) if and only if ff^* is a Nash flow for (G,r,c)(G,r,c^*).

Exercises

Exercise: Braess’s Paradox

Determine the optimal and Nash flows for the routing games shown in Figure 5 and Figure 6.

A routing game with two available paths

Figure 5:A routing game forming the basis of Braess’s paradox

A routing game with two vailable paths and a super path between them

Figure 6:A routing game known as Braess’s paradox.

Exercise: Nash flow via potential minimisation

Use Theorem: Nash Flow minimises the potential function and Appendix: Karush-Kuhn-Tucker Conditions to verify that f~=(1/2,1/5)\tilde f=(1/2,1/5) is a Nash flow for Figure 2.

Nash flow from marginal cost formulation

Use Theorem: Optimal Flow is a Nash Flow for Marginal Costs to confirm that

f=(115+15,122521125)f=\left(- \frac{\sqrt{11}}{5} + \frac{1}{5}, \frac{12}{25} - \frac{2 \sqrt{11}}{25}\right)

is a Nash flow for Figure 2.

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:

import numpy as np
import scipy.optimize

def objective(f):
    alpha, beta = f
    return alpha ** 3 / 3 + 3 * beta ** 2 / 4 + (1 - alpha - beta) ** 2 / 2

def g_1(f):
    return f[0]

def g_2(f):
    return f[1]

def g_3(f):
    return 1 / 2 - f[0]

def g_4(f):
    return 1 / 2 - f[1]

constraints = [
    {'type': 'ineq', 'fun': g_1},
    {'type': 'ineq', 'fun': g_2},
    {'type': 'ineq', 'fun': g_3},
    {'type': 'ineq', 'fun': g_4},
]

res = scipy.optimize.minimize(objective, [0, 0], constraints=constraints)
res

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

In this chapter, we introduced routing games, where self-interested agents choose paths through a network to minimize their own travel costs. These individual decisions create congestion effects, making costs interdependent and leading to potentially inefficient outcomes.

We developed a formal framework for routing games, introduced the key concepts of feasible flow, optimal flow, and Nash flow, and explored how potential functions allow us to compute Nash flows via standard optimisation techniques. We also introduced the concept of marginal costs, leading to the result that optimal flows correspond to Nash flows in a modified game with marginal cost functions.

Table 1 summarises the key concepts introduced in this chapter.

Table 1:Summary of routing games

ConceptDefinition
Feasible FlowAny flow satisfying demand and non-negativity constraints
Optimal Flow (ff^*)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)=eE0fece(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))
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.