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.

Economics

3 Optimal Flows

Authors
Affiliations
New York University
National Graduate Institute for Policy Studies (GRIPS)

Up until now we have analyzed problems where network structure is either fixed or generated by some specified random process. In this chapter, we investigate networks where connections are determined endogenously via equilibrium or optimality conditions. In the process, we cover some of the most powerful methods available for solving optimization problems in networks and beyond, with applications ranging from traditional graph and network problems, such as trade, matching, and communication, through to machine learning, econometrics and finance.

3.1Shortest Paths

As a preliminary step, we study the shortest path problem—a topic that has applications in production, network design, artificial intelligence, transportation and many other fields. The solution method we adopt also happens to be one of the clearest illustrations of Bellman’s principle of optimality, which is one of the cornerstones of optimization theory and modern economic analysis.

3.1.1Definition and Examples

We start proceedings by introducing simple examples. (In the next section we will formalize the problem and consider solution methods.)

3.1.1.1Set Up

Consider a firm that wishes to ship a container from AA to GG at minimum cost, where AA and GG are vertices of the weighted digraph G\gG shown in Figure 3.1. Arrows (edges) indicate paths that can be used for freight, while weights indicate costs of traversing them. In this context, the weight function is also called the cost function, and we denote it by cc. For example, c(A,B)c(A, B) is the cost of traveling from vertex AA to vertex BB.

Since this graph is small, we can find the minimum cost path visually. A quick scan shows that the minimum attainable cost is 8. Two paths realize this cost: (A,C,F,G)(A, C, F, G) and (A,D,F,G)(A, D, F, G), as shown in Figure 3.2 and Figure 3.3, respectively.

Graph for the shortest path problem

Figure 3.1:Graph for the shortest path problem

Solution 1

Figure 3.2:Solution 1

Solution 2

Figure 3.3:Solution 2

3.1.1.2A Recursive View

Let’s now consider a systematic solution that can be applied to larger graphs. Let q∗(x)q^*(x) denote the minimum cost-to-go from vertex xx. That is, q∗(x)q^*(x) is the total cost of traveling from xx to GG if we take the best route. Its values are shown at each vertex in Figure 3.4. We can represent q∗q^* in vector form via

(q∗(A),q∗(B),q∗(C),q∗(D),q∗(E),q∗(F),q∗(G))=(8,10,3,5,4,1,0)∈R7.(q^*(A), q^*(B), q^*(C), q^*(D), q^*(E), q^*(F), q^*(G)) = (8, 10, 3, 5, 4, 1, 0) \in \RR^7.
The cost-to-go function, with q^*(x) indicated by red digits at each x

Figure 3.4:The cost-to-go function, with q∗(x)q^*(x) indicated by red digits at each xx

As is clear from studying Figure 3.4, once q∗q^* is known, the least cost path can be computed as follows: Start at AA and, from then on, at arbitrary vertex xx, move to any yy that solves

min⁡y∈O(x){c(x,y)+q∗(y)}.\min_{y \in \oO(x)} \{ c(x, y) + q^*(y) \}.

Here O(x)={y∈V:(x,y)∈E}\oO(x) = \setntn{y \in V}{(x, y) \in E} is the set of direct successors of xx, as defined in Section 1.4.1, while c(x,y)c(x, y) is the cost of traveling from xx to yy. In other words, to minimize the cost-to-go, we choose the next path to minimize current traveling cost plus cost-to-go from the resulting location.

Thus, if we know q∗(x)q^*(x) at each xx, then finding the best path reduces to the simple two stage optimization problem in (3.2).

But now another problem arises: how to find q∗q^* in more complicated cases, where the graph is large? One approach to this problem is to exploit the fact that

q∗(x)=min⁡y∈O(x){c(x,y)+q∗(y)}q^*(x) = \min_{y \in \oO(x)} \{ c(x, y) + q^*(y) \}

must hold for every vertex xx in the graph apart from GG (where q∗(G)=0q^*(G)=0).

Take the time to convince yourself that, for our example, the function q∗q^* satisfies (3.3). In particular, check that (3.3) holds at each nonterminal xx in Figure 3.4.

We can understand (3.3), which is usually called the Bellman equation, as a restriction on q∗q^* that helps us identify this vector. The main difficulty with our plan is that the Bellman equation is nonlinear in the unknown function q∗q^*. Our strategy will be to convert this nonlinear equation into a fixed point problem, so that fixed point theory can be applied.

We do this in the context of a more general version of the shortest path problem.

3.1.2Bellman’s Method

We consider a generic shortest path problem on a flow network, which consists of a weighted digraph G=(V,E,c)\gG = (V, E, c) with a sink d∈Vd \in V called the destination and a weight function c ⁣:E→(0,∞)c \colon E \to (0, \infty) that associates a positive cost to each edge (x,y)∈E(x,y) \in E. In what follows we take ∣V∣=n|V|=n.

We consider how to find the shortest (i.e., minimum cost) path from xx to dd for every x∈Vx \in V. In doing so we impose the following assumption.

To simplify the arguments below, we consider a second digraph G′=(V,E′)\gG' = (V, E') where VV is unchanged and E′=E∪{(d,d)}E' = E \cup \{(d,d)\}. In other words, E′E' extends EE by adding a self-loop at dd. We also extend cc to this self-loop by setting c(d,d)=0c(d, d) = 0. This just means that “terminating at dd” is the same as “staying at dd,” since no more cost accrues after arrival at the destination. Figure 3.5 illustrates in the context of the previous example.

Addition of a self loop to the destination

Figure 3.5:Addition of a self loop to the destination

We will use the intuition from the previous section, based around the Bellman equation, to construct a solution method.

3.1.2.1Policies

Instead of optimal paths, it turns out to be more convenient to aim for optimal policies. In general, a policy is a specification of how to act in every state. In the present setting, a policy is a map σ ⁣:V→V\sigma \colon V \to V with σ(x)=y\sigma(x) = y understood as meaning “when at vertex xx, go to yy.” A policy is called feasible if σ(x)∈O(x)\sigma(x) \in \oO(x) for all x∈Vx \in V.

For any feasible policy σ\sigma and x∈Vx \in V, the trajectory of xx under σ\sigma is the path from xx to the destination indicated by the feasible policy. In other words, it is the sequence (p0,p1,p2,…)(p_0, p_1, p_2, \ldots) defined by p0=xp_0 = x and pi=σ(pi−1)p_i = \sigma(p_{i-1}) for all i∈Ni \in \NN. It can also be expressed as (σi(x)):=(σi(x))i⩾0(\sigma^i(x)) := (\sigma^i(x))_{i \geq 0}, where σi\sigma^i is the ii-th composition of σ\sigma with itself.

Let Σ\Sigma be the set of all feasible policies. In view of Exercise 3.1.1, policies in Σ\Sigma have the property that every trajectory they generate reaches dd in nn steps and stays there. In other words,

σi(x)=d for all i⩾n and all x∈V.\sigma^i(x) = d \text{ for all } i \geq n \text{ and all } x \in V.

Given q∈R+Vq \in \RR^V_+, we call σ∈Σ\sigma \in \Sigma qq-greedy if

σ(x)∈argmin⁡y∈O(x){c(x,y)+q(y)}for all x∈V.\sigma(x) \in \argmin_{y \in \oO(x)} \{c(x, y) + q(y)\} \quad \text{for all } x \in V.

In essence, a greedy policy treats qq as the minimum cost-to-go function and picks out an optimal path under that assumption.

Using our new terminology, we can rephrase the discussion in Section 3.1.1.2 as follows: the shortest path problem can be solved by finding the true minimum cost-to-go function q∗q^* and then following a q∗q^*-greedy policy. In the remainder of this section, we prove this claim more carefully.

3.1.2.2Cost of Policies

We need to be able to assess the cost of any given policy. To this end, for each x∈Vx \in V and σ∈Σ\sigma \in \Sigma, let qσ(x)q_\sigma(x) denote the cost of following σ\sigma from xx. That is,

qσ(x)=∑i=0∞c(σi(x),σi+1(x))=∑i=0n−1c(σi(x),σi+1(x)).q_\sigma(x) = \sum_{i=0}^\infty c(\sigma^i(x), \sigma^{i+1}(x)) = \sum_{i=0}^{n-1} c(\sigma^i(x), \sigma^{i+1}(x)).

This second equality holds because σi(x)=d\sigma^i(x) = d for all i⩾ni \geq n and c(d,d)=0c(d, d) =0. The function qσ∈R+Vq_\sigma \in \RR^V_+ is called the cost-to-go under σ\sigma.

It will be helpful in what follows to design an operator such that qσq_\sigma is a fixed point. For this purpose we let UU be all q∈R+Vq \in \RR_+^V with q(d)=0q(d)=0 and define Tσ ⁣:U→UT_\sigma \colon U \to U by

(Tσ q)(x)=c(x,σ(x))+q(σ(x))(x∈V).(T_\sigma \, q)(x) = c(x, \sigma(x)) + q(\sigma(x)) \qquad (x \in V).

Here and below, with k∈Nk \in \NN, the expression TσkT_\sigma^k indicates the kk-th composition of TσT_\sigma with itself (i.e., TσT_\sigma is applied kk times).

3.1.2.3Optimality

The minimum cost-to-go function q∗q^* is defined by

q∗(x)=min⁡σ∈Σqσ(x)(x∈V).q^*(x) = \min_{\sigma \in \Sigma} q_\sigma(x) \qquad (x \in V).

The definition of q∗q^* matches our intuitive definition from Section 3.1.1.2, in the sense that q∗(x)q^*(x) is, for each x∈Vx \in V, the minimum cost of traveling from xx to the destination dd.

A policy σ∗∈Σ\sigma^* \in \Sigma is called optimal if it attains the minimum in the definition of q∗q^*, so that q∗=qσ∗q^* = q_{\sigma^*} on VV. Our main aims are to

  1. obtain a method for calculating q∗q^* and

  2. prove that a q∗q^*-greedy policy is optimal, as suggested in our informal discussion above.

Regarding the first step, we claim that q∗q^* satisfies the Bellman equation (3.3). To prove this claim we introduce the Bellman operator TT via

(Tq)(x)=min⁡y∈O(x){c(x,y)+q(y)}(x∈V).(Tq)(x) = \min_{y \in \oO(x)} \{ c(x, y) + q(y) \} \qquad (x \in V).

By construction, q∗q^* satisfies the Bellman equation (3.3) if and only if Tq∗=q∗Tq^* = q^*.

The next result is central. It confirms that the minimum cost-to-go function satisfies the Bellman equation and also provides us with a means to compute it: pick any qq in UU and then iterate with TT.

We now have a means to compute the minimum cost-to-go function (by iterating with TT, starting at any q∈Uq \in U) and, in addition, a way to verify the following key result.

3.1.2.4An Implementation in Julia

Let’s use the ideas set out above to solve the original shortest path problem, concerning shipping, which we introduced in Section 3.1.1.1. We will implement in Julia.

Our first step is to set up the cost function, which we store as an array called c. We identify the vertices AA, ..., GG, with the integers 1,…,71, \ldots, 7. We set c[i, j] = Inf when no edge exists from i to j, so that such a path is never chosen when evaluating the Bellman operator, as defined in (3.3). When an edge does exist, we enter the cost shown in Figure 3.1.

c = fill(Inf, (7, 7))

c[1, 2], c[1, 3], c[1, 4] = 1, 5, 3
c[2, 4], c[2, 5] = 9, 6
c[3, 6] = 2
c[4, 6] = 4
c[5, 7] = 4
c[6, 7] = 1
c[7, 7] = 0

Next we define the Bellman operator:

function T(q)
    Tq = similar(q)
    n = length(q)
    for x in 1:n
        Tq[x] = minimum(c[x, :] + q[:]) 
    end
    return Tq
end

Now we arbitrarily set q≡0q \equiv 0, generate the sequence of iterations Tq,T2q,T3qTq, T^2 q, T^3 q and plot them:

using PyPlot
fig, ax = plt.subplots()

n = 7
q = zeros(n)
ax.plot(1:n, q)

for i in 1:3
    new_q = T(q)
    ax.plot(1:n, new_q, "-o", alpha=0.7)
    global q = new_q
end
Shortest path Bellman iteration

Figure 3.6:Shortest path Bellman iteration

After adding some labels, the output looks like the image in Figure 3.6. Notice that, by T3qT^3 q, we have already converged on q∗q^*. You can confirm this by checking that the values of T3qT^3 q line up with those we obtained manually in Figure 3.4.

3.1.3Betweenness Centrality

In Section 1.4.3 we discussed a range of centrality measures for networks, including degree, eigenvector and Katz centrality. Aside from these, there is another well-known centrality measure, called betweenness centrality, that builds on the notion of shortest paths and is particularly popular in analysis of social and peer networks.

Formally, for a given graph G=(V,E)\gG = (V, E), directed or undirected, the betweenness centrality of vertex v∈Vv \in V is

b(v):=∑x,y∈V∖{v}∣S(x,v,y)∣∣S(x,y)∣,b(v) := \sum_{x,y \in V \setminus \{v\} }\frac{ |S(x, v, y)|}{|S(x,y)|},

where S(x,y)S(x,y) is the set of all shortest paths from xx to yy and S(x,v,y)S(x, v, y) is the set of all shortest paths from xx to yy that pass through vv. (As usual, ∣A∣|A| is the cardinality of AA.) Thus, b(v)b(v) is proportional to the probability that, for a randomly selected pair of nodes x,yx, y, a randomly selected shortest path from xx to yy contains vv. Thus, the measure will be high for nodes that “lie between” a large number of node pairs.

For example, Networkx stores a graph called florentine_families_graph that details the marriage relationships between 15 prominent Florentine families during the 15th Century. The data can be accessed via

import networkx as nx
G = nx.florentine_families_graph()    

The network is shown in Figure 3.7, which was created using

nx.draw_networkx(G, [params])    

where [params] stands for parameters listing node size, node color and other features. For this graph, node size and node color are scaled by betweenness centrality, which is calculated via

nx.betweenness_centrality(G)    

Although this graph is very simple, the output helps to illustrate the prominent role of the Medici family, consistent with their great wealth and influence in Florence and beyond.

Betweenness centrality (by color and node size) for Florentine families

Figure 3.7:Betweenness centrality (by color and node size) for Florentine families

3.2Linear Programming and Duality

Our study of shortest paths in Section 3.1 used a relatively specialized optimization method. In this section we cover more general results in optimization and duality, which will then be applied to endogenous networks, optimal transport and optimal flows. Part of the strategy is to take challenging optimization problems and regularize them, often by some form of convexification.

Before diving into theory, we use Section 3.2.1 below to provide motivation via one very specific application. This application involves what is typically called matching in economics and linear assignment in mathematics. We illustrate the key ideas in the context of matching workers to jobs. Later, when we discuss how to solve the problem, we will see the power of linear programming, convexification and duality.

3.2.1Linear Assignment

Behold the town of Springfield. A local employer is shutting down and 40 workers stand idled. Fortunately for these workers, Springfield lies within a political battleground state and, as a result, the mayor receives backing to attract a new employer. She succeeds by promising a certain firm that the 40 workers will be retrained for the new skills they require. For mathematical convenience, let us suppose that there are exactly 40 new positions, each with distinct skill requirements.

The team set up by the mayor records the individual skills of the 40 workers, along with the requirements of the new positions, and estimates the cost c(i,j)c(i, j) of retraining individual ii for position jj. The team’s challenge is to minimize the total cost of retraining. In particular, they wish to solve

min⁡σ∈P∑i=140c(i,σ(i)),\min_{\sigma \in \pP} \sum_{i=1}^{40} c(i, \sigma(i)),

where P\pP is the set of all permutations (i.e., bijective self-maps) on the integers 1,…,401, \ldots, 40. Figure 3.8 illustrates one possible permutation.

One possible assignment (i.e., permutation of \natset{40})

Figure 3.8:One possible assignment (i.e., permutation of [40]\natset{40})

The problem is discrete, so first order conditions are unavailable. Unsure of how to proceed but possessing a powerful computer, the team instructs its workstation to step through all possible permutations and record the one that leads to the lowest total retraining cost. The instruction set is given in Algorithm 2.

After five days of constant execution, the workstation is still running and the mayor grows impatient. The team starts to calculate how long execution will take. The main determinant is the size of the set P\pP. Elementary combinatorics tells us that the number of permutations of a set of size nn is n!n!. Quick calculations show that 40!40! exceeds 8×10478 \times 10^{47}. A helpful team member points out that this is much less than the number of possible AES-256 password keys (approximately 107710^{77}). The mayor is not appeased and demands a runtime estimate.

Further calculations reveal the following: if, for each σ\sigma in P\pP, the workstation can evaluate the cost t(σ)=∑i=140c(i,σ(i))t(\sigma) = \sum_{i=1}^{40} c(i, \sigma(i)) in 10−1010^{-10}-th of a second (which is extremely optimistic), then the total run time would be

10−10×8×1047=8×1037 seconds ≈2.5×1030 years.10^{-10} \times 8 \times 10^{47} = 8 \times 10^{37} \text{ seconds } \approx 2.5 \times 10^{30} \text{ years}.

Another helpful team member provides perspective by noting that the sun will expand into a red giant and vaporize planet Earth in less than 101010^{10} years.

The great computational cost of solving this problem by direct calculations is an example of what is often called the curse of dimensionality. This phrase, coined by Richard Bellman (1920-1984) during his fundamental research into dynamic optimization, refers to the exponential increase in processor cycles needed to solve computational problems to a given level of accuracy as the number of dimensions increases. The matching problem we have just described is high-dimensional because the choice variable σ\sigma, a permutation in P\pP, is naturally associated with the vector (σ(1),…,σ(40))(\sigma(1), \ldots, \sigma(40)). This, in turn, is a point in 40-dimensional vector space.[1]

Fortunately, clever algorithms for this matching problem have been found and, for problems such as this one, useful approximations to the optimal allocation can be calculated relatively quickly. For example, Dantzig (1951) showed how such problems can be cast as a linear program, which we discuss below. Further progress has been made in recent years by adding regularization terms to the optimization problem that admit derivative-based methods.

In the sections that follow, we place matching problems in a more general setting and show how they can be solved efficiently. Our first step is to review the basics of linear programming.

3.2.2Linear Programming

A linear program is an optimization problem with a linear objective function and linear constraints. If your prior belief is that all interesting problems are nonlinear, then let us reassure you that linear programming is applicable to a vast array of interesting applications. One of these is, somewhat surprisingly, the assignment problem in Section 3.2.1, as famously demonstrated by the American mathematician George Bernard Dantzig (1914–2005) in Dantzig (1951). Other applications include optimal flows on networks and optimal transport problems, which in turn have diverse applications in economics, finance, engineering and machine learning.

We explain the key ideas below, beginning with an introduction to linear programming.

3.2.2.1A Firm Problem

One way to define linear programs is in terms of what open source and commercial solvers for linear programming problems handle. Typically, for these solvers, the problem takes the form

min⁡x∈Rn c⊤x\min_{x \in \RR^n} \, c^\top x
 subject to A1x=b1,  A2x⩽b2, and dℓ⩽x⩽du.\text{ subject to } A_1 x = b_1, \; A_2 x \leq b_2, \text{ and } d_\ell \leq x \leq d_u.

Here each AiA_i is a matrix with nn columns and c,b1,b2,dℓc, b_1, b_2, d_\ell and dud_u are conformable column vectors.

To illustrate, let’s consider a simple example, which concerns a firm that fabricates products labeled 1,…,n1, \ldots, n. To make each product requires machine hours and labor. Product ii requires mim_i machine hours and ℓi\ell_i labor hours per unit of output, as shown in the table below

productmachine hourslabor hoursunit price
1m1m_1ℓ1\ell_1p1p_1
⋮\vdots⋮\vdots⋮\vdots⋮\vdots
nnmnm_nℓn\ell_npnp_n

A total of MM machine hours and LL labor hours are available. Letting qiq_i denote output of product ii, the firm’s problem is

max⁡q1,…,qnπ(q1,…,qn):=∑i=1npiqi−wL−rM\max_{q_1, \ldots, q_n} \pi(q_1, \ldots, q_n) := \sum_{i=1}^n p_i q_i - w L - r M

subject to

∑i=1nmiqi⩽M,∑i=1nℓiqi⩽L and q1,…,qn⩾0.\sum_{i=1}^n m_i q_i \leq M , \quad \sum_{i=1}^n \ell_i q_i \leq L \text{ and } q_1, \ldots, q_n \geq 0.

Here π\pi is profits and ww and rr are the wage rate and rental rate of capital. We are taking these values as fixed, along with LL and MM, so choosing the q∈R+nq \in \RR^n_+ that maximizes profits is the same as choosing the qq that maximizes revenue ∑i=1npiqi\sum_{i=1}^n p_i q_i. This will be our objective in what follows.

(Why are total labor supply and machine hours held fixed here? We might think of this problem as one of designing a daily or weekly production plan, which optimally allocates existing resources, given current prices.)

Figure 3.9 shows an illustration of a simple case with two products. Consistent with Exercise 3.2.3, the feasible set is a polyhedron, shaded in blue. The green lines are contour lines of the revenue function (q1,q2)↦p1q1+p2q2(q_1, q_2) \mapsto p_1 q_1 + p_2 q_2, with p1=3p_1=3 and p2=4p_2=4. By inspecting this problem visually, and recognizing that the contour lines are increasing as we move to the northeast, it is clear that the maximum is obtained at the extreme point indicated in the figure.

Revenue maximizing quantities

Figure 3.9:Revenue maximizing quantities

Maximizing revenue is equivalent to minimizing ∑i(−pi)qi\sum_i (- p_i) q_i, so with c=(−p1,−p2)c = (-p_1, -p_2) we have a linear programming problem to which we can apply a solver.

3.2.2.2A Python Implementation

Let’s look at one option for solving this problem with Python, via SciPy’s open source solver linprog. For the simple two-product firm problem, we ignore the unnecessary equality constraint in (3.9) and set

A2=(m1m2ℓ1ℓ2)andb2=(ML).A_2 = \begin{pmatrix} m_1 & m_2 \\ \ell_1 & \ell_2 \end{pmatrix} \quad \text{and} \quad b_2 = \begin{pmatrix} M \\ L \end{pmatrix}.

The bound 0⩽q0 \leq q is imposed by default so we do not need to specify dℓd_\ell and dud_u.

We apply the numbers in Figure 3.9, so the maximization version of the problem is

max⁡q1,q23q1+4q2    s.t.    q1⩾0,  q2⩾0,    2q1+5q2⩽30 and 4q1+2q2⩽20.\max_{q_1, q_2} 3q_1 + 4 q_2 \; \st \; q_1 \geq 0, \; q_2 \geq 0, \;\; 2q_1 + 5q_2 \leq 30 \text{ and } 4q_1 + 2q_2 \leq 20.

Now we set up primitives and call linprog as follows:

A = ((2, 5),
     (4, 2))
b = (30, 20)
c = (-3, -4)  # minus in order to minimize

from scipy.optimize import linprog
result = linprog(c, A_ub=A, b_ub=b)
print(result.x)    

The output is [2.5, 5.0], indicating that we should set q1=2.5q_1=2.5 and q2=5.0q_2=5.0. The result is obtained via the simplex algorithm, discussed in Section 3.2.2.8.

3.2.2.3A Julia Implementation

When solving linear programs, one option is to use a domain specific modeling language to set out the objective and constraints in the optimization problem. In Python this can be accomplished using the open source libraries such as Pyomo and Google’s OR-Tools. In Julia we can use JuMP.

The following code illustrates the Julia case, using JuMP, applied to the firm problem (3.11).

using JuMP
using GLPK

m = Model()
set_optimizer(m, GLPK.Optimizer)

@variable(m, q1 >= 0)
@variable(m, q2 >= 0)
@constraint(m, 2q1 + 5q2 <= 30)
@constraint(m, 4q1 + 2q2 <= 20)
@objective(m, Max, 3q1 + 4q2)

optimize!(m)    

Notice how the JuMP modeling language allows us to write objectives and constraints as expressions, such as 2q1 + 5q2 <= 30. This brings the code closer to the mathematics and makes it highly readable.

If we now run value.(q1) and value.(q2), we get 2.5 and 5.0, respectively, which are the same as our previous solution.

3.2.2.4Standard Linear Programs

The programming problem in (3.8)–(3.9) is convenient for applications but somewhat cumbersome for theory. A more canonical version of the linear programming problem is

P:=min⁡x∈Rn c⊤x   subject to   Ax=b and x⩾0.P := \min_{x \in \RR^n} \, c^\top x \; \text{ subject to } \; A x = b \text{ and } x \geq 0.

Here xx is interpreted as a column vector in Rn\RR^n, cc is also a column vector in Rn\RR^n, AA is m×nm \times n, and bb is m×1m \times 1. A linear program in the form of (3.12) is said to be in standard equality form. In preparation for our discussion of duality below, we also call (3.12) the primal problem.

Standard equality form is more general than it first appears. In fact the original formulation (3.8)–(3.9) can be manipulated into standard equality form via a sequence of transformations. Hence, when treating theory below, we can specialize to standard equality form without losing generality.

Although we omit full details on the set of necessary transformations (which can be found in Bertsimas & Tsitsiklis (1997) and many other sources), let’s gain some understanding by converting the firm optimization problem into standard equality form. To simplify notation, we address this task when n=3n=3, although the general case is almost identical.

As above, we switch to minimization of a linear constraint by using the fact that maximizing revenue is equivalent to minimizing ∑i(−pi)qi\sum_i (- p_i) q_i. Next, we need to convert the two inequality constraints (3.10) into equality constraints. We do this by introducing slack variables sms_m and sℓs_\ell and rewriting the constraints as

∑i=13miqi+sm=M,∑i=13ℓiqi+sℓ=Landq1,q2,q3,sm,sℓ⩾0.\sum_{i=1}^3 m_i q_i + s_m = M , \quad \sum_{i=1}^3 \ell_i q_i + s_\ell = L \quad \text{and} \quad q_1, q_2, q_3, s_m, s_\ell \geq 0.

Indeed, we can see that requiring ∑i=13miqi+sm=M\sum_{i=1}^3 m_i q_i + s_m = M and sm⩾0s_m \geq 0 is the same as imposing ∑i=13miqi⩽M\sum_{i=1}^3 m_i q_i \leq M, and the same logic extends to the labor constraint.

Setting x:=(q1,q2,q3,sm,sℓ)x := (q_1, q_2, q_3, s_m, s_\ell), we can now express the problem as

min⁡xc⊤xwherec⊤:=(−p1,−p2,−p3,0,0)\min_x c^\top x \quad \text{where} \quad c^\top := (-p_1, -p_2, -p_3, 0, 0)

subject to

(m1m2m310ℓ1ℓ2ℓ301)(q1q2q3smsℓ)=(ML)andx⩾0.\begin{pmatrix} m_1 & m_2 & m_3 & 1 & 0 \\ \ell_1 & \ell_2 & \ell_3 & 0 & 1 \end{pmatrix} \begin{pmatrix} q_1 \\ q_2 \\ q_3 \\ s_m \\ s_\ell \end{pmatrix} = \begin{pmatrix} M \\ L \end{pmatrix} \quad \text{and} \quad x \geq 0.

This is a linear program in standard equality form.

3.2.2.5Duality for Linear Programs

One of the most important facts concerning linear programming is that strong duality always holds. Let us state the key results. The dual problem corresponding to the standard equality form linear program (3.12) is

D=max⁡θ∈Rm b⊤θ   subject to   A⊤θ⩽c.D = \max_{\theta \in \RR^m} \, b^\top \theta \; \text{ subject to } \; A^\top \theta \leq c.

Readers who have covered Section 6.1.7 in the appendix will be able to see the origins of this expression. In particular, by formula (6.19) in the appendix, the dual problem corresponding to the standard equality form linear program (3.12) can be expressed as

D=max⁡θ∈Rmmin⁡x∈E  L(x,θ)   where   L(x,θ):=c⊤x+θ⊤(b−Ax)D = \max_{\theta \in \RR^m} \min_{x \in E} \; L(x, \theta) \; \text{ where } \; L(x, \theta) := c^\top x + \theta^\top (b - A x)

and E=R+nE = \RR^n_+. (We can also treat the inequality x⩾0x \geq 0 via a multiplier but this turns out to be unnecessary.) Now observe that

min⁡x∈E  L(x,θ)=b⊤θ+min⁡x⩾0x⊤(c−A⊤θ)={b⊤θ if A⊤θ⩽c−∞ otherwise .\min_{x \in E} \; L(x, \theta) = b^\top \theta + \min_{x \geq 0} x^\top (c - A^\top \theta) = \begin{cases} b^\top \theta & \text{ if } A^\top \theta \leq c \\ -\infty & \text{ otherwise } \end{cases}.

Since the dual problem is to maximize this expression over θ∈Rn\theta \in \RR^n, we see immediately that a θ\theta violating A⊤θ⩽cA^\top \theta \leq c will never be chosen. Hence the dual to the primal problem (3.12) is (3.13).

3.2.2.6Strong Duality

As shown in Section 6.1.7.1 of the appendix, the inequality D⩽PD \leq P always holds, where PP is the primal value in (3.12). This is called weak duality. If P=DP = D, then strong duality is said to hold. Unlike weak duality, strong duality requires conditions on the primitives.

The next theorem states that, for linear programs, strong duality holds whenever a solution exists. A proof can be obtained either through Dantzig’s simplex method or via Farkas’ Lemma. See, for example, Ch. 4 of Bertsimas & Tsitsiklis (1997) or Ch. 6 of Matousek & Gärtner (2007).

Strong duality of linear programs has many important roles. Some of these are algorithmic: duality can be used to devise efficient solution methods for linear programming problems. Another way that duality matters for economists is that it provides deep links between optimality and competitive equilibria, as we show below.

3.2.2.7Complementary Slackness

We say that x∗⩾0x^* \geq 0 and θ∗∈Rm\theta^* \in \RR^m satisfy the complementary slackness conditions for the linear program (3.12) when

θi∗(bi−∑j=1naijxj∗)=0for all i∈[m]\theta_i^* \left( b_i - \sum_{j=1}^n a_{ij} x^*_j \right) = 0 \quad \text{for all } i \in \natset{m}
xj∗(cj−∑i=1maijθi∗)=0for all j∈[n].x^*_j \left( c_j - \sum_{i=1}^m a_{ij} \theta^*_i \right) = 0 \quad \text{for all } j \in \natset{n}.

While it is possible to derive these expressions from the complementary slackness in the KKT conditions in Section 6.1.7.3, a better approach is to connect them directly to the saddle point condition.

To see how this works, suppose that x∗⩾0x^* \geq 0 is feasible for the primal problem and θ∗∈Rm\theta^* \in \RR^m is feasible for the dual problem. If (x∗,θ∗)(x^*, \theta^*) is a saddle point of LL, then the complementary slackness conditions (3.15)–(3.16) must hold. Indeed, (3.15) is trivial when x∗x^* is feasible, since Ax∗=bAx^* = b. At the same time, (3.16) must be true because violation implies that

xj∗(cj−∑i=1maijθi∗)>0for some j∈[n],x^*_j \left( c_j - \sum_{i=1}^m a_{ij} \theta^*_i \right) > 0 \quad \text{for some } j \in \natset{n},

due to dual feasibility (i.e., A⊤θ∗⩽cA^\top \theta^* \leq c) and x∗⩾0x^* \geq 0. But then (x∗,θ∗)(x^*, \theta^*) is not a saddle point of LL, since changing the jj-th element of x∗x^* to zero strictly reduces the Lagrangian

L(x,θ)=c⊤x+θ⊤(b−Ax)=x⊤(c−A⊤θ)+θ⊤b.L(x, \theta) = c^\top x + \theta^\top (b - A x) = x^\top (c - A^\top \theta) + \theta^\top b .

By sharpening this argument, it is possible to show that, for linear programs, the complementary slackness conditions are exact necessary and sufficient conditions for a saddle point of the Lagrangian. This leads to the next theorem.

Chapter 4 of Bertsimas & Tsitsiklis (1997) provides more discussion and a full proof of Theorem 3.2.2. Below, we illustrate some of the elegant connections between complementary slackness and equilibria in competitive economic environments.

3.2.2.8The Simplex Algorithm

Linear programming is challenging in high-dimensional settings, partly because the linear objective function implies that solutions are not interior. The first efficient solution methods for linear programs appeared in the 1930s and 1940s, starting with the simplex method of Kantorovich and Dantzig. As the simplex method began to prove its worth, linear programming grew into a technique of enormous practical importance. Operations research, communication and production systems began to make heavy use of linear programs.

The simplex algorithm makes use of the following result, which is proved in Theorem 2.7 of Bertsimas & Tsitsiklis (1997).

(An extreme point of a polyhedron was defined in Section 6.1.5.1. The feasible set was shown to be a polyhedron in Exercise 3.2.3.)

The simplex algorithm makes use of Theorem 3.2.3 by walking along edges of the polyhedron that forms the feasible set, from one extreme point to another, seeking at each step a new extreme point (which coincides with a vertex of the polyhedron) that strictly lowers the value of the objective function. Details can be found in Bertsimas & Tsitsiklis (1997) and Matousek & Gärtner (2007).

3.3Optimal Transport

Next we turn to optimal flows across networks. One simple—but computationally nontrivial—example of a network flow problem is the linear assignment problem we analyzed in Section 3.2.1. There, the vertices are either workers or jobs and the edges are assignments, chosen optimally to minimize aggregate cost. More general network flow problems extend these ideas, allowing endogenous formation of networks in more sophisticated settings. The general structure is that vertices are given, while edges and weights are chosen to optimize some criterion. There are natural applications of these ideas in trade, transportation and communication, as well as less obvious applications within economics, finance, statistics and machine learning.

In our study of network flows, we begin with the optimal transport problem, which is the most important special case of the general network flow problem. (In fact, as we show in Section 3.3.4.3, there exists a technique by which the general network flow problem can always be reduced to an optimal transport problem.)

3.3.1The Monge-Kantorovich Problem

Optimal transport is a classic problem dating back to the work of Gaspard Monge (1746–1818), who studied, among many other things, the transport of earth for construction of forts. This simple-sounding problem—how to transport a pile of given shape into a new pile of given shape at minimum cost—can, after normalization, be identified with the problem of least cost transformation of one distribution into another distribution. Figure 3.10 gives a visualization of transforming one distribution into another in one dimension (although the cost function is not specified).

Transforming distribution \phi into distribution \psi

Figure 3.10:Transforming distribution φ\phi into distribution ψ\psi

It turns out that, by varying the notion of cost, this transportation problem provides a highly flexible method for comparing the distance between two distributions, with the essential idea being that distributions are regarded as “close” if one can be transformed into the other at low cost. The resulting distance metric finds wide-ranging and important applications in statistics, machine learning and various branches of applied mathematics.[2]

In economics, optimal transport has important applications in transportation and trade networks, as well as in matching problems, econometrics, finance and so on (see, e.g., Galichon (2018)). As such, it is not surprising that economists have contributed a great deal to the optimal transport problem, with deep and fundamental work being accomplished by the great Russian mathematical economist Leonid Kantorovich (1912–1986), as well as the Dutch economist Tjalling Koopmans (1910–1985), who shared the Nobel Prize with Kantorovich in 1975 for their work on linear programming and optimal transport.[3]

We start our discussion with a straightforward presentation of the mathematics. Then, in Section 3.3.3, we will connect the mathematics to economic problems, and show the deep connections between transport, duality, complementary slackness and competitive equilibria.

3.3.1.1Monge’s Formulation

We start with the classical problem of Monge, which is simple to explain. We take as given two finite sets X\Xsf and Y\Ysf, paired with distributions φ∈D(X)\phi \in \dD(\Xsf) and ψ∈D(Y)\psi \in \dD(\Ysf). Elements of X\Xsf and Y\Ysf are called locations. To avoid tedious side cases, we assume throughout that φ\phi and ψ\psi are strictly positive on their domains. In addition, we are supplied with a cost function c ⁣:X×Y→R+c \colon \Xsf \times \Ysf \to \RR_+. Our goal is to “transport” φ\phi into ψ\psi at minimum cost. That is, we seek to solve

min⁡T∑xc(x,T(x))\min_T \sum_x c(x, T(x))

over the set of all maps TT from X\Xsf onto Y\Ysf satisfying

∑xφ(x)1{T(x)=y}=ψ(y)for all y∈Y.\sum_x \phi(x) \1\{T(x) = y\} = \psi(y) \quad \text{for all } y \in \Ysf.

The constraint says TT must be such that, for each target location yy, the sum of all probability mass sent to yy is equal to the specified quantity ψ(y)\psi(y). The symbol ∑x\sum_x is short for ∑x∈X\sum_{x \in \Xsf}. In this context, TT is often called a Monge map.

The problem is easily illustrated in the current discrete setting. Figure 3.11 gives a visualization when locations are enumerated as X={x1,…,x7}\Xsf = \{x_1, \ldots, x_7\} and Y={y1,y2,y3,y4}\Ysf = \{y_1, y_2, y_3, y_4\}, with both X\Xsf and Y\Ysf being subsets of R2\RR^2. For simplicity, φ(xi)\phi(x_i) is written as φi\phi_i and similarly for ψ(yj)\psi(y_j). Vertex size is proportional to probability mass assigned to the vertex. The edges represent one feasible Monge map.

A Monge map transporting ϕ to ψ

Figure 3.11:A Monge map transporting ϕ to ψ

Discreteness and lack of convexity in the constraint (3.18) imply that the Monge problem is, in general, hard to solve. Truly fundamental progress had to wait until Kantorovich showed how convexification can greatly simplify the problem. The convexification process requires shifting the problem to a higher dimensional space, but the cost of higher dimensions is outweighed by the regularization provided by convexity and lack of discreteness. We study the Kantorovich formulation in Section 3.3.1.3.

3.3.1.2Assignment as Optimal Transport

The linear assignment problem studied in Section 3.2.1, with cost c(i,j)c(i, j) of training worker ii for job jj, is a special case of optimal transport. All we have to do is set X=Y=[n]\Xsf = \Ysf = \natset{n} and take φ\phi and ψ\psi to be discrete uniform distributions on [n]\natset{n}.

Since TT must be a bijection on [n]\natset{n}, which is also a permutation of [n]\natset{n}, the objective of the optimal transport problem under the current configuration is

min⁡T∈P∑i=1nc(i,T(i)),\min_{T \in \pP} \sum_{i=1}^n c(i, T(i)),

where P\pP is the set of all permutations of [n]\natset{n}. This is the same optimization problem as the linear assignment problem in (3.7).

3.3.1.3Kantorovich’s Relaxation of the Monge Problem

The basic idea in Kantorovich’s relaxation of the Monge problem is to allow mass located at arbitrary x∈Xx \in \Xsf to be mapped to multiple locations in Y\Ysf, rather than just one. This means that we are no longer seeking a function TT, since, by definition, a function can map a given point to only one image. Instead, we seek a “transport plan” that sends some fraction π(x,y)\pi(x, y) of the mass at xx to yy. The plan is constrained by the requirement that, for all xx and yy,

  1. total probability mass sent to yy is ψ(y)\psi(y) and

  2. total probability mass sent from xx is φ(x)\phi(x).

These constraints on this transport plan mean that it takes the form of a “coupling,” which we define below.

Figure 3.12 illustrates a feasible transport plan in the discrete setting. As with Figure 3.11, φ(xi)\phi(x_i) is written as φi\phi_i and similarly for ψ(yj)\psi(y_j), while vertex size is proportional to probability mass. Unlike the Monge setting of Figure 3.11, the mass at each vertex φi\phi_i can be shared across multiple ψj\psi_j, as long as the constraints are respected.

Kantorovich relaxation of the Monge problem

Figure 3.12:Kantorovich relaxation of the Monge problem

Let’s write the constraints more carefully. We recall that, in probability theory, a coupling is a joint distribution with specific marginals. More precisely, given φ\phi in D(X)\dD(\Xsf) and ψ\psi in D(Y)\dD(\Ysf), a coupling of (φ,ψ)(\phi, \psi) is an element π\pi of D(X×Y)\dD(\Xsf \times \Ysf) with marginals φ\phi and ψ\psi. This restriction on marginals means that

∑yπ(x,y)=φ(x)for all x∈X and\sum_y \pi(x, y) = \phi(x) \quad \text{for all } x \in \Xsf \quad \text{ and}
∑xπ(x,y)=ψ(y)for all y∈Y\sum_x \pi(x, y) = \psi(y) \quad \text{for all } y \in \Ysf

The constraints in (3.20)–(3.21) require that

  1. for any x∈Xx \in \Xsf, the total amount of probability mass flowing out of xx is φ(x)\phi(x) and

  2. for any y∈Yy \in \Ysf, the total amount of probability mass flowing into yy is ψ(y)\psi(y).

In the present setting, a coupling is also called a transport plan.

Let Π(φ,ψ)\Pi(\phi, \psi) be the set of all couplings of ψ\psi and φ\phi. Taking φ,ψ\phi, \psi and the cost function cc as given, the general Monge–Kantorovich problem, also called the optimal transport problem, is to solve

P:=min⁡π⟨c,π⟩Fsubject toπ∈Π(φ,ψ).P := \min_\pi \inner{c, \pi}_F \quad \text{subject to} \quad \pi \in \Pi(\phi, \psi).

where

⟨c,π⟩F:=∑x∑yc(x,y)π(x,y)\inner{c, \pi}_F := \sum_x \sum_y c(x,y) \pi(x, y)

is the Frobenius inner product of cc and π\pi, treated as ∣X∣×∣Y∣|\Xsf| \times |\Ysf| matrices. The sum in ⟨c,π⟩F\inner{c, \pi}_F measures the total cost of transporting φ\phi into ψ\psi under the plan π\pi. There is linearity embedded in this cost formulation, since doubling the amount sent from xx to yy scales the associated cost at rate c(x,y)c(x, y).

We call any π\pi solving (3.22) an optimal plan. Since we are maximizing over a finite set, at least one such plan exists.

3.3.1.4Optimal Transport as a Linear Program

With some relatively simple manipulations, the general optimal transport problem can be mapped into a standard equality form linear program. This provides two significant benefits. First, we can apply duality theory, which yields important insights. Second, on the computational side, we can use linear program solvers to calculate optimal plans.

To map the optimal transport problem into a linear program, we need to convert matrices into vectors. Will use the vec⁡\vecop operator, which takes an arbitrary A∈Mn×mA \in \matset{n}{m} and maps it to a vector in Rnm\RR^{nm} by stacking its columns vertically. For example,

vec⁡(a11a12a21a22)=(a11a21a12a22).\vecop \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} = \begin{pmatrix} a_{11} \\ a_{21} \\ a_{12} \\ a_{22} \end{pmatrix} .

In this section we adopt the notational conventions in Exercise 3.3.5. The objective function ⟨c,π⟩F\inner{c, \pi}_F for the optimal transport problem can now be expressed as vec⁡(c)⊤vec⁡(π)\vecop(c)^\top \vecop(\pi).

To rewrite the constraints in terms of vec⁡(π)\vecop(\pi), we use the Kronecker product, which is denoted by ⊗\otimes and defined as follows. Suppose AA is an m×sm \times s matrix with entries (aij)(a_{ij}) and that BB is an n×tn \times t matrix. The Kronecker product A⊗BA \otimes B of AA and BB is the mn×stmn \times st matrix defined, in block matrix form, by

A⊗B=(a11Ba12B…a1sBa21Ba22B…a2sB⋮am1Bam2B…amsB).A \otimes B = \begin{pmatrix} a_{11}B & a_{12}B & \dots & a_{1s}B \\ a_{21}B & a_{22}B & \dots & a_{2s}B \\ & & \vdots & \\ a_{m1}B & a_{m2}B & \dots & a_{ms}B \\ \end{pmatrix}.

It can be shown that Kronecker products and the vec⁡\vecop operator are connected by the following relationship: for conformable matrices AA, BB and MM, we have

vec⁡(AMB)=(B⊤⊗A)vec⁡(M).\vecop(A M B) = (B^\top \otimes A) \vecop(M).

Using (3.24) and the symbol IkI_k for the k×kk \times k identity matrix, we can rewrite the first constraint in (3.23) as

φ=Inπ1m=vec⁡(Inπ1m)=(1m⊤⊗In)vec⁡(π).\phi = I_n \pi \1_m = \vecop(I_n \pi \1_m ) = (\1_m^\top \otimes I_n) \vecop( \pi ).

Now, using block matrix notation and setting

A:=(1m⊤⊗InIm⊗1n⊤)andb:=(φψ),A := \begin{pmatrix} \1_m^\top \otimes I_n \\ I_m \otimes \1_n^\top \end{pmatrix} \quad \text{and} \quad b := \begin{pmatrix} \phi \\ \psi \end{pmatrix},

the optimal transport problem can be expressed as the standard equality form linear program

min⁡xvec⁡(c)⊤x over x∈R+nm such that Ax=b.\min_x \vecop(c)^\top x \quad \text{ over } x \in \RR^{nm}_+ \text{ such that } A x = b.

Finally, for a given solution xx, the transport plan is recovered by inverting x=vec(π)x = vec(\pi).

3.3.1.5Implementation

Listing 1 is a function that implements the above steps, given flat (one-dimensional) arrays phi and psi representing the distributions over the source and target locations, plus a two-dimensional array c representing transport costs. (The method argument highs-ipm tells linprog to use a particular interior point method, details of which can be found in the linprog documentation. Simplex and other methods give similar results.)

import numpy as np
from scipy.optimize import linprog

def ot_solver(phi, psi, c, method='highs-ipm'):
    """
    Solve the OT problem associated with distributions phi, psi 
    and cost matrix c.

    Parameters
    ----------
    phi : 1-D array
        Distribution over the source locations.
    psi : 1-D array
        Distribution over the target locations.
    c : 2-D array
        Cost matrix.
    """
    n, m = len(phi), len(psi)

    # vectorize c
    c_vec = c.reshape((m * n, 1), order='F') 

    # Construct A and b
    A1 = np.kron(np.ones((1, m)), np.identity(n))
    A2 = np.kron(np.identity(m), np.ones((1, n)))
    A  = np.vstack((A1, A2))
    b  = np.hstack((phi, psi))

    # Call solver
    res = linprog(c_vec, A_eq=A, b_eq=b, method=method)

    # Invert the vec operation to get the solution as a matrix
    pi = res.x.reshape((n, m), order='F')
    return pi

Listing 1:Function to solve a transport problem via linear programming

Notice that in Listing 1, the reshape order is specified to F. This tells NumPy to reshape with Fortran column-major order, which coincides with the definition of the vec⁡\vecop operator described in Section 3.3.1.4. (The Python vectorize operation defaults to row-major order, which concatenates rows rather than stacking columns. In contrast, Julia uses column-major by default.)

Let’s call this function for the very simple problem

φ=(0.50.5),ψ=(10)andc=(1111)\phi = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}, \quad \psi = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \quad \text{and} \quad c = \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}

With these primitives, all mass from φ1\phi_1 and φ2\phi_2 should be sent to ψ1\psi_1. To implement this problem we set

phi = np.array((0.5, 0.5))
psi = np.array((1, 0))
c = np.ones((2, 2))

and then call ot_solver via

ot_solver(phi, psi, c)

The output is as expected:

array([[0.5, 0. ],
       [0.5, 0. ]])    

3.3.1.6Python Optimal Transport

In the case of Python, the steps above have been automated by the Python Optimal Transport package, due to Flamary et al. (2021). For the simple problem from Section 3.3.1.5 we run

import ot
ot.emd(phi, psi, c)   # Use simplex method via the emd solver

The output is again equal to

array([[0.5, 0. ],
       [0.5, 0. ]])    

Figure 3.13 shows an example of an optimal transport problem solved using the Python Optimal Transport package. The interpretation is similar to Figure 3.12, although the number of vertices is larger. In addition, the edges show the optimal transport configuration, in the sense that π∗\pi^*, the optimal transport plan, is treated as the adjacency matrix for the graph. (The figure shows the unweighted graph, with an arrow drawn from φi\phi_i to ψj\psi_j whenever πij∗>0\pi^*_{ij} > 0.) The optimal transport plan is obtained by converting the transport problem into a linear program, as just described, and applying the simplex method. Although there are 32 nodes of each type, the problem is solved by the simplex routine in less than one millisecond.

An optimal transport problem solved by linear programming

Figure 3.13:An optimal transport problem solved by linear programming

3.3.1.7Kantorovich Relaxation and Linear Assignment

We showed in Section 3.3.1.2 that the linear assignment problem studied in Section 3.2.1 is a special case of optimal transport, where φ\phi and ψ\psi become discrete uniform distributions on [n]\natset{n}. Moreover, as we have just seen, Kantorovich’s relaxation method allows us to apply linear programming. This leads to fast solutions.

In the discussion in Section 3.2.1 we used n=40n=40. Let’s start here with n=4n=4, to illustrate the method, and then try with n=40n=40. The matrix c(i,j)c(i,j) of costs, which is the only other primitive, will be generated randomly as an independent array of uniform random variables: Then we apply the Python Optimal Transport (POT) library, as in Section 3.3.1.6.

Here is our set up:

import numpy as np
import ot

n = 4
phi = np.ones(n) 
psi = np.ones(n)

We have broken the rule that φ\phi and ψ\psi should sum to one. This could be fixed easily by using np.ones(n)/n instead of np.ones(n), but the POT library does not care (as long as np.sum(phi) equals np.sum(psi)) and, moreover, the idea of putting unit mass everywhere is natural, since each element of φ\phi represents one worker, and each element of ψ\psi represents one job.

Now we build the cost matrix:

c = np.random.uniform(size=(n, n))

The output is

array([[0.03841, 0.32896, 0.55989, 0.41682],
       [0.91527, 0.24566, 0.26022, 0.64510],
       [0.96275, 0.44089, 0.79274, 0.93065],
       [0.40454, 0.87307, 0.43555, 0.54903]])

(For example, the cost of retraining worker 1 for job 2 is 0.32896.) Finally, we call the solver:

ot.emd(phi, psi, c)    

The output is

array([[1., 0., 0., 0.],
       [0., 0., 1., 0.],
       [0., 1., 0., 0.],
       [0., 0., 0., 1.]])    

This is a permutation matrix, which provides another way to express a permutation of [n]\natset{n}. The first row tells us that worker 1 is assigned to job 1, the second tells us that worker 2 is assigned to job 3, and so on.

If we now set n=40n=40 and rerun the code, the line ot.emd(phi, psi, c), which calls the simplex-based solver, runs in less than 1 millisecond on a mid-range laptop. This is a remarkable improvement on the 2.5×10302.5 \times 10^{30} year estimate for the brute force solver we obtained in Section 3.2.1.

3.3.1.8Tight Relaxation

Notice that the solution we obtained for the linear assignment problem using the simplex method does not split mass, as permitted by the Kantorovich relaxation. For example, we do not send half of a worker to one job and the other half to another. This is convenient but why does it hold?

While we omit the details, the basic idea is that a general Kantorovich transport plan is a bistochastic matrix, and all such matrices can be formed as convex combinations of permutation matrices. (This is called Birkhoff’s Theorem.) In other words, the permutation matrices are extreme points of the set of bistochastic matrices. Moreover, Theorem 3.2.3 tells us that any optimizer of a linear program will be an extreme point—in this case, a permutation matrix.

3.3.2Kantorovich Duality

One of the greatest achievements of Kantorovich was to show that the optimal transport problem can be connected to a dual problem, and how that dual problem can be used to characterize solutions. This work anticipated much of the later development of duality theory for arbitrary linear programs.

Throughout this section, in stating the main results, we use the notation

⟨f,φ⟩=∑xf(x)φ(x)for f∈RX and φ∈D(X).\inner{f, \phi} = \sum_x f(x) \phi(x) \quad \text{for } f \in \RR^\Xsf \text{ and } \phi \in \dD(\Xsf).

This is just the usual inner product, when we think of ff and φ\phi as vectors in R∣X∣\RR^{|\Xsf|}. Also, given a cost function cc on X×Y\Xsf \times \Ysf, let Fc\fF_c be all pairs (w,p)(w, p) in RX×RY\RR^\Xsf \times \RR^\Ysf such that

p(y)⩽c(x,y)+w(x) on X×Y.p(y) \leq c(x, y) + w(x) \text{ on } \Xsf \times \Ysf.

One part of Kantorovich’s duality results runs as follows.

Theorem 3.3.1 can now be understood as a special case of the more general result that strong duality holds for linear programs, which we stated in Theorem 3.2.1. In that spirit, let us verify Theorem 3.3.1 using Theorem 3.2.1, by working with the linear programming formulation of the optimal transport problem provided in Section 3.3.1.4.

To do this, we take that formulation, which is stated in (3.27), and apply the dual formula in (3.13), which yields

D=max⁡θ∈Rn+m(φψ)⊤θ   subject to   (1m⊤⊗InIm⊗1n⊤)⊤θ⩽vec⁡(c).D = \max_{\theta \in \RR^{n+m}} \begin{pmatrix} \phi \\ \psi \end{pmatrix}^\top \theta \; \text{ subject to } \; \begin{pmatrix} \1_m^\top \otimes I_n \\ I_m \otimes \1_n^\top \end{pmatrix}^\top \theta \leq \vecop(c).

If we write the argument θ∈Rn+m\theta \in \RR^{n+m} as (−w,p)(-w, p), so that we now maximize over the two components −w∈Rn-w \in \RR^n and p∈Rmp \in \RR^m, as well as transposing the constraint, we get

max⁡w, p{p⊤ψ−w⊤φ}   subject to   p⊤(Im⊗1n⊤)−w⊤(1m⊤⊗In)⩽vec⁡(c)⊤\max_{w, \, p} \left\{ p^\top \psi - w^\top \phi \right\} \; \text{ subject to } \; p^\top (I_m \otimes \1_n^\top) - w^\top (\1_m^\top \otimes I_n) \leq \vecop(c)^\top

where w∈Rnw \in \RR^n and p∈Rmp \in \RR^m. By using the definition of the Kronecker product and carefully writing out the individual terms, it can be shown that the constraint in this expression is equivalent to requiring that pj−wi⩽cijp_j - w_i \leq c_{ij} for all (i,j)∈[n]×[m](i,j) \in \natset{n} \times \natset{m}. Recalling that X\Xsf has been mapped to [n]\natset{n} and Y\Ysf has been mapped to [m]\natset{m}, this is exactly the same restriction as (3.28).

At this point it is clear that (3.29) is nothing but the dual of the linear program formed from the optimal transport problem. The claims in Theorem 3.3.1 now follow directly from the strong duality of linear programs (Theorem 3.2.1).

3.3.3Optimal Transport and Competitive Equilibria

The other major achievement of Kantorovich in the context of duality theory for optimal transport was to connect optimality of transport plans with the existence of functions w,pw, p from the dual problem such that a version of the complementary slackness conditions holds. Here we present this result, not in the original direct formulation, but rather through the lens of a competitive equilibrium problem. In doing so, we illustrate some of the deep connections between prices, decentralized equilibria and efficient allocations.

3.3.3.1The Advisor’s Problem

We imagine the following scenario. Iron is mined at a finite collection of sites, which we denote by X\Xsf. We identify an element x∈Xx \in \Xsf with a point (a,b)∈R2(a, b) \in \RR^2, which can be understood as the location of the mine in question on a map. At the wish of the queen, who seeks to defend the empire from greedy rivals, this iron is converted to swords by blacksmiths. There are a number of talented blacksmiths in this country, located at sites given by Y\Ysf. As for X\Xsf, each y∈Yy \in \Ysf indicates a point in R2\RR^2. Henceforth, we refer to “mine xx” rather than “the mine at xx” and so on.

Each month, mine xx produces φ(x)\phi(x) ounces of iron ore, while blacksmith yy consumes ψ(y)\psi(y) ounces. We take these quantities as fixed. We assume that total supply equals total demand, so that ∑xφ(x)=∑yψ(y)\sum_x \phi(x) = \sum_y \psi(y). For convenience, we normalize this sum to unity. As a result, φ\phi and ψ\psi are elements of D(X)\dD(\Xsf) and D(Y)\dD(\Ysf) respectively.

The cost of transporting from xx to yy is known and given by c(x,y)c(x,y) per ounce. The king’s chief advisor is tasked with allocating and transporting iron from the mines to the blacksmiths, such that each blacksmith yy receives their desired quantity ψ(y)\psi(y), at minimum cost. A small amount of thought will convince you that the advisor’s problem is a version of the optimal transport problem (3.22). We call this the primal problem in what follows.

Operating in the days before Kantorovich, Dantzig and the electronic computer, the advisor employs a large team of bean counters, instructing them to find the allocation with least cost by trying different combinations. However, after a few days, she realizes the futility of the task. (With infinite divisibility, which corresponds to our mathematical model, the number of allocations is infinite. If we replace infinite divisibility with a finite approximation, the scale can easily be as large as that of the matching problem discussed in Section 3.2.1, with only a moderate number of mines and blacksmiths.)

3.3.3.2The Guild’s Problem

At this point she has another idea. There is a guild of traveling salesmen, who buy goods in one town and sell them in another. She seeks out the guild master and asks him to bid for the project along the following lines. The guild will pay the queen’s treasury w(x)w(x) per ounce for iron ore at mine xx. It will then sell the iron at price p(y)p(y) per ounce to the queen’s representative at blacksmith yy. The difference can be pocketed by the guild, as long as all blacksmiths are provided with their desired quantities. The guild master is asked to propose price functions ww and pp.

The guild master sees at once that pp and ww must satisfy p(y)−w(x)⩽c(x,y)p(y) - w(x) \leq c(x, y) at each x,yx, y, for otherwise the advisor, who is no ones fool, will see immediately that money could be saved by organizing the transportation herself. Given this constraint, the guild master seeks to maximize aggregate profits, which is ∑yp(y)ψ(y)−∑xw(x)φ(x)\sum_y p(y) \psi(y) - \sum_x w(x) \phi(x). At this point it will be clear to you that the problem of the guild master is exactly that of Kantorovich’s dual problem, as given in Theorem 3.3.1.

Since the advisor has given up on her team of bean counters, the guild master employs them, and asks them to produce the optimal pair of prices. The bean counters set to work, trying different combinations of prices that satisfy the constraints. However, without a systematic methodology to follow or fast computers to turn to, their progress is slow. The advisor begins to fear that the coming war will be over before the guild master replies.

3.3.3.3Decentralized Equilibrium

At this point, it occurs to the advisor that yet another approach exists: privatize the mines, abolish the guild, and let the traveling salesmen, mine owners and blacksmiths make individual choices in order to maximize their profits. Purchase and sales prices, as well as quantities transported from each mine to each blacksmith, will be determined by the free market.

Although the advisor predates Kantorovich, she reasons that competition will prevent each salesman from profiteering, while the desire for profits will encourage high levels of transportation and minimal waste. It turns out that this idea works amazingly well, in the sense that we now describe.

For the record, we define a competitive equilibrium for this market as pair of price vectors (w,p)(w, p) in RX×RY\RR^\Xsf \times \RR^\Ysf and a set of quantities π ⁣:X×Y→R+\pi \colon \Xsf \times \Ysf \to \RR_+ such that the following three conditions hold: For all (x,y)(x, y) in X×Y\Xsf \times \Ysf,

∑v∈Yπ(x,v)=φ(x) and ∑u∈Xπ(u,y)=ψ(y)\sum_{v \in \Ysf} \pi(x, v) = \phi(x) \text{ and } \sum_{u \in \Xsf} \pi(u, y) = \psi(y)
p(y)⩽c(x,y)+w(x)p(y) \leq c(x, y) + w(x)
p(y)=c(x,y)+w(x) whenever π(x,y)>0.p(y) = c(x, y) + w(x) \text{ whenever } \pi(x, y) > 0.

Condition (RE) is a resource constraint that builds in the assumption no ore is wasted or disposed. Condition (NA) imposes no arbitrage. If it is violated along route (x,y)(x,y), then another salesman, of which we assume there are many, will be able to gain business without suffering losses by offering a slightly higher purchase prices at xx or a slightly lower sales prices at yy. Finally, condition (IC) is an incentive constraint, which says that, whenever a route is active (in the sense that a nonzero quantity is transported), prices are such that the salesmen do not lose money.

We do not claim that a competitive equilibrium will hold immediately and at every instant in time. However, we reason, as the advisor does, that competitive equilibrium has natural stability properties, as described in the previous paragraph. As such, we predict it as a likely outcome of decentralized trade, provided that private property rights are enforced (e.g., bandits are eliminated from the routes) and noncompetitive behaviors are prevented (e.g., collusion by mine owners is met by suitably painful punishments).

Taking cc, φ\phi and ψ\psi as given, we can state the following key theorem, which states that any competitive equilibrium simultaneously solves both the advisor’s quantity problem and the guild master’s price problem.

To prove the theorem we will use the results from the next exercise.

We will use Exercise 3.3.8 in the following way. Let A=Π(φ,ψ)A = \Pi(\phi, \psi) and B=FcB = \fF_c. Let ff be the value of the primal and gg be the value of the dual. By (3.30), the ordering f(π)⩾g(w,p)f(\pi) \geq g(w, p) holds over all feasible π∈A\pi \in A and (w,p)∈B(w,p) \in B pairs. By strong duality, we also have min⁡π∈Af(π)=max⁡(w,p)∈Bg(w,p)\min_{\pi \in A} f(\pi) = \max_{(w,p) \in B} g(w, p). Hence we need only show that, when (w,p)(w, p) and π\pi form a competitive equilibrium, we have f(π)=g(w,p)f(\pi) = g(w,p).

We also have the following converse:

3.3.4The General Flow Problem

We now describe a general network flow problem that can be used to analyze a large range of applications, from international trade to communication and assignment. This general problem includes optimal transport as a special case.

Once we have introduced the problem, we show two results. First, the problem can easily be formulated as a linear program and solved using standard linear programming methods. Second, even though optimal transport is a strict subset of the general flow problem, every general flow problem can be solved using a combination of optimal transport and shortest path methods.

3.3.4.1Problem Statement

We are interested in flow of a good or service across a network with nn vertices. This network can be understood as a weighted directed graph (V,E,c)(V, E, c). To simplify notation, we label the nodes from 11 to nn and let V=[n]V = \natset{n}. Existence of an edge e=(i,j)∈Ee = (i, j) \in E with weight c(i,j)c(i, j) indicates that the good can be shipped from ii to jj at cost c(i,j)c(i, j). We recall from Section 1.4.1 that I(i)\iI(i) is the set of direct predecessors of vertex ii (all u∈Vu \in V such that (u,i)∈E(u, i) \in E) and O(i)\oO(i) is the set of direct successors (all j∈Vj \in V such that (i,j)∈E(i, j) \in E).

A classic example is the famous Silk Road of antiquity, part of which is illustrated in Figure 3.14. Silk was produced in eastern cities such as Loyang and Changan, and then transported westward to satisfy final demand in Rome, Constantinople and Alexandria. Towns such as Yarkand acted as trade hubs. Rather than covering the whole route, traders typically traveled backward and forward between one pair of hubs, where they knew the language and customs.[4]

The Silk Road (Source: Wikimedia Commons)

Figure 3.14:The Silk Road (Source: Wikimedia Commons)

Returning to the model, we allow for both initial supply of and final demand for the good at every node (although one or both could be zero). Let s(i)s(i) and d(i)d(i) be supply and demand at node ii respectively. Aggregate supply and demand over the network are assumed to be equal, so that

∑i∈Vs(i)=∑i∈Vd(i).\sum_{i \in V} s(i) = \sum_{i \in V} d(i) .

This can be understood as an equilibrium condition: prices have adjusted to equalize initial supply and final demand in aggregate. We assume throughout that the vectors ss and dd are nonnegative with at least one positive element.

Let q(i,j)q(i, j) be the amount of the good shipped from node ii to node jj for all i,j∈Vi, j \in V. The minimum cost network flow problem is to minimize total shipping cost

∑i∈V∑j∈Vc(i,j)q(i,j),\sum_{i \in V} \sum_{j \in V} c(i,j) q(i, j),

subject to the restriction that q⩾0q \geq 0 and

s(i)+∑v∈I(i)q(v,i)=d(i)+∑j∈O(i)q(i,j)for all i∈V.s(i) + \sum_{v \in \iI(i)} q(v, i) = d(i) + \sum_{j \in \oO(i)} q(i, j) \quad \text{for all } i \in V.

The left hand side of (3.34) is total supply to node ii (initial supply plus inflow from other nodes), while the right hand side is total demand (final demand plus outflow to other nodes).

3.3.4.2Optimality

There are several ways to transform the network flow problem into a linear program. We follow the presentation in Bertsimas & Tsitsiklis (1997). We take m=∣E∣m = |E| to be the total number of edges and enumerate them (in any convenient way) as e1,…,eme_1, \ldots, e_m. Let’s say that eke_k leaves node ii if ek=(i,j)e_k = (i, j) for some j∈[n]j \in \natset{n}, and that eke_k enters node ii if ek=(ℓ,i)e_k = (\ell, i) for some ℓ∈[n]\ell \in \natset{n}. Then we define the n×mn \times m node-edge incidence matrix AA by

A=(aik)withaik:={  1if ek leaves i−1if ek enters i  0otherwise.A = (a_{i k}) \quad \text{with} \quad a_{i k} := \begin{cases} \; 1 & \text{if } e_k \text{ leaves } i \\ -1 & \text{if } e_k \text{ enters } i \\ \; 0 & \text{otherwise}. \end{cases}
A simple network flow problem

Figure 3.15:A simple network flow problem

Now, returning to the general case, we rearrange qq and cc into m×1m \times 1 vectors (qk)(q_k) and (ck)(c_k), where qkq_k is the amount shipped along edge kk and ckc_k is the cost. For example, if ek=(i,j)e_k = (i,j), then qk=q(i,j)q_k = q(i, j) and ck=c(i,j)c_k = c(i,j). In addition, we set bb to be the vector in Rn\RR^n with ii-th element s(i)−d(i)s(i) - d(i), which is net exogenous supply at node ii.

Equation (3.36) tells us that the ii-th row of AqAq give us the net outflow from node ii under the transport plan qq. Now, with ⟨c,q⟩:=∑k=1mckqk\inner{c, q} := \sum_{k=1}^m c_k q_k, the minimum cost network flow problem can now be expressed as

min⁡⟨c,q⟩  s.t.  q⩾0   and   Aq=b.\min \inner{c, q} \quad \st \quad q \geq 0 \; \text{ and } \; A q = b.

This is a linear program in standard equality form, to which we can apply any linear programming solver. For Example 3.3.1, we run the following:

A = (( 1,  1,  0,  0),
     (-1,  0,  1,  0),
     ( 0,  0, -1,  1),
     ( 0, -1,  0, -1))

b = (10, 0, 0, -10)
c = (1, 4, 1, 1)

result = linprog(c, A_eq=A, b_eq=b, method='highs-ipm')
print(result.x)

The output is [10. 0. 10. 10.]. Recalling the order of the paths in (3.35), this means that the optimal transport plan is q(1,4)=0q(1,4)=0 and q(1,2)=q(2,3)=q(3,4)=10q(1,2)=q(2,3)=q(3,4)=10, as our intuition suggests.

3.3.4.3Reduction to Optimal Transport

In Exercise 3.3.13, we saw how every optimal transport problem is a special kind of minimum cost network flow problem. There is a sense in which the converse is also true. In particular, we can use optimal transport methods to solve any network flow problem, provided that we first modify the network flow problem via an application of shortest paths.

To explain how this works, we take the abstract network flow problem described in Section 3.3.4.1, on the weighted digraph (V,E,c)(V, E, c), with V=[n]V = \natset{n}, initial supply vector s∈R+ns \in \RR^n_+ and final demand vector d∈R+nd \in \RR^n_+. For the purposes of this section, we agree to call a node ii with s(i)−d(i)>0s(i) - d(i) > 0 a net supplier. A node ii with d(i)−s(i)>0d(i) - s(i) > 0 will be called a net consumer. Nodes with s(i)=d(i)s(i) = d(i) will be called trading stations.

The idea behind the reduction is to treat the net supplier nodes as source locations and the net consumer nodes as target locations in an optimal transport problem. The next step is to compute the shortest path (if there are multiple, pick any one) from each net supplier ii to each net consumer jj. Let ρ(i,j)\rho(i, j) denote this path, represented as a sequence of edges in EE. The cost of traversing ρ(i,j)\rho(i, j) is

c^(i,j):=∑k=1mck1{ek∈ρ(i,j)}.\hat c(i, j) := \sum_{k=1}^m c_k \1\{e_k \in \rho(i, j)\}.

Now the trading stations are eliminated and we solve the optimal transport problem with

After we find the optimal transport plan π\pi, the network minimum cost flow qkq_k along arbitrary edge ek∈Ee_k \in E is recovered by setting

qk=∑i∈X∑j∈Yπ(i,j)1{ek∈ the shortest path from i to j}.q_k = \sum_{i \in \Xsf} \sum_{j \in \Ysf} \pi(i, j) \1\{e_k \in \text{ the shortest path from } i \text{ to } j\}.

Figure 3.16 illustrates the method. Trading station 3 is eliminated after the shortest paths are computed.

Reducing minimum cost optimal flow to optimal transport

Figure 3.16:Reducing minimum cost optimal flow to optimal transport

3.4Chapter Notes

Our treatment of shortest paths can be understood as a simplified version of both the Bellman–Ford algorithm and Dijkstra’s algorithm, which are routinely used to solve large shortest path planning problems. Our approach is intended to emphasize recursive solution methods, which are valuable for analyzing a vast range of economic problems, from intertemporal modeling (see, e.g., Lucas & Stokey (1989) or Ljungqvist & Sargent (2018)) to production chains Kikuchi et al., 2021.

Betweenness centrality has been used to quantify the notion of “too connected to fail,” which gained attention after the 2007–2008 global financial crisis. For example, Huang et al. (2016) examine how betweenness centrality affects systemic risk. Betweenness centrality is used to examine liquidity shocks in the interbank markey by Chiu et al. (2020). Relatedly, Yun et al. (2019) propose a measure of “too central to fail” based on the PageRank algorithm.

For a more in-depth treatment of linear programming, we recommend the excellent textbooks by Bertsimas & Tsitsiklis (1997) and Matousek & Gärtner (2007). For bedtime reading, Cook (2011) provides an entertaining introduction to some of the main ideas and applications to network problems, including a review of computation.

While Section 3.2.1 provided a rather whimsical introduction to matching and assignment problems, such problems have great real world importance. Examples include assigning kidney donors to recipients, mothers to maternity wards, doctors to hospitals, students to schools, delivery drivers to orders and autonomous vehicles to riders.[6] A brief history of assignment, matching problems and combinatorial optimization can be found in Schrijver (2005). Greinecker & Kah (2021) study existence of stable matchings in a setting with many agents.

Villani (2008) and Vershik (2013) provide extensive historical background on the optimal transport problem. Vershik (2013) mentions some of the problems that Kantorovich faced, as a Soviet mathematician working in the time of Stalin and Khrushchev, given that his main duality theorem for optimal transport can be seen as a proof that competitive market equilibria attain the maximal transport plan.

In Section 3.3.2, we mentioned that Kantorovich’s work anticipated much of the later development of duality theory for arbitrary linear programs. In fact, according to Vershik (2013), Kantorovich anticipated much of the general theory of linear programming itself, including providing a version of the simplex algorithm later rediscovered and extended by Dantzig.

Optimal transport has a remarkably wide variety of applications, spread across economics, econometrics, finance, statistics, artificial intelligence, machine learning and other fields. Within economics, Galichon (2018) provides an excellent overview. Charpentier et al. (2019) and Fajgelbaum & Schaal (2020) consider optimal transport in spacial equilibria. Ocampo (2022) applies optimal transport measures to the study of tasks and occupations. Beiglböck et al. (2022) review some of the major milestones of modern finance theory and show their connections via optimal transport. Connections to machine learning are surveyed in Kolouri et al. (2017).

The computational theory of optimal transport is now a major field. A high quality exposition can be found in Peyré & Cuturi (2019). Blanchet et al. (2018) use computational optimal transport to solve for Cournot–Nash equilibria in mean-field type games.

Footnotes
  1. Readers familiar with high performance computing techniques might suggest that the curse of dimensionality is no cause for concern for the matching problem, since the search algorithm be parallelized. Unfortunately, even the best parallelization methods cannot save the workstation from being vaporized by the sun with the calculation incomplete. The best-case scenario is that adding another execution thread doubles effective computations per second and hence halves execution time. However, even with 101010^{10} such threads (an enormous number), the execution time would still be 2.5×10202.5 \times 10^{20} years.

  2. For example, in image processing, two images might be regarded as close if the cost of transforming one into the other by altering individual pixels is small. Even now, in image processing and some branches of machine learning, one of the metrics over the set of probability distributions arising from optimal transport methods is referred to as “earth mover’s distance” in honor of the work of Monge.

  3. The optimal transport problem continues to attract the interest of many brilliant mathematicians and economists, with two recent Fields Medals being awarded for work on optimal transport. The first was awarded to Cedric Villani in 2010, while the second was to Alessio Figalli in 2018. Note that the Field Medal is only awarded every four years (unlike the Nobel Prize, which is annual).

  4. Our use of the Silk Road as an example of a network flow problem is not original. Galichon (2018) provides a highly readable treatment in the context of optimal transport.

  5. If no path exists from ii to jj then we set c^(i,j)=∞\hat c(i, j) = \infty. Such settings can be handled in linear programming solvers by adding capacity constraints. See, for example, Peyré & Cuturi (2019), Section 10.3.

  6. The latter problem occurs in the field of Autonomous Mobility on Demand (AMoD). See, for example, Ascenzi & Palanza (2021) or Simonetto et al. (2019).

References
  1. Dantzig, G. B. (1951). Application of the simplex method to a transportation problem. Activity Analysis and Production and Allocation.
  2. Bertsimas, D., & Tsitsiklis, J. N. (1997). Introduction to linear optimization. Athena Scientific.
  3. Matousek, J., & Gärtner, B. (2007). Understanding and using linear programming. Springer Science & Business Media.
  4. Galichon, A. (2018). Optimal Transport Methods in Economics. Princeton University Press.
  5. Flamary, R., Courty, N., Gramfort, A., Alaya, M. Z., Boisbunon, A., Chambon, S., Chapel, L., Corenflos, A., Fatras, K., Fournier, N., Gautheron, L., Gayraud, N. T. H., Janati, H., Rakotomamonjy, A., Redko, I., Rolet, A., Schutz, A., Seguy, V., Sutherland, D. J., … Vayer, T. (2021). POT: Python Optimal Transport. Journal of Machine Learning Research, 22(78), 1–8. http://jmlr.org/papers/v22/20-451.html
  6. Lucas, R., & Stokey, N. (1989). Recursive methods in dynamic economics. Harvard University Press.
  7. Ljungqvist, L., & Sargent, T. J. (2018). Recursive macroeconomic theory (4th ed.). MIT press.
  8. Kikuchi, T., Nishimura, K., Stachurski, J., & Zhang, J. (2021). Coase meets Bellman: Dynamic programming for production networks. Journal of Economic Theory, 196, 105287.
  9. Huang, W.-Q., Zhuang, X.-T., Yao, S., & Uryasev, S. (2016). A financial network perspective of financial institutions’ systemic risk contributions. Physica A: Statistical Mechanics and Its Applications, 456, 183–196.
  10. Chiu, J., Eisenschmidt, J., & Monnet, C. (2020). Relationships in the interbank market. Review of Economic Dynamics, 35, 170–191.
  11. Yun, T.-S., Jeong, D., & Park, S. (2019). “Too central to fail” systemic risk measure using PageRank algorithm. Journal of Economic Behavior & Organization, 162, 251–272.
  12. Cook, W. J. (2011). In pursuit of the traveling salesman. Princeton University Press.
  13. Schrijver, A. (2005). On the history of combinatorial optimization (till 1960). Handbooks in Operations Research and Management Science, 12, 1–68.
  14. Greinecker, M., & Kah, C. (2021). Pairwise stable matching in large economies. Econometrica, 89(6), 2929–2974.
  15. Villani, C. (2008). Optimal transport: old and new (Vol. 338). Springer Science & Business Media.