A Practical Introduction to Dynamic Programming

1. Introduction to Dynamic Programming
Dynamic programming is a powerful technique to solve computational problems, which have a recursive substructure and recurring subproblems. The idea is to solve these recursive subcases and store these solutions in a lookup table. When a solved recursive subcase is encountered, the existing solution is accessed using only a constant number of steps. A solution to the initial instance is constructed from the solutions to the sub-cases, typically in a bottom-up manner. Frequently, the computational problems of interest are optimization problems. Common examples include the Shortest Path Problem, the Rod-Cutting Problem, and the Game of Nim. We provide a practical exposition, introducing some examples amenable to the dynamic programming technique. The goal of this tutorial is that the readers can successfully apply the dynamic programming technique. To that end, this tutorial is not a complete treatment of the subject. In particular, issues of computational complexity are largely not discussed here. Readers interested in more advanced expositions should direct their attention to common algorithm analysis texts, such as Sedgewick and Wayne, or CLRS.

1.1 The Game of Nim
We consider the following two-person game, in which players alternate turns. The game begins with a pile of n (identical) stones. During a player’s turn, they may remove either 1, 2, or 3 stones from the pile. If a player cannot make a move, that player loses. This game is denoted as a (1, 2, 3)-Nim game, in light of the allowed moves of removing 1, 2, or 3 stones. We define the game of Nim more formally.

Definition 1 (Nim). Let a_{1}, a_{2}, \ldots, a_{k} \in \mathbb{Z}^{+} be distinct, and let n \in \mathbb{N}. The game (a_{1}, a_{2}, \ldots, a_{k})-Nim is a two player game, which is initialized with a pile of n stones. Players alternate removing stones from the pile, where the number of stones each player can remove on their turn lies in the set \{a_{1}, a_{2}, \ldots, a_{k}\}. A player loses if they cannot make a move on a given turn.

Remark: In (1, 2, 3)-Nim, a player loses if there are no stones left. However, in (2, 3)-Nim, a player loses if there are fewer than 2 stones left on the pile.

We restrict attention to (1,2,3)-Nim, with the goal of illustrating the dynamic programming technique to determine for which values of i \in [n] Player 1 will win. Here, we assume both agents play optimally; that is, both players seek to win the game and are able to determine the best move to achieve their goal. We denote \ell to indicate a loss, and w to denote a win.

  1. We begin by initializing our lookup table T[0, \ldots, n] to store whether or not Player 1 will win, given a pile with i stones. Clearly, if i = 0, Player 1 loses. So T[0] = \ell. Similarly, if i \in [3], then Player 1 can take all the stones and win in one turn. So T[1] = T[2] = T[3] = w.
  2. Now suppose there are i = 4 stones. No matter how many stones Player 1 takes (whether it be 1, 2, or 3 stones), Player 2 takes the remaining stones. So Player 1 always loses. Thus, we set T[4] := \ell.
  3. Suppose there are i = 5 stones. Suppose Player 1 selects j \in [3] stones. Now Player 2 is the first player in a smaller instance of (1, 2, 3)-Nim with 5-j stones. Here, we begin to see the power of dynamic programming in constructing strategies. We have already computed whether Player 2 will win in the smaller instance of Nim with 5-j stones, and so we can just look up the result in T. Observe that T[5-j] = \ell if and only if j = 1 (i.e., T[4] = \ell). So for i = 5, Player 1 starts by taking a single stone. Then Player 2 will lose. So T[5] = w.
  4. Using similar reasoning as in part (c), we have that T[6] = T[7] = w.
  5. Now what happens if there are i = 8 stones? Suppose that Player 1 takes j \in [3] stones. So Player 2 is the first player in a smaller instance of (1,2,3)-Nim with 8-j stones. For each j \in [3], T[8-j] = w. So Player 2 will always win. Thus, T[8] = \ell.

While we can continue building the lookup table, it may be more insightful to look at the entries already present. Observe that T[0], T[4], and T[8] are the only entries with \ell. This leads to the following observation.

Proposition 1.1. In (1,2,3)-Nim with n stones in the pile, Player 1 has a winning strategy if and only if n is not a multiple of 4.

Proof: The proof is by strong induction on n \in \mathbb{N}. We have the following base cases:

  • Case: Suppose n = 0. Player 1 has no available moves, and so Player 1 loses.
  • Case: Suppose n \in [3]. Player 1 takes all available stones. So Player 2 has no moves and loses. Thus, Player 1 wins.

Now fix k \geq 4, and suppose that the proposition holds for all 0 \leq n \leq k. We prove true for the k+1 case. have the following cases:

  • Case: Suppose that k+1 is not a multiple of 4. By the Division Algorithm, we may write k+1 = 4q + r for some r \in [3]. We show that it is a winning strategy for Player 1 to take r stones on their first turn. After Player 1 takes r stones, Player 2 takes their turn with k+1-r = 4q stones remaining. Observe that Player 2 is the first player in a smaller instance of (1,2,3)-Nim with 4q stones. By the Inductive Hypothesis, Player 2 has no winning strategy, as 4q is a multiple of 4. So Player 1 has a winning strategy, as claimed.
  • Case: Suppose that k+1 is a multiple of 4. For any i \in [3], k+1-i is not a multiple of 4. Suppose Player 1 removes i stones from the pile. Then Player 2 is the first player in a smaller instance of (1,2,3)-Nim with k+1-i stones. As k+1-i \leq k and k+1-i is not a multiple of 4, we have by the inductive hypothesis that Player 2 has a winning strategy. Thus, Player 1 does not have a winning strategy, as claimed.

The result follows by induction. QED.

Remark: When working with instances of Nim, it is helpful to employ dynamic programming with the goal of determining the period of the game, or the length of the pattern of wins and losses that repeat within the lookup table. Once this pattern is ascertained, we may appeal to the pattern to decide in constant time who wins the game. More exposition and generalizations of Nim are discussed in Combinatorial Game Theory, and we direct interested readers to look there for more in-depth exposition on Nim.

1.2 Rod-Cutting Problem

In this section, we examine the Rod-Cutting Problem. Let us consider a motivating example. Suppose we have a rod of length 5, which can be cut into smaller pieces of lengths 1, 2, 3, or 4. These smaller rods can then further be cut into smaller pieces. Now suppose that we can sell rods of length 1 for $1, which we denote p_{1} = 1. Similarly, suppose that the prices for rods of length 2, \ldots, 5 are given by p_{2} = 4, p_{3} = 7, p_{4} = 8, and p_{5} = 9 respectively. We make two key assumptions: we will sell all the smaller rods, regardless of the cuts; and that each cut is free. Under these assumptions, how should the rod be cut to maximize the profit? We note the following cuts and the corresponding profits.

  • If the rod is cut into five pieces of length 1, we stand to make 5 \cdot p_{1} = \$5.
  • If the rod is cut into one piece of length 2 and one piece of length 3, we stand to make p_{2} + p_{3} = 4 + 7 = \$11.
  • If the rod is cut into two pieces of length 2 and one piece of length 1, we stand to make 2 \cdot p_{2} + p_{1} = 8 + 1 = \$9.

Out of the above options, cutting the rod into one piece of length 2 and one rod of length 3 is the most profitable. Of course, there are other possible cuts not listed above, such as cutting the rod into one piece of length 1 and one piece of length 4. The goal is to determine the most profitable cut. The Rod-Cutting Problem is formalized as follows.

Definition 2 (Rod-Cutting Problem).

  • Instance: Let n \in \mathbb{N} be the length of the rod, and let p_{1}, p_{2}, \ldots, p_{n} be non-negative real numbers. Here, p_{i} is the price of a length i rod.
  • Solution: The maximum revenue, which we denote r_{n}, obtained by cutting the rod into smaller pieces of integer lengths and selling the smaller rods.

Intuitively, the maximum revenue is determined by examining the revenues for the subdivisions and taking the largest. Mathematically, this amounts to the following expression:

r_{n} = \max( p_{n}, r_{1} + r_{n-1}, r_{2} + r_{n-2}, \ldots, r_{n-1} + r_{1}).

We begin by working through an example of utilizing dynamic programming to determine the maximum profit.

Example 1. Suppose we have a rod of length 5, with prices p_{1} = 1, p_{2} = 4, p_{3} = 7, p_{4} = 8, p_{5} = 9. We proceed as follows.

  1. Initialize a lookup table T[1, \ldots, 5]. Now for a rod of length 1, there is only one price: p_{1}. So we set T[1] := p_{1}.
  2. Now consider a rod of length 2. There are two options: either don’t cut the rod, or cut the rod into two smaller pieces of length 1. Here, p_{2} = 4 represents the case in which no cuts to a rod of length 2. Now suppose instead we cut the rod up into two smaller pieces each of length 1. We know that the maximum profit for a rod of length 1 is r_{1} = T[1] = 1. So the profit of cutting the rod into two smaller pieces each of length 1 is 2r_{1} = 2. Now r_{2} = \max(p_{2}, 2r_{1}) = 4, so we set T[2] = 4.
  3. Now consider a rod of length 3. Here, we have more options: we can leave the rod untouched, we can divide the rod into smaller pieces of length 1 or length 2; or we can divide the rod into three pieces of length 1. If we do not divide the rod into smaller pieces, the profit is p_{3} = 7. Now suppose we divide the rod up into smaller pieces of length 2 and length 1. We may now keep this configuration, or further divide the rod of length 2 into two rods each of length 1, as discussed in the previous bullet point. Rather than re-solving this problem, we can simply look up the maximum profit for a rod of length 2 in the lookup table. Recall that r_{2} = T[2] = 4 and r_{1} = 1. So the profit from cutting the rod into smaller pieces of length 2 and length 1 is r_{2} + r_{1} = 5. Now r_{3} = \max(p_{3}, r_{2} + r_{1}) = 7, so we set T[3] = 7.
  4. Now consider a rod of length 4. We have the following options for the first cut: leave the rod uncut, in which we stand to make profit p_{4} = 8; cut the rod into smaller pieces of length 1 and length 3; or cut the rod into two smaller rods, each of length 2. Consider the case in which we cut the rod up into smaller pieces of length 1 and length 3. The natural, though inefficient, approach here is to consider all the ways in which we could cut up the rod of length 3. It turns out that we don’t need to do this, as the maximum revenue attainable from a rod of length 3 was found in the previous bullet point. This is the power of dynamic programming: once a solution to a smaller problem is found, we simply look it up rather than re-solving the smaller problem. Similarly, we can look up the maximum profit for a rod of length 2. So given our cases, we have the following possible profits:
    • The uncut rod of length 4 will result in profit p_{4} = 8.
    • The rod cut into pieces of length 3 and length 1 will result in profit r_{3} + r_{1} = T[3] + T[1] = 7 + 1 = 8.
    • The rod cut into two pieces, each of length 2, will result in profit 2r_{2} = 2 \cdot T[2] = 2 \cdot 4 = 8.

    So T[4] = \max(8, 8, 8) = 8.

  5. Finally, consider our original rod of length 5. We have the following possible initial cuts:
    • We can leave the rod uncut, in which case we will make profit p_{5} = 9.
    • We can cut the rod into one piece of length 4 and one piece of length 1. The maximum revenue attainable by cutting up a rod of length 4 was determined already. So we can simply look up this solution in T[4]. Thus, the profit in this case is r_{4} + r_{1} = T[4] + T[1] = 8 + 1 = 9.
    • We can cut up the rod into one piece of length 3 and one piece of length 2. By similar argument as above, we may simply look up the maximum revenues attainable from a rod of length 3 and a rod of length 2. So our profit is r_{3} + r_{2} = T[3] + T[2] = 7 + 4 = 11.

    So r_{5} = \max(9, 9, 11) = 11. Thus, we set T[5] = 11.

We conclude that we stand to make 11 from a rod of length 5.

While the expression

r_{n} = \max( p_{n}, r_{1} + r_{n-1}, r_{2} + r_{n-2}, \ldots, r_{n-1} + r_{1}).

may not seem insightful, it in fact provides an algorithm to compute r_{n}. Example 1 provides a tangible example of this algorithm. The goal now is to generalize the algorithm from Example 1 to work for any rod of positive integer length any list of prices. We proceed as follows.

  1. Initialize the lookup table T[1, \ldots, n], and set T[1] := p_{1}.
  2. We set T[2] := \max(p_{2}, 2r_{1}). Here, p_{2} represents the case in which no cuts to a rod of length 2, and 2r_{1} represents the case in which a rod of length 2 is cut into two rods each of length 1. We note that r_{1} = T[1] = p_{1}.
  3. We set T[3] := \max(p_{3}, r_{1} + r_{2}). Now r_{1} = T[1], and r_{2} = T[2]. We have already solved the rod cutting problem for a length 2 rod, so we simply look up r_{2} in the table T rather than re-solving the problem.
  4. T[4] := \max(p_{4}, r_{1} + r_{3}, 2r_{2}). As we have already computed r_{1}, r_{2}, r_{3}, we may look up their respective values in T rather than re-computing these values.

Continuing in this manner, we compute r_{n}, which is the value in T[n] after the algorithm terminates.

Remark: This algorithm only provides the maximum revenue. It does not tell us how to achieve that result. As an exercise, modify the algorithm to produce an optimal set of rod cuts.

1.3 Longest Common Subsequence Problem
Solutions to both the Rod-Cutting Problem and Nim utilized dynamic programming techniques, where the lookup table was one-dimensional. In this section, we introduce the Longest Common Subsequence Problem, which is also amenable to the dynamic programming technique. However, unlike the Rod-Cutting Problem and Nim, the lookup table for the Longest Common Subsequence Problem is a two-dimensional table rather than a one-dimensional array. The purpose of this section is to illustrate the usage of multidimensional lookup tables in dynamic programming problems. To this end, the Longest Common Subsequence Problem serves as a tangible example. We begin by formalizing the Longest Common Subsequence Problem.

Definition 3 (Subsequence). Let \Sigma be a finite set, which we refer to as an alphabet. Let \omega \in \Sigma^{n}. We say that \psi \in \Sigma^{m} is a subsequence of \omega if there exists a strictly increasing sequence of indices (i_{1}, i_{2}, \ldots, i_{m}) such that \omega_{i_{k}} = \psi_{k} for all k \in [m].

Example 2. Let \omega = (A, B, C, B, D, A, B), and let \psi = (A, C, D, B). Consider the sequence of indices (1, 3, 5, 7). So \psi_{1} = \omega_{1}, \psi_{2} = \omega_{3}, \psi_{3} = \omega_{5}, and \psi_{4} = \omega_{7}. Thus, \psi is a subsequence of \omega.

Definition 4 (Common Subsequence).
Let \Sigma be an alphabet. Let \omega \in \Sigma^{n}, \tau \in \Sigma^{m} be sequences. We say that \psi \in \Sigma^{\ell} is a common subsequence of \omega and \tau if: \psi is a subsequence of \omega, and \psi is a subsequence of \tau. Note that \psi does not have to appear as a subsequence in the same position in both \omega and \tau.

Example 3. Let \omega = (0, 2, 1, 2, 3, 0, 1) and \tau = (2, 3, 1, 0, 2, 0). The sequence (2, 1, 0) is a subsequence of both \omega and \tau. Here, (2, 1, 0) appears in \omega at the indices (2, 3, 6), and (2, 1, 0) appears in \tau at the indices (1, 3, 4).

Definition 5 (Longest Common Subsequence Problem (LCS)).

  • Instance: Let \Sigma be an alphabet, and let \omega \in \Sigma^{n}, \tau \in \Sigma^{m} be sequences.
  • Solution: A sequence \psi that is common to both \omega and \tau; and for any other common subsequence \sigma of \omega and \tau, |\sigma| \leq |\psi|.

The naive approach to solving LCS is enumerating all the possible subsequences of X and Y, and recording the longest. Without loss of generality, suppose that m \leq n. So there are 2^{m} possible index sequences to check, which correspond bijectively to subsequences of Y. So for large sequences, the brute force and ignorance solution is not a practical solution. The dynamic programming approach provides a linear time algorithm instead.

Dynamic programming works best when optimal solutions to subproblems can be used to construct an optimal solution to the original instance. We first show that LCS exhibits this property.

Theorem 1.1. Let \Sigma be an alphabet, and let \omega \in \Sigma^{n}, \tau \in \Sigma^{m} be sequences. Let \psi \in \Sigma^{k} be a longest common subsequence of \omega and \tau. The following hold:

  1. If \omega_{n} = \tau_{m}, then \psi_{k} = \omega_{n} = \tau_{n} and \psi[1, \ldots, k-1] is a longest common subsequence of \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1].
  2. If \omega_{n} \neq \tau_{m} and \psi_{k} \neq \omega_{n}, then \psi is a longest common subsequence of \omega[1, \ldots, n-1] and \tau. Similarly, if \omega_{n} \neq \tau_{m} and \psi_{k} \neq \tau_{m}, then \psi is a longest common subsequence of \omega and \tau[1, \ldots, m-1].

Proof:

  1. Let \Sigma be a common subsequence of \omega and \tau whose last digit does not correspond to the last instance of the character \omega_{n} = \tau_{m} in \omega and \tau. Then \Sigma can be augmented by appending the character \omega_{n} = \tau_{m}. So every longest common subsequence of \omega and \tau has last character \omega_{n} = \tau_{m}.We now show that \psi[1, \ldots, k-1] is a longest common subsequence of \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1]. Observe that \psi[1, \ldots, k-1] is a common subsequence of \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1]. Suppose to the contrary that there exists a longest common subsequence \Sigma of \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1], with |\sigma| > k. Then \Sigma can be augmented with \omega_{n} = \tau_{m} to obtain a common subsequence of \omega and \tau. This contradicts the assumption that any longest common subsequence of \omega and \tau has length k. So \psi[1, \ldots, k-1] is a longest common subsequence of \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1].
  2. Suppose that \omega_{n} \neq \tau_{m}. Now suppose that \psi_{k} \neq \omega_{n}. We show that \psi is a longest common subsequence of \omega[1, \ldots, n-1] and \tau, by contradiction. Let \Sigma be a longest common subsequence of \omega[1, \ldots, n-1] and \tau of length |\sigma| > k. Clearly, \Sigma is a common subsequence of \omega and \tau. Now |\sigma| > |\psi| = k, contradicting the assumption that \psi was a longest common subsequence of \omega and \tau. So \psi is a longest common subsequence of \omega and \tau. Interchanging the roles of \omega and \tau, we obtain that: if \omega_{n} \neq \tau_{m} and \psi_{k} \neq \tau_{m}, then \psi is a longest common subsequence of \omega and \tau[1, \ldots, m-1].

Theorem 1.1 provides the insights necessary for designing a dynamic programming algorithm to solve LCS. Let \omega \in \Sigma^{n}, \tau \in \Sigma^{m} be sequences. If \omega_{n} = \tau_{m}, we record the last character and examine the smaller LCS instance with \omega[1, \ldots, n-1] and \tau[1, \ldots, m-1]. If \omega_{n} \neq \tau_{m}. Otherwise, we need to find the longest common subsequences of \omega and \tau[1, \ldots, m-1]; and \omega[1, \ldots, n] and \tau. These observations yield a natural recurrence to compute the length of the longest common subsequence for a pair of strings:

Ellij

Using the recurrence \ell[i, j] as a template, we design an explicit dynamic programming algorithm. We proceed as follows.

  1. Let \omega \in \Sigma^{n}, \tau \in \Sigma^{m} be our input sequences. We initialize a lookup table T[0, \ldots, n][0, \ldots, m] to be a two-dimensional array, where each cell stores:
    • A natural number corresponding to the length of a longest common subsequence; and
    • A pointer to another cell in the lookup table, which corresponds to the optimal subproblem as specified in Theorem 1.1.

    Now recall that if either of the input sequences have length 0, the length of the longest common subsequence is 0. Therefore, we set T[i][0] = 0 and T[0][j] = 0 for all i \in [n] and all j \in [m]. While our original input sequences may not have length 0, sequences we encounter in subproblems may indeed have length 0.

  2. We now proceed to fill in the remaining cells in a bottom up manner, row-by-row. Each row is filled left-to-right. The cells T[i][j] are filled as follows.
    • Case 1: Suppose \omega_{i} = \tau_{j}. By Theorem 1.1, any longest common subsequence \psi of \omega[1, \ldots, i] and \tau[1, \ldots, j] ends with \omega_{i} = \tau_{j}. Furthermore, \psi[1, \ldots, |\psi|-1] is a longest common subsequence of \omega[1, \ldots, i-1] and \tau[1, \ldots, j-1]. So we take the following actions:
      • Set T[i][j].\text{length} = T[i-1][j-1].\text{length} + 1; and
      • Set T[i][j].\text{subproblem} = T[i-1][j-1].
    • Case 2: Suppose \omega_{i} \neq \tau_{j}. Theorem 1.1 tells us that we need to consider the two subproblems, whose solutions (or at least, their optimal lengths) are stored in: T[i-1][j] and T[i][j-1], respectively. If T[i-1][j].\text{length} \geq T[i][j-1].\text{length}, we set:
      • T[i][j].\text{length} = T[i-1][j].\text{length}
      • T[i][j].\text{subproblem} = T[i-1][j].
    • Otherwise, we set:

      • T[i][j].\text{length} = T[i][j-1].\text{length}
      • T[i][j].\text{subproblem} = T[i][j-1].

    In order to construct a longest common subsequence from the lookup table T, we start at T[n][m] and follow the pointers to the subproblem. Each time some T[i][j] points to T[i-1][j-1] as a subproblem, we prepend the character \omega_{i} = \tau_{j} to the front of the longest common subsequence. We stop once the currently visited cell has no pointer to a subproblem.

    Example 4. Let \omega = (A, B, C) and \tau = (B, A, C, B, D). By inspection, it is easy to see that any longest common subsequence of \omega and \tau has length 2. In particular, (A, B), (B, C), and (A, C) are all longest common subsequences of \omega and \tau. We work through the dynamic programming algorithm to explicitly find a longest common subsequence.

    1. We begin by initializing a 4 \times 6 lookup table T[0, \ldots, 3][0, \ldots, 5], and filling the first row and column with 0‘s. So we have:
      Initial_Lookup
    2. We now fill Row 1.
      • Consider T[1][1]. Observe that \omega_{1} = A and \tau_{1} = A are different. So T[1][1].\text{length} is the maximum of T[1][0].\text{length} = 0 and T[0][1].\text{length} = 0. Thus, T[1][1].\text{length} = 0. By Case 2 of the algorithm, T[1][1].\text{subproblem} points to T[1][0].
      • Consider T[1][2]. Observe that \omega_{1} = \tau_{2}. So T[1][2].\text{length} = T[0][1].\text{length} + 1 = 1, and \newline T[1][2].\text{subproblem} points to T[0][1].
      • Consider T[1][3]. Observe that \omega_{1} = A and \tau_{3} = C are different. So T[1][3].\text{length} is the maximum of T[0][3].\text{length} = 0 and T[1][2].\text{length} = 1. So T[1][3].\text{length} = 1, and T[1][3].\text{subproblem} points to T[1][2].
      • Consider T[1][4]. Observe that \omega_{1} = A and \omega_{4} = B are different. By similar argument as for T[1][1] and T[1][3], we set T[1][4].\text{length} = 1 and T[1][4].\text{subproblem} to point to T[1][3].
      • Consider T[1][5]. By similar argument as for T[1][4], T[1][5].\text{length} = 1 and T[1][5].\text{subproblem} points to T[1][4].

      The updated lookup table is as follows:

      Row1_Lookup
    3. We next fill Rows 2-3, omitting the detailed explanation associated with filling Row 1. The completed lookup table is as follows.
      Final_Lookup
    4. Finally, we construct a longest common subsequence of \omega and \tau from the lookup table. We start at T[3][5] and follow the arrows, prepending the character at the given index every time we see \nwarrow. So we have the sequence:
      T[3][5] \to T[3][4] \to T[3][3] \, (\text{Record C}) \\ \to T[2][2] \to T[2][1] \, (\text{Record B)} \\ \to T[1][0].

      After which, we stop, as T[1][0] does not reference any subproblems. So our longest common subsequence is (B, C), which we identified at the start of this example.

Evolutionary Stable Strategies- Part 2

I. Introduction
In this blog entry, we continue the discussion of the Evolutionary Stable Strategy (ESS) solution concept from my previous blog entry. The definition of the ESS presented in my previous blog entries works well for infinite or sufficiently large populations, but experiences shortcomings for smaller finite populations. We introduce the generalized ESS, which was originally introduced by Mark E. Schaffer in 1988. The generalized ESS accounts for finite populations as well as arbitrary n-player games, rather than the two-player games such as those discussed in my previous blog entry. In finite populations, we see that the intuition for ESS is that no player can unilaterally deviate and improve its relative payoff, which leads to spiteful behavior. For a sufficiently large population, we see that the generalized ESS converges to the Nash equilibrium, in which no player can unilaterally deviate and improve its absolute payoff. The generalized ESS will be illustrated with the Cournot duopoly game, as well as an n-person Tullock contest.

II. Generalized ESS
Let N be the size of the population, and let \Gamma be a C-person game. We denote C as the contest size. Recall the definition of an ESS:

Definition (Evolutionary Stable Strategy): A strategy x \in \Delta is an Evolutionary Stable Strategy if for every strategy y \neq x, there exists an \epsilon_{y} \in (0, 1) such that u[x, (1-\epsilon)x + \epsilon y] > u[y, (1-\epsilon)x + \epsilon y] for every \epsilon \in (0, \epsilon_{y}).

This definition of an ESS holds true when N = \infty and C = 2. Let x be an ESS and y \neq x be an alternative strategy. Suppose the majority of the agents play the strategy x and a small \epsilon \in (0, 1) of the population play y. The expected utility of an ESS player is \pi^{ESS} = (1-\epsilon)u[x, x] + \epsilon u[x, y], while a mutant player has expected utility \pi^{M} = (1-\epsilon)u[y, x] + \epsilon u[y, y]. Following a Darwinian and biological intuition, evolutionary forces select against the strategy with the lower expected payoff.

We now substitute in the expected payoffs for each player. An agent playing the ESS strategy x has a \frac{1}{N-1} chance of being matched up with the mutant, and so has expected payoff \frac{1}{N-1} u[x, y] in that case. So our optimization problem reduces to:

\max_{y} u[y, x] - \frac{1}{N-1} u[x, y]

As N \to \infty, we see that the u[x, y] term disappears, and the mutant player sees to find a best response to x, which is the Nash equilibrium condition for an individual player. So for sufficiently large populations, an ESS converges to a Nash equilibrium. This motivates the study of the ESS solution concept, as it relates to neoclassical Game Theory. Additionally, we see that players seek to maximize their relative payoffs. In small populations, this leads to spiteful behavior, with the intuition that being harmed less than other agents can lead to better survival rates than the other agents. Equivocally, no player can unilaterally deviate and improve its relative payoff.

With all this in mind, we seek to formulate a generalized ESS in the same spirit as the original: a strategy x is a generalized ESS if enough agents adopt it and a minority of agents adopting the mutant strategy y have lower expected utility than agents playing x. We have two conditions: the equilibrium condition and the fitness condition, in which the strategy is resistant to a minority of mutants.

Definition (Generalized ESS): Let N be a population, from which we draw agents to play a symmetric game of contest size C. The strategy x \in \Delta is a Generalized ESS iff:

  1. In a population with only one mutant, the strategy x is a solution for \max_{y} u_{i}(y, x, \ldots, x) - u_{-i}(x, y, x, \ldots, x). That is, we compare the payoff of agent i playing the mutant strategy to an arbitrary agent playing the generalized ESS x, assuming s_{-i} = x.
  2. Suppose there are M > 0 mutants each playing the strategy y. Then there exists an integer 2 \leq Y \leq M such that for every 2 \leq k \leq Y, if exactly k mutants are selected to participate in the game, then each mutant’s expected payoff is less than the expected payoff of the remaining C-k agents who play the strategy x.

Note that we can rewrite u_{-i}(x, y, x, \ldots, x) = \frac{1}{N-1} \sum_{j \neq i} u_{j}(x, y, x, \ldots, x); that is, the average of all the payoffs of each generalized ESS player (which happen to be the same value).

Let’s consider a couple examples.

Example 1: Consider the following game, with population size N = 2. In the previous blog entry, it was shown that B is the ESS for this game. Recall that the previous blog entry used the textbook definition, which only holds in the case of infinite populations. Here, we see that both (A, A) and (B, B) result in both players having the same payoff. We check that no player can unilaterally deviate and improve its relative payoff. If both players use the strategy A, then one player can deviate to B resulting in a payoff of 3 for the player that deviated and a payoff of 0 for the other player. So by deviating from A, a player can improve its relative payoff. It follows that A is not a solution to \max_{y} u_{i}(y, A) - u_{-i}(A, y); and thus, not a Generalized ESS.

Now consider B. If both agents play B and one deviates, the deviating player encounters a payoff of 0. So B is a solution to \max_{y} u_{i}(y, A) - u_{-i}(A, y). Given that there are only two players in this population, the mutant cases have been covered. So B is the unique generalized ESS of this game.

Example1

Example 2: Consider a second game, with population size N = 3. In the previous blog entry, we showed that A is a pure ESS, which considered N = \infty. Under the generalized ESS definition with N = 3, we see that a player can unilaterally deviate to B and improve its relative performance. So A is not a generalized ESS when N = 3. Now consider B. We see that any mixing between A and B results in a higher payoff than purely playing B. So B is not resistant to invasion; and thus, not a generalized ESS. So there are no pure strategies generalized ESS in this game for the population size N = 3. By the analysis of the pure strategies, it is intuitive that no such mixed strategies ESS exists, for we apply the analysis component-wise. Formally, we show this by contradiction. As the ESS is symmetric, each player will use the same mixing ratio of p for strategy A and 1-p for strategy B; and thus, incur the same utility. This yields the expected payoff of 3p + 1(1-p) = 2p + 1 for playing strategy A and 2p + 0(1-p) = 2p for playing strategy B. Setting 2p + 1 = 2p is always false, so the two players will never incur the same utility, which is the contradiction. Thus, no generalized ESS exists for this game given N = 3.

Example2

III. Cournot Duopoly
The Cournot Duopoly is a standard model in neoclassical Game Theory and Industrial Organization. The simplest of these models considers two identical firms, each of whom produce an identical good in quantities q_{1}, q_{2} \in \mathbb{R}_{+} respectively. Let Q = q_{1} + q_{2}. We have an inverse demand function P : \mathbb{R}_{+} \to \mathbb{R}_{+} where P(Q) is the market price with respect to the quantity of the good supplied. Let a \in \mathbb{R}_{++} with a > c and suppose P is given by:

P(Q) = \begin{cases} a - Q & : Q \leq a \\ 0 & : \text{ Otherwise} \end{cases}

Let’s solve for the Nash equilibrium of this game. Each firm seeks to maximize its profit, which is given by \pi_{i}(q_{i}, q_{-i}) = q_{i}P(Q) - cq_{i}. The first order conditions for each player are:

a - 2q_{i} - q_{-i} - c = 0 \implies
q_{i} = \frac{a - q_{-i} - c}{2}

As the two firms are symmetric, there exists a Nash equilibrium in which each firm produces the same quantity of the good. Thus, we set q_{i} = q_{-i} and solve the first order condition:

q_{i} = \frac{a - q_{i} - c}{2} \implies
3q_{i} = a - c \implies
q_{i}^{*} = \frac{a-c}{3}

So the symmetric Nash equilibrium of this game is for each player to produce \frac{a-c}{3} of the good. Observe that both firms are making positive profit, as a > c and \frac{2}{3} \cdot (a-c) < a, firm i can produce q_{i} + \epsilon for a sufficiently small \epsilon and increase its relative profit compared to q_{-i}. However, such a minor increase in production will decrease both firms’ profits. So in this sense, profit maximization and survival are at odds. In fact, the generalized ESS is for each of the two firms to product q_{i}^{*} = \frac{a-c}{2}. So P(Q) = 0. It suffices to show that no firm can unilaterally deviate and improve its relative performance. If one player produces \frac{a-c}{2} - \epsilon for some small \epsilon > 0, then P(Q) > 0 and firm -i has payoff \frac{a-c}{2} \cdot P(Q) > (\frac{a-c}{2} - \epsilon) \cdot P(Q).

So firm i decreases its relative profit by decreasing production. Now suppose firm i produces \frac{a-c}{2} + \epsilon, for some small \epsilon > 0. Then P(Q) < 0 and we have (\frac{a-c}{2} + \epsilon) \cdot P(Q) < \frac{a-c}{2} \cdot P(Q). Thus, no firm can unilaterally deviate and improve its relative profit.

IV. Tullock Contest
A Tullock contest is a generalization of a lottery. In the lottery, each player pays a bid x_{i} upfront for the chance to win some prize of value v \in \mathbb{R}_{+}. The probability of player i winning is given by:

\dfrac{x_{i}}{\sum_{j=1}^{n} x_{j}}

In a Tullock contest, we fix a constant r > 0, and so each player’s bid x_{i} is weighted x_{i}^{r}. This yields the probability of player i winning as:

\dfrac{x_{i}^{r}}{\sum_{j=1}^{n} x_{j}^{r}}

So player i‘s expected profit is:

\dfrac{x_{i}^{r}}{\sum_{j=1}^{n} x_{j}^{r}}v - x_{i}

Let’s first derive the symmetric Nash equilibrium of this game. Each player seeks to maximize its expected profit, which yields the first order conditions:

\dfrac{rx_{i}^{r-1} \cdot \sum_{j=1}^{n} x_{j}^{r} - rx_{i}^{2r-1}}{(\sum_{j=1}^{n} x_{j}^{r})^{2}} v - 1 = 0

In the symmetric equilibrium, each player bids the same amount x_{i}. Substituting this into the first order conditions, we obtain:

\dfrac{ rnx_{i}^{2r-1} - rx_{i}^{2r-1}}{n^{2}x_{i}^{2r}}v = 1 \implies
\dfrac{r(n-1)}{n^{2}}v = x_{i}

So when r \leq \frac{n}{n-1}, x_{i}^{*} = \frac{r(n-1)}{n^{2}}v is the symmetric Nash equilibrium. When r > \frac{n}{n-1}, the strategy x^{*} = \frac{r(n-1)}{n^{2}}v results in players overpaying. When r \leq \frac{n}{n-1}, we see that the (unique pure strategies) symmetric Nash equilibrium is not a generalized ESS. Intuitively, if player i increases its bid slightly from x_{i}^{*}, then i‘s expected payoff increases slightly while the other players’ expected payoffs decrease slightly. This is because the probability of winning shifts slightly in i‘s favor, with respect to the amount of the increase. Formally, we consider the following optimization problem:

\max_{y} u_{1}(y, x^{*}, \ldots, x^{*}) - u_{i}(y, x^{*}, \ldots, x^{*}) = \dfrac{y^{r} - (x^{*})^{r}}{y^{r} + (n-1)(x^{*})^{r}}v - (y - x^{*})

Where x^{*} is the symmetric Nash equilibrium of the Tullock contest. We have the first order condition, which we call (*):

\dfrac{\partial (u_{1}(y, x^{*}, \ldots, x^{*}) - u_{i}(y, x^{*}, \ldots, x^{*}))}{\partial y} = 0

As x^{*} is a Nash equilibrium, we have that when y = x^{*}:

\dfrac{\partial u_{1}(y, x^{*}, \ldots, x^{*})}{\partial y} = 0

We consider:

\dfrac{\partial u_{i}(y, x^{*}, \ldots, x^{*})}{\partial y} = -\dfrac{(x_{i}^{*})^{r} \cdot ry^{r-1}}{(y^{r} +  (n-1)(x_{i}^{*})^{r})^{2}}v

Substituting y = x^{*} to obtain:

\dfrac{\partial u_{i}(y, x^{*}, \ldots, x^{*})}{\partial y} = -\dfrac{r(x_{i}^{*})^{2r - 1}}{(n(x_{i}^{*})^{r})^{2}}v < 0

And so when y = x^{*}, we have:

\dfrac{\partial (u_{1}(y, x^{*}, \ldots, x^{*}) - u_{i}(y, x^{*}, \ldots, x^{*}))}{\partial y} > 0

As x^{*} is an interior point, we conclude that x^{*} does not maximize the relative payoffs. So x^{*} is not a generalized ESS. We now solve for an ESS by considering the first order condition (12):

\dfrac{\partial (u_{1}(y, x, \ldots, x) - u_{i}v)}{\partial y} = \dfrac{n(yx)^{r}}{(y^{r} + (n-1)x^{r})^{2}y}v - 1 = 0

As the ESS is symmetric, we set y = x and solve:

nx^{2r}rv = n^{2}x^{2r+1}v \implies
x = \frac{rv}{n}

So the generalized ESS is x^{*} = \frac{rv}{n}, when r \leq \frac{n}{n-1}.

Evolutionary Stable Strategies- Part 1

I. Introduction
Neoclassical models of Game Theory consider fully rational agents, where each agent is perfectly aware of the other agents, their strategy sets, and the payoffs of each strategy profile. Each player is able to examine all possibilities and select a best option, taking into account the other players. The solution concept in Game Theory is the Nash Equilibrium, which intuitively is an outcome where no individual player can unilaterally deviate and strictly improve its outcome. However, more traditional models of Game Theory only examine the equilibrium outcomes, not the underlying dynamics driving them.

Evolutionary Game Theory seeks to provide a more realistic model of human behavior, while encompassing the notion of Darwinian dynamics or survival of the fittest. It has two key differences which separates it from traditional models of Game Theory. First, Evolutionary Game Theory models the dynamics. Rather than focusing solely on the equilibrium, the focus is shifted towards how such an equilibrium comes about, if one even exists. Realistically, there are always dynamics, even if they are negligible. In this sense, the evolutionary framework captures this realism better than the neoclassical framework. The second key difference is the notion of bounded rationality. In Evolutionary Game Theory, individuals are not perfectly rational. This means that not every agent computes every possible payoff, making the best decision. Non-rational agents may ignore certain players or possibilities, or opt to imitate the majority rather than maximize their payoffs. In many competitive situations, it may not be feasible to compute all possible outcomes even in the case of perfect information. Instead, agents start with initial strategies and adapt. The outcomes of the game reward the winners and punish the losers. Agents slowly adapt new and beneficial strategies, factoring in what actions they think the other players might choose. In this sense, agents are more recognizably human. Furthermore, the evolutionary framework yields similar equilibria in many cases as the neoclassical Game Theory model.

There are several important applications of Evolutionary Game Theory, outside of economics and biology. Sociologists and psychologists find applications in studying the prevalent social customs, both in small groups and large societies. Researchers in artificial intelligence, particularly multiagent systems, use Evolutionary Game Theory to study how repeated local interactions amongst arbitrary subsets of players drive the overall state of the system. Within the context of economic networks, Evolutionary Game Theory proves to be a useful tool in studying local interaction and learning.

This blog entry will introduce the evolutionary framework, as well as explore the solution concept of the Evolutionary Stable Strategy, which is a refinement of the Nash Equilibrium. The goal is to introduce textbook formulations of the Evolutionary Stable Strategy, while the next blog entry will discuss adaptations of this concept that frequently arise in the literature. Some familiarity with the basics of Game Theory is advisable, such as my previous blog entry on the subject.

II. Evolutionary Framework
Recall the definition of a normal form game:

Definition 1 [Normal Form Game]. A normal form game is a three-tuple \Gamma = [N, (S_{i})_{i \in N}, (u_{i})_{i \in N}] where N is the set of players, S_{i} is player i‘s strategy set, and u_{i} : \prod_{i=1}^{n} S_{i} \to \mathbb{R} is player i‘s utility function.

In the neoclassical model, each player in the game is fully rational. Each player selects its strategy simultaneously, and the game is played exactly once. The evolutionary framework, in contrast, has three key assumptions:

  1. There is a large population of non-fully rational agents.
  2. The game is played multiple times. In a given round, each player selects its strategy simultaneously.
  3. Some agents are drawn at random each period to play the game.

The goal of the evolutionary framework is to examine which types of players or strategies survive repeated play, shedding light on which equilibrium is more realistic. Let’s examine a coordination game.

Example 1: Consider the following payoff matrix.

Example1

The two pure strategies Nash equilibria of this game are (A, A) and (B, B)- it is easy to check that no player can unilaterally deviate from one of these strategy profiles and improve its payoff. Furthermore, it is clear that players prefer the equilibrium (A, A) to (B, B). However, which of these equilibria is more realistic?

Let’s now apply the evolutionary framework to the coordination game. Let N be the finite set of players. At each round, two players are selected at random from $N$ to play the coordination game. The players with the highest payoffs are most likely to survive.

If two players both play A, then their preferred Nash equilibrium is achieved. Suppose player i chooses to play B instead, while player -i maintains the strategy A. Then player i has utility 3 while player -i has utility 0. As the game repeats, agents playing the strategy B have a comparative advantage over those playing A. Agents playing the strategy A will eventually die out when faced with agents playing strategy B, and the equilibrium (B, B) will arise even though (A, A) is the preferred equilibrium. This phenomenon is captured by Evolutionary Game Theory with the solution concept known as the Evolutionary Stable Strategy (ESS).

III. Evolutionary Stable Strategy
Recall that a strategy profile is a Nash equilibrium if no player can unilaterally deviate and improve its payoff. The Evolutionary Stable Strategy is intuitively a strategy that, if played by a sufficiently large proportion of the population, is resistant to the adoption of a mutant strategy. Recall from Example 1 in the previous section that players adoption the strategy A in the coordination game ended up dying out if the strategy B was adopted by a fraction of the players. In this sense, the strategy A is not resistant to mutations.

Prior to engaging in the technical details, some motivation is first in order. Evolutionary Game Theory originated from mathematical biology rather than economics. This is a reasonable starting point. Suppose we have a population of small insects. Anytime two insects come across a food source, they compete for it, enabling each insect to lay five eggs. Now suppose a mutation is introduced, allowing mutant insects to grow to a larger size. So now we have small insects and large insects. A large insect is only able to lay three eggs after consuming food, as it requires more energy to maintain its size. When two large insects compete, they are each able to lay three eggs. However, when a large insect and a small insect compete, the large insect is able to consume all the food. Even though the small insects are able to reproduce more efficiently, will they survive in the long run with the mutation introduced? The answer is no. Observe that this is the game from Example 1.

While the notion of mutation has clear roots in biology, it also applies to social situations. Language coordinates communication, and it evolves by sufficiently many individuals adopting new terminology. In a market setting, suppose a producer introduces a new good. The profitability of this good is determined by whether sufficiently many customers purchase it. Here, the adopting customers can be viewed as mutants in the population. Other societal conventions such as etiquette, law, and currency have evolved based on the natural dynamics arising from individual interactions amongst agents. The Evolutionary Stable Strategy seeks to capture conventions that arise from such interactions.

We now formalize the notion of the Evolutionary Stable Strategy. A Darwinian and biological intuition suggests that evolutionary forces will select against the mutant strategy if and only if the incumbent strategy has a higher payoff. This is the fitness condition. Formally, consider a two-player game \Gamma with the mixed strategies set \Delta. Suppose that the incumbent strategy is x \in \Delta and the mutant strategy is y \in \Delta. Let \epsilon \in (0, 1) be the proportion of players that are programmed to play y. So an agent playing strategy a \in \{x, y\} has expected payoff (1-\epsilon)u[a, x] + \epsilon u[a, y], which is the same expected payoff as if the opponent was playing mixed strategies x with probability (1-\epsilon) and y with probability \epsilon. So evolutionary forces favor strategy x if and only if:

u[x, (1-\epsilon)x + \epsilon y] > u[y, (1-\epsilon)x + \epsilon y]

This is precisely the condition for a strategy to be evolutionary stable.

Definition 2 [Evolutionary Stable Strategies]. A strategy x \in \Delta is an Evolutionary Stable Strategy if for every strategy y \neq x, there exists an \epsilon_{y} \in (0, 1) such that u[x, (1-\epsilon)x + \epsilon y] > u[y, (1-\epsilon)x + \epsilon y] for every \epsilon \in (0, \epsilon_{y}).

Intuitively, \epsilon_{y} is the barrier for invasion. If there are not a sufficient number of mutants, then the incumbent agents dominate and the mutants die out. The evolutionary stable strategies can also be characterized as a subset of strict Nash equilibria. Formally, we have the following theorem.

Theorem 1: Let \Delta^{ESS} be the set of evolutionary stable strategies for a two-player game \Gamma, \Delta^{NE} be the set of Nash equilibria for \Gamma, and \beta(x) be the best response correspondence of strategy x. We have:

\Delta^{ESS} = \{ x \in \Delta^{NE} : u[y, y] < u[x, y], \forall{y} \in \beta(x), y \neq x \}

Proof: Let x \in \Delta^{ESS}, and let y be a strategy other than x. Let \epsilon_{y} \in (0, 1) be the barrier to invasion of y-mutants against x. As x is an Evolutionary Stable Strategy, we have for every \epsilon \in (0, \epsilon_{y}).

u[x, (1-\epsilon)x + \epsilon y] > u[y, (1-\epsilon)x + \epsilon y]

By multilinearity of the expected utilities, we have:

(1-\epsilon)u[x, x] + \epsilon u[x, y] > (1-\epsilon) u[y, x] + \epsilon u[y, y]

Taking \epsilon \to 0, we have either u[x, x] > u[y, x]; or u[x,x] = u[y, x] and u[x, y] > u[y, y]. Note that x is necessarily a Nash equilibrium; otherwise, there would exist a strategy z resulting in higher expected payoff than x, contradicting the assumption that x \in \Delta^{ESS}.

Conversely, let s be a Nash equilibrium satisfying u_{i}[a, a] < u_{i}[s, a] for all a \in \beta(s) - \{s\}, and let t \in \beta(s). Then we have u[s, s] > u[t, s]; or u[s, s] = u[t, s] and u[s, t] > u[t, t]. If u[s, s] > u[t, s], then for \epsilon = 0 we have:

(1-\epsilon)u[s, s] + \epsilon u[s, t] > (1-\epsilon) u[t, s] + \epsilon u[t, t]

And so s \in \Delta^{ESS}. Now suppose instead that u[s, s] = u[t, s] and u[s, t] > u[t, t]. We have:

u[s, s] + u[s, t] > u[t, s] + u[t, t]

Multiplying u[s, t] and u[t, t] by a fixed \epsilon \in (0, 1), and multiplying u[s, s] and u[t, s] by (1-\epsilon) yields the result. QED.

While every game has a Nash equilibrium (possibly in mixed strategies), not every game has an Evolutionary Stable Strategy. In fact, deciding if a game has an Evolutionary Stable Strategy is NP-Complete. We consider a couple examples to illustrate this point.

Recall Example 1, shown below. Intuitively, we discussed why (B, B) is evolutionary stable. It is clear that (B, B) is a Nash equilibrium. As u[B, B] = 3 > 0 = u[A, B], we have that B is evolutionary stable. Now while (A, A) is a Nash equilibrium, we have u[A, B] = 0 < 5 = u[A, A], so A is not stable.

Example1

Example 2: Consider a second game:
Example2

It is easy to verify that (A, A) is the unique Nash equilibrium of this game. In fact, (A, A) is a strict Nash equilibrium, which means that any deviation strictly decreases an agent’s payoff. Now we have u[A, A] > u[B, A] and u[A, B] > u[B, B]. So for any \epsilon \in (0, 1), we certainly have:

(1-\epsilon)u[A, A] + \epsilon u[A, B] > (1-\epsilon)u[B, A] + \epsilon u[B, B]

Thus, A is the Evolutionary Stable Strategy for this game. In fact, for any game, its strict Nash equilibria must be Evolutionary Stable Strategies.

Example 3: Consider the matching pennies game, shown below. The unique Nash equilibrium is for each agent to play the mixed strategy \sigma of A and B with frequency \frac{1}{2} each. However, it fails to meet the stability condition. Suppose player 1 players A instead of \sigma. We have u[\sigma, \sigma] = u[A, \sigma] = 0. However, u[\sigma, A] = 0 < u[A, A] = 1.

Matching_Pennies

IV. Conclusion
In this blog entry, we explored the Evolutionary Stable Strategy solution concept, which is a refinement of the Nash equilibrium. In addition to finding Evolutionary Stable Strategies in games, we discussed motivations for this concept in understanding the dynamics that drive equilibria in games. The next blog entry will further discuss refinements and adaptations of the Evolutionary Stable Strategy, with important applications and results.

Algorithmic Game Theory- College Admissions Problem

I. Introduction
This blog entry introduces the College Admissions problem, as well as several algorithmic solutions. The College Admissions problem extends the Stable Marriage problem by allowing for a many-to-one matching. The Stable-Marriage problem is a one-to-one matching problem in which each proposer may be matched with at most single acceptor, and vice-versa: e.g., one man and one woman, one firm and one employee, or one student and one school. More realistically, a firm hires many desirable employees, and a college admits many students. To this end, we extend the notion of a one-to-one matching to allow for a many-to-one matching. The College Admissions problem provides a model allowing for a college to be matched with multiple students, but students may only be matched with one college. This is also more realistic of how firms hire workers. I assume familiarity with the Stable Marriage Problem.

II. Model
The College Admissions problem starts with two disjoint sets: a set S of students and a set C of colleges. Each student i \in S has a strict, transitive preference relation \succ^{i} over the set C \cup \{\emptyset\}. By convention, if an agent x prefers \emptyset to another agent y, then x prefers being unmatched than to being matched with y. Each college c \in C also has a strict, transitive preference relation \succ^{c} over S \cup \{\emptyset\}. Additionally, each college c \in C has a capacity q_{c} \in \mathbb{Z}^{+} of students it can admit. The solution is a matching between colleges and students, which is formalized as follows:

Definition 2.1 (Many-to-One Matching). Let S and C be sets. A many-to-one matching from C to S is a function \phi : C \to 2^{S} such that for any distinct c_{1} and c_{2} in C, we have \phi(c_{1}) \cap \phi(c_{2}) = \emptyset. Furthermore, if c_{i} \in C has capacity q_{i}, then |\phi(c_{i})| \leq q_{i}.

Applying this definition to the College Admissions Problem, a Many-to-One matching function \phi relates a college c to a subset of students it admits. The matching \phi is further constrained to prohibit a student from being matched with multiple colleges. Lastly, \phi does not allow college c to admit more than q_{c} students.

The definition of a Many-to-One Matching does not account for the actors’ preferences. To this end, the notion of stability will be introduced. Stability in the College Admissions problem is analogous to that in the Stable Marriage problem. First, define the mate function to return a student’s enrolled college: \mu : S \to (C \cup \{\emptyset\}) by:

\mu(s) =  \begin{cases} c : & s \in \phi(c) \\ \emptyset : & \text{ Otherwise} \end{cases}

Definition 2.2 (Stable Matching). A Many-to-One Matching of colleges and students \phi : C \to 2^{S} is stable if and only if the following conditions hold:

  1. For any college c and student s such that s \in \phi(c), s and c prefer being matched with each other to being unmatched.
  2. There does not exist a student s and college c such that s \not \in \phi(c), but c \succ^{s} \mu(s), s \succ^{c} \emptyset if |\phi(c)| < q_{c}, and s \succ^{c} s^{\prime} for some s^{\prime} \in \phi(c) if |\phi(c)| = q_{c}.

Intuitively, a stable matching satisfies everyone. So no student-college pair should want to deviate and improve their outcomes. The definition of a stable matching prohibits any condition in which a student-college pair would want to match with each other over their current mates in a given matching. Consider a many-to-one matching \phi. The first condition describes when it is preferable for a student and college not to be matched. The second condition describes then prohibits a student-college s \in S and c \in C pair not matched by \phi to prefer matching with each other over their mates in \phi. Clearly, s must prefer c over its mate in \phi to deviate. The analysis of the college takes a little more work due to the fact that it can admit multiple students. If the college c has room for s (i.e., |\phi(c)| \leq q_{c}), it can and should admit s. If c has fulfilled its capacity, it must check if s is a better choice than one of its already admitted students. If so, c replaces its least preferred admitted student with s.

Let’s consider an example.

Example 1: Suppose we have five student S = \{ s_{1}, ..., s_{5}\} and three colleges C = \{ c_{1}, c_{2}, c_{3}\}. Each student i has the preference relation \succ^{i} := (c_{1}, c_{2}, c_{3}) (that is, c_{1} is the most preferred and c_{3} is the least preferred). The colleges have the following preferences and capacities:

  • College c_{1} has the preference relation \succ := (s_{1}, s_{2}, s_{3}, s_{4}, s_{5}) with capacity q_{c_{1}} = 2.
  • College c_{2} has the preference relation \succ := (s_{5}, s_{4}, s_{3}, s_{2}, s_{1}) with capacity q_{c_{2}} = 1.
  • College c_{3} has the preference relation \succ := (s_{1}, s_{2}) with capacity q_{c_{3}} = 1.

Consider the matching \phi : C \to 2^{S} given by \phi(c_{1}) = \{ s_{1}, s_{2}\}, \phi(c_{2}) = \{ s_{5} \}, and \phi(c_{3}) = \emptyset. Observe that c_{1} is matched with its top two choices, and s_{1} and s_{2} are matched with their top choices. Since \phi(c_{1}) has reached its capacity of two students, it cannot deviate and improve its outcome.

Now consider c_{2}. Observe that \phi gives c_{2} its top choice, s_{5}. The only college s_{5} prefers to c_{2} is c_{1}. However, c_{1} prefers both of its admitted students over s_{5} and has no room for s_{5}. Thus, s_{5} cannot match with another college c_{1} or c_{3} which will improve both s_{5}‘s outcome and the college’s outcome.

Next, consider c_{3}. According to c_{3}‘s preference relation, it will only match with s_{1} and s_{2}. Since s_{1} and s_{2} are already matched with c_{1}, which they prefer to c_{3}, it follows that c_{3} will not admit any students in a stable matching.

Finally, consider s_{3} and s_{4}. By the above analysis of c_{3}, s_{4} and s_{5} can only match with c_{1} or c_{2}. However, both c_{1} and c_{2} have filled their admittance capacities. So s_{4} and s_{5} cannot be admitted to any college. So there exists no student-college pair which can mutually deviate and match with each other over their mates in \phi. Additionally, any student-college pair that are matched under \phi prefer each other to being unmatched. Thus, \phi is a stable matching.

The definition of the core will be recalled, but I direct readers to my previous blog entry on the Stable Marriage Problem for further exposition on the core.

Definition 2.3 (Core). Let x = (x_{1}, ..., x_{n}) be an allocation. The allocation y = (y_{1}, ..., y_{n}) is said to dominate or block x if there exists a coalition S \subset N such that for every agent i \in S, y_{i} \succeq^{i} x_{i}; and for at least one j \in S, y_{j} \succ^{j} x_{j}. The Core contains the set of allocations x such that no other allocation y dominates x.

Recall from the Stable Marriage Problem that the unique stable one-to-one matching constitutes the core. The result extends to the College Assignment Problem in the case of many-to-one matchings, which is shown below.

Theorem 2.1: Let S be the set of students, and let C be the set of colleges. Let \mathcal{M} = \{ \phi : C \to 2^{S} : \phi \text{ is a stable matching } \} and let \mathcal{C} be the core of the College Admissions problem. We have \mathcal{M} = \mathcal{C}.

Proof: Let \phi : C \to 2^{S} be a stable matching. Suppose to the contrary \phi is not in the core. Then there exists a blocking coalition. By the definition of stability, no agent prefers being unmatched to its mate in \phi. So no individual will form a blocking coalition. Note that students only match with colleges, and colleges only match with students. It follows that no coalition consisting solely of students or solely of colleges will form a blocking coalition. Let \{x_{1}, ..., x_{n}\} be a coaliion blocking \phi consisting of both students and colleges. From the definition of a blocking coalition, at least one agent x_{i} in the coalition strictly improves its outcome. As each agent’s preferences are strict, agent x_{i}‘s new mate in the blocking coalition must also strictly improve its outcome over \phi, contradicting the definition of stability. It follows that \mathcal{M} \subset \mathcal{C}.

Now let x be a core allocation. As no coalition exists blocking x, no individual prefers being unmatched to its mate in x. So condition (1) of the stable matching is satisfied. Suppose x is not a stable matching. Then there exists a student-college pair that would strictly benefit from matching with each other over their mates in x. This student-college pair would form a coalition blocking x, contradicting the fact that x is a core allocation. So \mathcal{C} \subset \mathcal{M}. Thus, \mathcal{M} = \mathcal{C}. QED.

In order to find a stable matching in the College Admissions problem, the Gale-Shapley algorithm is adapted to derive two new algorithms: the Student-Optimal Deferred Acceptance (SODA) and College-Optimal Deferred Acceptance (CODA) algorithms. Recall the Gale-Shapley algorithm favors the proposers. The SODA algorithm is the analogue of the Gale-Shapley algorithm when the students propose, and the CODA algorithm is the analogue of the Gale-Shapley algorithm when the colleges propose. We begin by introducing the SODA algorithm.

III. Student-Optimal Deferred Acceptance
The Student-Optimal Deferred Acceptance algorithm works quite similarly to the Gale-Shapley algorithm. Each student takes a turn proposing to a college. If the college has not fulfilled its quota, it admits the student only if it is preferable to being unmatched. If the college has fulfilled its quota and the student is more preferable than an already admitted candidate, the college admits the student applicant and revokes acceptance to its least preferred admittant. Let’s work through an example using the SODA algorithm.

Example 2: Suppose we have six students and three colleges, with each college having a capacity of 2. The preferences are as given below:

  • Students 1 and 4 with preferences: \succ := (Y, X, Z).
  • Students 2 and 5 with preferences: \succ := (X, Z, Y).
  • Students 3 and 6 with preferences \succ := (X, Z, Y).
  • Colleges X and Y with preferences \succ := (2, 5, 3, 6, 1, 4).
  • College Z with preferences \succ := (1, 4, 2, 5, 3, 6).

The SODA algorithm proceeds as follows:

  • Student 1 proposed to College Y. College Y accepted the proposal from Student 1.
  • Student 2 proposed to College X. College X accepted the proposal from Student 2.
  • Student 3 proposed to College X. College X accepted the proposal from Student 3.
  • Student 4 proposed to College Y. College Y accepted the proposal from Student 4.
  • Student 5 proposed to College X. College X accepted the proposal from Student 5 and unmatched from Student 3.
  • Student 6 proposed to College X. College X rejected the proposal from Student 6.
  • Student 6 proposed to College Z. College Z accepted the proposal from Student 6.
  • Student 3 proposed to College Z. College Z accepted the proposal from Student 3.

The final matching is \{ (X, \{2, 5\}), (Y, \{1, 4\}), (Z, \{3, 6\}) \}.

Let’s examine an implementation.

The Student class models a Student in the College-Admissions Problem. The makeProposals() method is the workhorse of the Student class in the SODA algorithm. The makeProposals() method allows the Student to propose to Colleges in preference order until it makes a match or runs out of Students to which it can propose.

package collegeadmissions;

import java.util.ArrayList;
import java.util.PriorityQueue;

/**
 * This class models a Student in the College-Admissions Problem.
 * The Student class is designed to allow instances to propose in the
 * Student-Optimal Deferred Acceptance algorithm, or respond to College 
 * proposals in the College-Optimal Deferred Acceptance algorithm.
 * 
 * @author Michael Levet
 * @date 01/10/2016
 */
public class Student {

    private ArrayList&lt;College&gt; preferences;
    private College match;
    private String name;
   
    /**
     * @param name The name of this Student
     */
    public Student(String name){
        this.name = name;
        this.preferences = new ArrayList&lt;College&gt;();
    }
    
    /**
     * 
     * @param c The College to insert 
     * @return true if c was successfully inserted, false if c was present in the preference List
     */
    public boolean insertLeastPreferredCollege(College c){
        if(c == null || this.preferences.contains(c)){
            return false;
        }
        
        return this.preferences.add(c);
    }
    
    /**
     * 
     * @param c The College to insert
     * @param preferenceRanking The position in the preference List to insert c
     * @return true if c was successfully inserted, false if c was already present in the preference List
     */
    public boolean insertCollege(College c, int preferenceRanking){
        if(c == null || this.preferences.contains(c)){
            return false;
        }
        
        if(preferenceRanking &gt; this.preferences.size()){
            return this.preferences.add(c);
        }
        
        this.preferences.add(preferenceRanking, c); 
        return true;
    }
    
    /**
     * Determines whether this Student is unmatched and has Colleges to which
     * it has not proposed and with which it is willing to match.
     * 
     * @return true if this Student can make proposals, false otherwise.
     */
    public boolean canMakeProposal(){
        return this.match == null &amp;&amp; this.preferences.size() &gt; 0;
    }
    
    /**
     * This method is used in the Student-Optimal Deferred Acceptance algorithm.
     * The Student proceeds by selecting its most preferred College
     * to which it has not already proposed, and makes a proposal.
     * The method terminates when the Student is either matched or
     * runs out of Colleges to which it can propose.
     * 
     * @return true if a College accepts a proposal from this Student, false otherwise
     */
    public boolean makeProposals(){
        College temp = null;
        
        do{
            temp = this.preferences.remove(0);
            System.out.println(this + &quot; proposed to &quot; + temp);
            if(temp.acceptProposal(this)){
                this.match = temp;
                System.out.println(temp + &quot; accepted the proposal from &quot; + this);
                return true;
            }
            
            System.out.println(temp + &quot; rejected the proposal from &quot; + this);
            
        }while(temp != null &amp;&amp; this.preferences.size() &gt; 0);
            
        return false;
    }
    
    /**
     * This method unmatches this Student from its current mate.
     * We use this method in the College-Optimal Deferred Acceptance algorithm.
     */
    public void unmatch(){
        this.match = null;
    }
    
    /**
     * This method is used in the College-Optimal Deferred Acceptance algorithm,
     * allowing the Student to process a College's proposal. The Student can
     * accept the College's proposal, unmatching its current mate if necessary;
     * or reject c's proposal.
     * 
     * @param c The College proposing to this Student
     * @return true if this Student accepts c's proposal, false otherwise
     */
    public boolean acceptProposal(College c){
        if(!this.preferences.contains(c)){
            return false;
        }
        
        if(this.match == null){
            this.match = c; 
            return true;
        }
        
        int index = this.preferences.indexOf(c);
        int matchIndex = this.preferences.indexOf((this.match));
        
        if(index &lt; matchIndex){
           this.match.unmatchStudent(this);
           this.match = c;
           return true;
        }
        
        return false;
    }
            
    /**
     * @return College this Student's current mate
     */
    public College getMatch(){
        return this.match;
    }
    
    /**
     * @return String A String representation of this Student
     */
    public String toString(){
        return &quot;Student &quot; + this.name;
    }
}   

The College class models a College in the College-Admissions problem. The relevant method for the SODA algorithm is the acceptProposal() method, which checks several conditions. First, it checks if the College is willing to match with the Student. If not, the College outright rejects the proposal. If the College is willing to match with the student over being unmatched, the acceptProposal() method checks if the College has room; and if so, which (if any) existing Student should be replaced by the proposer.

package collegeadmissions;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * This class models a College in the College-Admissions Problem.
 * The College class is designed to allow instances to propose in the
 * College-Optimal Deferred Acceptance algorithm, or respond to Student 
 * proposals in the Student-Optimal Deferred Acceptance algorithm.
 * 
 * @author Michael Levet
 * @date 01/10/2016
 */
public class College {
   
    private PriorityQueue&lt;Student&gt; matches;
    private ArrayList&lt;Student&gt; preferences;
    private String name;
    private int capacity;
    
    /**
     * @param name The name of this College
     * @param capacity The number of Students this College can admit
     */
    public College(String name, int capacity){
        this.name = name;
        this.preferences = new ArrayList&lt;Student&gt;();
        this.capacity = capacity;

        //ranks Students based on their positions in the preferences List
        //this Comparator ensures that the PriorityQueue is stores Students
        //in order of increasing preference
        Comparator&lt;Student&gt; ranking = new Comparator&lt;Student&gt;(){
            
            public int compare(Student s1, Student s2){
                int indexOne = College.this.preferences.indexOf(s1);
                int indexTwo = College.this.preferences.indexOf(s2);
                
                return indexTwo - indexOne;
            }
        };
        
        this.matches = new PriorityQueue(capacity, ranking);
        
    }
    
    /**
     * 
     * @param s The Student to insert 
     * @return true if s was successfully inserted, false if s was present in the preference List
     */
    public boolean insertLeastPreferredStudent(Student s){
        if(s == null || this.preferences.contains(s)){
            return false;
        }
        
        return this.preferences.add(s);
    }
    
    /**
     * 
     * @param s The Student to insert
     * @param preferenceRanking The order in the preferences List to insert s
     * @return true if s was successfully inserted, false if s was present in the preference List
     */
    public boolean insertStudent(Student s, int preferenceRanking){
        if(s == null || this.preferences.contains(s)){
            return false;
        }
        
        if(preferenceRanking &gt;= this.preferences.size()){
            return this.preferences.add(s);
        }
        
        this.preferences.add(preferenceRanking, s);
        return true;
    }
    
    /**
     * This method is used in the College-Optimal Deferred Acceptance algorithm.
     * A College can make proposals if it has not reached its quota of admitted Students
     * and it has Students to which it has not proposed (and with which it is willing to match).
     * 
     * @return true if this College can make proposals, false otherwise
     */
    public boolean canMakeProposal(){
        return this.matches.size() &lt; this.capacity &amp;&amp; this.preferences.size() &gt; 0;
    }
    
    /**
     * @param s The Student to remove from this College's admitted students
     */
    public void unmatchStudent(Student s){
        System.out.println(this + &quot; unmatched from &quot; + s);
        this.matches.remove(s);
    }
    
    /**
     * This method is used in the College-Optimal Deferred Acceptance algorithm.
     * This College proposes to Students in preference order until it has fulfilled
     * its quota or runs out of Students to which it can propose.
     * 
     * @return true if this College added a Student to its matches, false otherwise
     */
    public boolean makeProposals(){
        boolean madeMatch = false;
        
        while(this.preferences.size() &gt; 0 &amp;&amp; this.matches.size() &lt; this.capacity){
            Student temp = this.preferences.remove(0);
            System.out.println(this + &quot; proposed to &quot; + temp);
            
            if(temp.acceptProposal(this)){
                this.matches.add(temp);
                madeMatch = true;
                System.out.println(temp + &quot; accepted proposal from &quot; + temp);
                continue;
            }
            
            System.out.println(temp + &quot; rejected proposal from &quot; + temp);
                    
        }
        
        return true;
    }
    
    /**
     * This method is used in the Student-Optimal Deferred Acceptance algorithm,
     * allowing the College to process a Student's proposal. The College may accept
     * the proposal, unmatching its current mate if necessary; or reject the proposal.
     * 
     * @param other The Student proposing to this College
     * @return true iff this College accepted the proposal
     */
    public boolean acceptProposal(Student other){
        int index = this.preferences.indexOf(other);
        if(index == -1){
            return false;
        }
        
        if(this.matches.size() == this.capacity){
            int indexOther = this.preferences.indexOf(this.matches.peek());
            if(index &lt; indexOther){
                Student revoked = this.matches.poll();
                System.out.println(this + &quot; unmatched from &quot; + revoked);
                revoked.unmatch();
                this.matches.add(other);
                return true;
            }
            
            return false;
        }
        
        this.matches.add(other);
        return true;
    }
    
    /**
     * @return PriorityQueue&lt;Student&gt; The admitted Students for this College
     */
    public PriorityQueue&lt;Student&gt; getMatches(){ 
        return this.matches;
    }
    
    /**
     * @return A String representation of this College
     */
    public String toString(){
        return &quot;College &quot; + this.name;
    }
}

For completeness, the MatchMaker and CollegeAdmsisions classes allow executing the algorithms.

MatchMaker.java

package collegeadmissions;

/**
 * This class accepts a List&lt;Student&gt; and List&lt;College&gt;, and allows
 * for the Student-Optimal Deferred Acceptance and College-Optimal 
 * Deferred Acceptance algorithms to be executed on the inputs
 * 
 * @author Michael Levet
 * @date 01/10/2016
 */
import java.util.List;

public class MatchMaker {
    
    private List&lt;Student&gt; students;
    private List&lt;College&gt; colleges;
    
    public MatchMaker(List&lt;Student&gt; students, List&lt;College&gt; colleges){
        this.students = students;
        this.colleges = colleges;
    }
    
    public void sodaMakeMatches(){
        boolean newProposalMade = false;
        
        do{
            newProposalMade = false;
            for(Student s : students){
                if(s.canMakeProposal()){
                   newProposalMade = s.makeProposals();
                }
            }
        }while(newProposalMade);
    }
    
    public void codaMakeMatches(){
        boolean madeMatch = false;
        
        do{
            madeMatch = false;
            
            for(College c : colleges){
                if(c.canMakeProposal()){
                    madeMatch = c.makeProposals();
                }
            }
        }while(madeMatch);
    }
}

CollegeAdmissions.java

package collegeadmissions;

/**
 *
 * @author Michael Levet
 * @date 01/10/2016
 */
import java.util.*;
public class CollegeAdmissions {

    
    public static void main(String[] args) {
        System.out.println(&quot;Executing the SODA Algorithm:&quot;);
        sodaMakeMatches();
        
        System.out.println(&quot;\n\nExecuting the CODA Algorithm:&quot;);
        codaMakeMatches();
    }
    
    public static void codaMakeMatches() {
        List&lt;Student&gt; students = new ArrayList&lt;Student&gt;();
        List&lt;College&gt; colleges = new ArrayList&lt;College&gt;();
        
        College c0 = new College(&quot;X&quot;, 2);
        College c1 = new College(&quot;Y&quot;, 2);
        College c2 = new College(&quot;Z&quot;, 2);
        colleges.add(c0);
        colleges.add(c1);
        colleges.add(c2);
        
        for(int i = 0; i &lt; 6; i++){
            Student s = new Student((i+1) + &quot;&quot;);
            students.add(s);
            
            if(i != 0 &amp;&amp; i != 3){
                s.insertLeastPreferredCollege(c0);
                s.insertLeastPreferredCollege(c2);
                s.insertLeastPreferredCollege(c1);
            }
        }
        
        Student s0 = students.get(0);
        Student s3 = students.get(3);
        
        s0.insertLeastPreferredCollege(c1);
        s0.insertLeastPreferredCollege(c0);
        s0.insertLeastPreferredCollege(c2);
        s3.insertLeastPreferredCollege(c1);
        s3.insertLeastPreferredCollege(c0);
        s3.insertLeastPreferredCollege(c2);
        
        int[] prefs1 = new int[]{1, 4, 2, 5, 0, 3};
        int[] prefs2 = new int[]{0, 3, 1, 4, 2, 5};
        
        for(int i:prefs1){
            c0.insertLeastPreferredStudent(students.get(i));
            c1.insertLeastPreferredStudent(students.get(i));
        }
        
        for(int i:prefs2){
            c2.insertLeastPreferredStudent(students.get(i));
        }
        
        MatchMaker matchMaker = new MatchMaker(students, colleges);
        matchMaker.codaMakeMatches();
        
        for(Student s : students){
            System.out.println(s + &quot; is matched with &quot; + s.getMatch());
        }
        
        for(College c : colleges){
            System.out.println(c + &quot; is matched with &quot; + c.getMatches());
        }
    }

    public static void sodaMakeMatches(){
        List&lt;Student&gt; students = new ArrayList&lt;Student&gt;();
        List&lt;College&gt; colleges = new ArrayList&lt;College&gt;();
        
        College c0 = new College(&quot;A&quot;, 2);
        College c1 = new College(&quot;B&quot;, 1);
        College c2 = new College(&quot;C&quot;, 1);
        colleges.add(c0);
        colleges.add(c1);
        colleges.add(c2);
        
        for(int i = 0; i &lt; 5; i++){
            Student s = new Student((i+1) + &quot;&quot;);
            students.add(s);
            c0.insertLeastPreferredStudent(s);
            c1.insertStudent(s, 0);
            for(College c:colleges){
                s.insertLeastPreferredCollege(c);
            }
        }
        
        c2.insertLeastPreferredStudent(students.get(0));
        c2.insertLeastPreferredStudent(students.get(1));
        
        MatchMaker matchMaker = new MatchMaker(students, colleges);
        matchMaker.sodaMakeMatches();
        
        for(Student s : students){
            System.out.println(s + &quot; is matched with &quot; + s.getMatch());
        }
        
        for(College c : colleges){
            System.out.println(c + &quot; is matched with &quot; + c.getMatches());
        }
    }
    
}

A proof of algorithm correctness will be provided.

Theorem 3.1: The SODA algorithm terminates, resulting in a stable matching that is student-optimal.

Claim 3.1.1: The SODA algorithm terminates.

Proof: Suppose that some student s is unmatched after iteration k > |C|. It follows that each college in C to which s has proposed has either rejected s outright, or accepted s‘s proposal and later unmatched from s. If a college c outright rejected s, then s need not propose to c again. If s accepted s‘s initial proposal and later unmatched from s, then s is matched with a second student t such that t \succ^{c} s. Furthermore, for any x \not \in \{s, t\} that c was matched with, it is necessary that x \succ^{c} s (otherwise, as c is rational, it would not have unmatched from x). Agent s prefers to be unmatched than to match with any college to which it did not propose prior to iteration k (otherwise, s would have proposed to one of these colleges prior to iteration k). Thus, s need not be considered again by the algorithm. By consideration of all students, the algorithm must terminate. QED.

Claim 3.1.2: The SODA algorithm produces a stable matching.

Proof: Let \phi be the matching returned by the SODA algorithm. Suppose to the contrary that it is not stable. By the algorithm, no student will propose to a college with which it would not match. Similarly, any college will reject the proposal from a student if it would prefer to remain unmatched over matching with the student. Thus, there exists a student s and college c such that s \not \in \phi(c), but c \succ^{s} \mu(s), s \succ^{c} \emptyset if |\phi(c)| < q_{c}, and s \succ^{c} s^{\prime} for some s^{\prime} \in \phi(c) if |\phi(c)| = q_{c}.

By the SODA algorithm, s would have proposed to c prior to its current mate in the matching. If |\phi(c)| < q_{c} after the algorithm terminates, then c would would have accepted s's proposal, a contradiction. If |\phi(c)| = q_{c} after the algorithm terminates; then by the algorithm, c would unmatch from its least preferred mate in \phi and mate with s, a contradiction. It follows that the matching must be stable. QED.

Claim 3.1.3: The matching produced from the SODA algorithm is student-optimal.

Proof: Let \phi be the matching returned by the SODA algorithm. Suppose to the contrary that \phi is not student-optimal. Let \phi^{\prime} be a second stable matching which weakly improves the students’ outcomes, and let s be a student such that \mu^{\prime}(s) \succ^{s} \mu(s). Then s would have proposed to \mu^{\prime}(s) prior to \mu(s) under the SODA algorithm. Since s \in \phi^{\prime}(\mu^{\prime}(s)), \mu^{\prime}(s) prefers to match with s over being unmatched. However, \mu^{\prime}(s) unmatched from s or outright rejected s in the algorithm, implying that \mu^{\prime}(s) prefers \phi(\mu^{\prime}(s)) to \phi^{\prime}(\mu^{\prime}(s)). Without loss of generality, suppose this was the first instance of a rejection or unmatching in the SODA algorithm. As this is the first instance of rejection or unmatching, there exists a student t \in \phi(\mu^{\prime}(s)) \setminus \phi^{\prime}(\mu^{\prime}(s)). Furthermore, as this is the first instance of rejection or unmatching, each student in \phi(\mu^{\prime}(s)) can have no stable partner better than \mu^{\prime}(s). It follows that t prefers \mu^{\prime}(s) to \mu^{\prime}(t), and so \{ \mu^{\prime}(s), \phi(\mu^{\prime}(s))\} form a coalition blocking \phi^{\prime}, contradicting the stability of \phi^{\prime}. It follows that \phi is student-optimal. QED.

Claims 3.1.1, 3.1.2, and 3.1.3 together imply Theorem 1. Claim 3.1.3 also yields an important corollary.

Corollary 3.1.3: The SODA algorithm returns the same matching regardless of the order in which the students propose to the colleges.

Remark: When each college has capacity $1$, this is exactly the Stable-Marriage problem. Recall the definition of a strategy proof mechanism is one in which truthfully revealing one’s preferences is a weakly dominant strategy. The Stable-Marriage problem has no strategy-proof mechanism, which was shown in my previous blog entry. Therefore, the result extends to the many-to-one matching case. So while in the SODA algorithm, it is optimal for students to truthfully reveal their preferences, this is not the case for the colleges as demonstrated in the example from my previous blog entry. Furthermore, the colleges receive their worst core allocations under the SODA algorithm. This generalizes the result of the Gale-Shapely algorithm, which will be proven next.

Theorem 3.1.2: Under the SODA algorithm, each college receives its least preferred core allocation.

Proof: Let \phi be the stable matching returned by the SODA algorithm. Suppose to the contrary that there exists a second stable matching \phi^{\prime} that grants each college its least preferred core allocation. Let c be a college such that c prefers strictly \phi(c) to \phi^{\prime}(c). If |\phi^{\prime}(c)| > |\phi(c)|, then any student in \phi^{\prime}(c) \setminus \phi(c) would have proposed to c under the SODA algorithm. As |\phi(c)| < |\phi^{\prime}(c)| \leq q_{c}, c would have admitted at least one of these students. Thus, |\phi(c)| \geq |\phi^{\prime}(c)| necessarily. As c strictly prefers its allocation in \phi over that in \phi^{\prime}, there exists a student in s \in \phi(c) \setminus \phi^{\prime}(c). As \phi is student-optimal, \{c, \phi(c)\} forms a coalition blocking \phi^{\prime}, contradicting the stability of \phi^{\prime}. QED.

IV. College-Optimal Deferred Acceptance
The College-Optimal Deferred Acceptance (CODA) algorithm is the analogue of the Gale-Shapley algorithm in which the colleges do the proposing rather than the students. The algorithm proceeds similarly as the SODA algorithm. It begins by selecting a college c with open slots. If there exist students with whom c will match, c proposes to them in order of preference. A student may accept a proposal or reject it. If a student is matched with a different college than the one proposing, the student must unmatch from its present mate before accepting a proposal from a new mate. Let’s work through an example of the CODA algorithm.

Example 3: Recall the six students and three colleges from Example 2. The CODA algorithm proceeds as follows:

  • College X proposed to Student 2. Student 2 accepted proposal from Student 2.
  • College X proposed to Student 5. Student 5 accepted proposal from Student 5.
  • College Y proposed to Student 2. Student 2 rejected proposal from Student 2.
  • College Y proposed to Student 5. Student 5 rejected proposal from Student 5.
  • College Y proposed to Student 3. Student 3 accepted proposal from Student 3.
  • College Y proposed to Student 6. Student 6 accepted proposal from Student 6.
  • College Z proposed to Student 1. Student 1 accepted proposal from Student 1.
  • College Z proposed to Student 4. Student 4 accepted proposal from Student 4.

The final matching is \{ (X, \{2, 5\}), (Y, \{3, 6\}), (Z, \{1, 4\})\}.

Recall the sample code in Section III. The makeProposals() method in the College class is the workhorse of this algorithm. A given College proposes to Students one at a time in preference order until it has either filled its quota or runs out of Students to which it can propose. Each Student can either outright reject a College’s proposal, or accept the proposal. If the Student is already matched with another College, it must unmatch from its current mate to accept a new proposal. The acceptProposal() method in the Student class handles this logic by checking if the Student is willing to match with the proposing College, and whether the proposing College is more preferable to the Student’s current mate. A College that is unmatched may propose again to any remaining Students in its preference list.

We now examine a proof of algorithm correctness for the CODA algorithm, which is analogous to that of the SODA algorithm.

Theorem 4.1: The CODA algorithm terminates, resulting in a stable matching that is college-optimal.

Claim 4.1.1: The CODA algorithm terminates.

Proof: Suppose there exists an unmatched college c at iteration k > |S|. By the CODA algorithm, each student to which c has proposed either outright rejected the proposal, or accepted the proposal then later unmatched from c. And so each student to which c has already proposed is matched with a college more preferable than c or unmatched. Therefore, c will be rejected if it proposes to these students again. Since k > |S|, c has proposed to all the students with whom it is willing to match. Therefore, c has no available options. By considering all such colleges, it follows that the CODA algorithm terminates. QED.

Claim 4.1.2: The CODA algorithm produces a stable matching.

Proof: Let \phi be the matching returned by the CODA algorithm. Suppose to the contrary that \phi is not stable. Colleges will only propose with whom they are willing to match, and students will only accept proposals from colleges with which they are willing to match. So no individual agent will form a blocking coalition by itself. So there must exist a student s and college c such that s \not \in \phi(c) but s and c prefer each other to their current mates in \phi. Under the CODA algorithm, c would have proposed to s. If |\phi(c)| < q_{c}, then s would have been added to \phi(c) under the CODA algorithm. But since s was not added to \phi(c), it follows that |\phi(c)| = q_{c}. Let t \in \phi(c) be c's least preferred match. Since \{c, \phi(c)\} blocks \phi, s \succ^{c} t. Under the CODA algorithm, c would have proposed to s prior to t and s would have accepted, contradicting the fact that t \in \phi(c). It follows that \phi must be stable. QED.

Claim 4.1.3: The matching produced by the CODA algorithm is college-optimal.

Proof: Let \phi be the matching returned by the CODA algorithm. Suppose to the contrary that there exists a second stable matching \phi^{\prime} which weakly improves upon the colleges’ outcomes. Let c \in C such that \phi^{\prime}(c) \succ^{c} \phi(c). Then there exists a student s \in \phi^{\prime}(c) \setminus \phi(c) such that c prefers s to its least preferred mate t \in \phi(c). Then under the CODA algorithm, c would have proposed to s prior to t. However, s must have rejected c. Without loss of generality, suppose this is the first instance of rejection. As \phi^{\prime} is stable, s prefers being matched with c over being single. So s must be matched with another college x under \phi. Since this is the first instance of rejection, it follows that x can have no better set of mates than \phi(x). So \{x, \phi(x)\} forms a blocking coalition of \phi^{\prime}, contradicting the stability of \phi^{\prime}. QED.

Remark: Just as the SODA algorithm is not strategy proof, neither is the CODA algorithm. Furthermore, the CODA algorithm grants the students their worst stable matching, analogously to the SODA algorithm with respect to the colleges. This final result will now be proven.

Theorem 4.1.2: Under the CODA algorithm, each student receives its least preferred core allocation.

Proof: Let \phi be the stable matching returned by the CODA algorithm. Suppose to the contrary that there exists a second stable matching \phi^{\prime} granting each student its least preferred core allocation. Let s be a student such that s strictly prefers its mate in \phi over its mate in \phi^{\prime}. As \phi is college-optimal, \{\mu(s), \phi(\mu(s))\} blocks \phi^{\prime}, contradicting the stability of \phi^{\prime}. QED.

V. Conclusion
In this blog entry, the notion of a one-to-one matching was extended to a many-to-one matching. Two extensions of the Gale-Shapley algorithm were explored, including the Student-Optimal Deferred Acceptance and College-Optimal Deferred Acceptance algorithms. We examined sample implementations, as well as proofs of correctness for these algorithms. The College-Admissions problem has an important extension, where Students signal their viabilities to colleges through the use of test scores. In certain approaches, Students may benefit by under-performing on certain tests. So the matching problem can be extended to design a mechanism rewarding students for doing their best on tests. Additionally, the natural question arises of how to extend the many-to-one matching problem to the case of many-to-many matchings.

Game Theory: Mixed-Strategies and Zero-Sum Games

I. Introduction
In my previous blog entry, the normal form game and Nash equilibrium were introduced. Attention was restricted to pure strategies. As will be illustrated below, not every finite, normal form game has a pure strategies Nash equilibrium. The notion of mixed strategies extends the notion of pure strategies, allowing players to assign probabilities to each pure strategy. This extension provides for the existence of a mixed strategies Nash equilibrium in every finite, normal form game. Additionally, zero sum games and prudent strategies will be discussed.

II. Mixed-Strategies
In this section, we introduce the notion of mixed-strategies. One important motivator for mixed-strategies is that not every game has a pure strategies Nash equilibrium. Consider the matching pennies game:

Matching_Pennies

In any pure strategy profile, one player incurs utility 1 and the other player incurs utility -1. The player incurring utility -1 can unilaterally deviate by switching its choice to improve its utility. This inverts the payoffs- the first player incurs utility -1 while the second player incurs utility 1. Iterating on the above argument, we see that no Nash equilibrium exists in pure strategies.

Mixed Strategies: Let \Gamma be a normal form game. Let i \in N. A mixed strategy is a sequence (s_{j})_{j=1}^{k} \in S_{i} and a probability distribution \sigma = (\sigma_{j})_{j=1}^{k} where player i selects strategy s_{j} with probability \sigma_{j}. Note that \sum_{j=1}^{k} \sigma_{j} = 1. The set of mixed strategies for player i is denoted \Sigma_{i} := \Delta(S_{i}), where \Delta(S_{i}) is the simplex in \mathbb{R}^{|S_{i}|}. That is, \Delta(S_{i}) = \{ x \in \mathbb{R}^{|S_{i}|} : x_{i} \geq 0 \text{ } \forall{i} \in \{1, ..., |S_{i}|\}, \sum_{i=1}^{|S_{i}|} x_{i} = 1 \}.

Note that pure strategies are a special case of mixed strategies. The mixed extension will now be defined, to formalize the notion of games with mixed strategies. A mixed strategies Nash equilibrium in a normal form game is equivalent to a pure strategies Nash equilibrium in a mixed extension.

Mixed Extension: Let \Gamma = [N, (S_{i})_{i \in N}, (u_{i})_{i \in N}] be a normal form game. The mixed extension of \Gamma is the three-tuple [N, (\Sigma_{i})_{i \in N}, (u_{i})_{i \in N}], where \Sigma_{i} := \Delta(S_{i}).

The notion of mixed strategies is rather unintuitive from a behavioral perspective, as a normal form game is played simultaneously. So how is a mixed strategies Nash equilibrium formulated? Recall that each player is a rational, utility maximizing agent that is aware of the structure of the game. Each player still seeks to mix its strategies in such a way to maximize its utility. In mixing strategies, a player runs the risk that another player can take advantage of a given mixing. Thus, in a Nash equilibrium, each player i mixes strategies such that -i is indifferent to whichever pure strategy ends up being played. That is, -i‘s expected utility for each of i‘s pure strategies in the mixing is the same. This is formalized as follows.

Theorem 2.1: Let \Gamma be a normal form game. A mixed strategy profile \sigma^{*} is a mixed strategy Nash equilibrium if and only if, for each player i, the following two conditions are satisfied:

  1. Every pure strategy s_{i} \in S_{i} which is given positive probability by \sigma_{i}^{*} yields the same expected payoff against \sigma_{-i}^{*}; that is, u_{i}(s_{i}, \sigma_{-i}^{*}) = u_{i}(\sigma^{*}).
  2. Every pure strategy s_{i} \in S_{i} which is given probability zero by \sigma_{i}^{*} yields no more than the pure strategies that are assigned positive probability: u_{i}(s_{i}, \sigma_{-i}^{*}) \leq u_{i}(\sigma^{*}).

Proof: Suppose first that the mixed-strategy profile \sigma^{*} satisfies conditions (1) and (2). Let i \in N. If i unilaterally deviates by shifting positive probability to a strategy s_{i} \in S_{i} given zero probability in \sigma^{*}, then i‘s utility does not increase by condition (2). Let S_{i}^{\prime} = \{ s_{i} \in S_{i} : \sigma_{i}^{*}(s_{i}) > 0 \} be the set of strategies given positive probability by \sigma_{i}^{*}. By condition (1), each pure strategy in S_{i}^{\prime} results in the same expected utility \overline{u}. Thus, any mixing \gamma of strategies in S_{i}^{\prime} results in expected utility:

\sum_{s_{i} \in S_{i}^{\prime}} \gamma(s_{i}) u_{i}(s_{i}, \sigma_{-i}^{*}) = \overline{u} \sum_{s_{i} \in S_{i}^{\prime}} \gamma(s_{i}) = \overline{u}

Thus, player i cannot unilaterally deviate and improve its outcome, so \sigma^{*} is a mixed strategies Nash equilibrium.

Conversely, suppose \sigma^{*} is a mixed-strategies Nash equilibrium. As no player can unilaterally deviate and improve its outcome, condition (2) follows immediately. Suppose to the contrary that condition (1) does not hold. Let i \in N and s_{i} \in S_{i} such that the u_{i}(s_{i}, \sigma_{-i}^{*}) \neq u_{i}(\sigma^{*}). If u_{i}(s_{i}, \sigma_{-i}^{*}) > u_{i}(\sigma^{*}), then player i could assign more weight to s_{i} in \sigma_{i}^{*} and improve its outcome. Similarly, if u_{i}(s_{i}, \sigma_{-i}^{*}) < u_{i}(\sigma^{*}), then player i could assign less weight to s_{i} in \sigma_{i}^{*} and improve its outcome. Either occurrence contradicts the assumption that \sigma^{*} is a mixed-strategies Nash equilibrium. QED.

Example 1: Let’s now use Theorem 2.1 to find a mixed-strategies Nash equilibrium for the Matching Pennies game. Player 1 mixes strategies such that Player 2 is indifferent to H and T. Suppose Player 1 plays H with probability p and T with probability 1-p. Player 2‘s payoff from playing H is -p + (1-p) = 1 - 2p. Player 2‘s payoff from playing T is p - (1 - p) = 1-2p. In equilibrium, Player 2 is indifferent between playing H and T. Setting 1 - 2p = 2p - 1 \implies p^{*} = \frac{1}{2}. By symmetry, we have Player 2 mixing between H and T with frequencies (\frac{1}{2}, \frac{1}{2}) as well.

In addition to guaranteeing the existence of a Nash equilibrium, mixed strategies are also useful in selecting realistic Nash equilibria. Consider the following example.

Example 2: Consider a traffic routing game on the following network. The weight of each edge denotes the latency cost of traversing that edge. The variable x denotes the number of players traversing the edge (A, B), and the variable y denotes the number of players using the edge (C, D). So for example, if x = 50, then the latency cost of (A, B) is 1.5 for every each of the 50 players. Each player starts at A and ends at D, seeking to minimize latency.

Suppose there are 100 players in the game. Denote n_{1} as the number of players choosing the path \text{ABD}, n_{2} as the number of players choosing the path \text{ACD}, and n_{3} as the number of players choosing \text{ABCD}. Consider first the pure strategies Nash equilibrium of n_{1} = 25, n_{2} = 25, n_{3} = 50. Both the edges (A, B) and (C, D) have 75 players traversing them, and so have latency costs 1.75. Players of each type incur latency cost 3.75. If a player of type n_{1} unilaterally deviates, he increases the latency cost of the edge (C, D) to 1.76, resulting in a total latency cost of 3.76. By similar argument, players of type n_{2} and n_{3} cannot unilaterally deviate and decrease their costs as well.

While n_{1} = n_{2} = 25 and n_{3} = 50 is a pure strategies Nash equilibrium, it is unlikely the 100 players will end up playing this strategy profile. However, this pure strategies equilibrium does provide the probabilities for a mixed strategies equilibrium. As the game is symmetric, there exists a Nash equilibrium in which each player selects the same strategy. Suppose each player selects the mixed strategy (\text{ABD}, \text{ACD}, \text{ABCD}) with probabilities (\frac{1}{4}, \frac{1}{4}, \frac{1}{2}). We apply Theorem 2.1 to verify this mixed strategy profile, denoted \sigma^{*}, is a mixed-strategies Nash equilibrium.

First, observe that \mathbb{E}[u_{i}(\sigma^{*})] = 3.75. Consider each of the pure strategies \text{ABD}, \text{ACD}, \text{ABCD}.

  • Suppose player i plays the pure strategy \text{ABD}. Under \sigma_{-i}^{*}, n_{1} = 24, n_{2} = 25, and n_{3} = 50. So \mathbb{E}[u_{i}(\text{ABD}, \sigma_{-i}^{*})] = 1.75 + 2 = 3.75 = \mathbb{E}[u_{i}(\sigma^{*})].
  • Suppose player i plays the pure strategy \text{ACD}. Under \sigma_{-i}^{*}, n_{1} = 25, n_{2} = 24, and n_{3} = 50. So \mathbb{E}[u_{i}(\text{ACD}, \sigma_{-i}^{*})] = 1.75 + 2 = 3.75 = \mathbb{E}[u_{i}(\sigma^{*})].
  • Suppose player i plays the pure strategy \text{ABCD}. Under \sigma_{-i}^{*}, n_{1} = n_{2} = 25 and n_{3} = 49. So \mathbb{E}[u_{i}(\text{ABCD}, \sigma_{-i}^{*})] = 1.75 + 0.25 + 1.75 = 3.75 = \mathbb{E}[u_{i}(\sigma^{*})].

Thus, \sigma^{*} is a mixed-strategies Nash equilibrium.

III. Zero-Sum Games
In this section, we examine zero-sum games. Intuitively, in a zero sum game, each player’s gain (or loss) is exactly balanced with those of the other players. For example, cutting a larger slice of cake for one person leaves less cake for the others. This notion is formalized as follows:

Zero-Sum Games: Let \Gamma be a normal form game. \Gamma is said to be a Zero-Sum Game if \sum_{i \in N} u_{i}(\sigma) = 0 for every strategy profile \sigma.

Recall the Matching Pennies game from the previous section. In any strategy profile, one player earns utility 1 while the other player earns utility -1. Thus, the Matching Pennies game is a zero-sum game. Another example of a zero-sum game is Rock-Paper-Scissors. The winner of the game earns utility 1 while the loser earns utility -1. In the event of a tie, each player earns utility 0.

So how are zero-sum games solved? We can solve zero-sum games in the same manner as any other normal form game. Of particular interest, however, are prudent strategies. Intuitively, players who play prudently seek to minimize potential losses. We define prudent strategies as follows:

Prudent Strategies: Let \Gamma be a finite, normal form game. A prudent strategy of player i is a mixed strategy \sigma_{i}^{*} that satisfies \max_{\sigma_{i}} \min_{\sigma_{-i}} u_{i}(\sigma_{i}, \sigma_{-i}).

Note that the definition of prudent strategies did not restrict to zero-sum games. We discuss them in the context of zero-sum games; however, as they are most useful here. In the case of a two-player game, saddle points are equivalent to prudent strategies. We define a saddle point as follows.

Saddle Point: Let \Gamma be a two-player zero-sum game. A saddle point is a strategy profile (\sigma_{1}^{*}, \sigma_{2}^{*}) \in S_{1} \times S_{2} satisfying u_{i}(\sigma_{1}, \sigma_{2}^{*}) \leq u_{i}(\sigma_{1}^{*}, \sigma_{2}^{*}) \leq u_{i}(\sigma_{1}^{*}, \sigma_{2}) for all \sigma_{1} \in S_{1}, all \sigma_{2} \in S_{2}, and each i \in \{1, 2\}.

In order to test for saddle points in finite games, we convert the payoff matrix into a mathematical matrix from linear algebra. As we are considering zero sum games, define the matrix A to be a real-valued |S_{1}| \times |S_{2}| matrix where [A_{ij}] = u_{i}(s_{i}, s_{j}), s_{i} \in S_{1}, s_{j} \in S_{2}. That is, [A_{ij}] represents the amount Player 1 wins and Player 2 loses when the pure strategy profile (s_{i}, s_{j}) is played. A saddle point A_{ij} is a minimum of row i and a maximum of column j. Let’s consider an example of finding a saddle point.

Example 3: Consider the two-player, zero-sum game given by the following payoff matrix.

Ex3

We begin by converting the payoff matrix to an algebraic matrix:

\begin{bmatrix} 4 & 1 & -3 \\ 3 & 2 & 5 \\ 0 & 1 & 6 \end{bmatrix}

The row minima are -3, 2, 0; and the column maxima are 4, 2, 6. Observe that row two and column two have the same value: 2. So (M, M) is a saddle point with payoff (2, -2).

Example 4: Consider the two-player, zero-sum game given by the following payoff matrix.

Ex4

We begin by converting the payoff matrix to an algebraic matrix:

\begin{bmatrix} 2 & -1 \\ -1 & 1 \end{bmatrix}

The row minima are -1 for row one, and -1 for column one. The column maxima are 2 for column one, and 1 for column two. So there are no pure strategy saddle points for this game.

We solve this game by determining the mixed strategies Nash equilibria. Suppose Player 2 plays L with probability p and R with probability (1-p). If Player 1 plays T, his expected payoff is 2p - (1-p) = 3p - 1. If Player 1 plays B, his expected payoff is -p + (1-p) = 1 - 2p. Setting 3p - 1 = 1 - 2p \implies p = \frac{2}{5}. So Player 2 plays L with probability \frac{2}{5} and R with probability \frac{3}{5} in equilibrium.

We now solve for Player 1’s mixed equilibrium strategies. Suppose Player 1 plays T with probability q and B with probability 1-q. Then Player 2’s expected payoff from playing L is -2q + 1-q = 1 - 3q. Player 2’s expected payoff from playing R is q - (1-q) = 2q - 1. Setting 2q - 1 = 1 - 3q yields q = \frac{2}{5}. So Player 1 plays T with probability \frac{2}{5} and B with probability \frac{3}{5} in equilibrium.

When considering mixed strategies or infinite games with compact (closed and bounded) strategy sets (such as mixed extensions of normal form games), saddle points are guaranteed to exist. This is due to a result in real analysis known as the Weierstrass Extreme Value Theorem, which states that a continuous function over a compact set achieves both a maximum and a minimum.

It is easy to verify that a pure-strategy saddle point is a Nash equilibrium in a finite zero-sum games. This verification is presented in the following theorem to build intuition. The logic is analogous in the case of infinite games (such as mixed extensions of finite zero-sum games).

Theorem 3.1: Let \Gamma be a two-player zero-sum game and let A be the associated matrix. Suppose (s_{i}, s_{j}) \in S_{1} \times S_{2} is a saddle point. Then (s_{1}, s_{2}) constitutes a Nash equilibrium of \Gamma.

Proof: As A_{ij} is the maximum of column j, a unilateral deviation from Player 1 will result in payoff A_{kj} for some k. It follows that A_{kj} \leq A_{ij}, so Player 1 cannot unilaterally deviate and improve its outcome. For Player 2, u_{2}(s_{i}, s_{j}) = -A_{ij} as \Gamma is a zero-sum game and by construction of the matrix A. So if Player 2 unilaterally deviates, the payoff will be u_{2}(s_{i}, s_{m}) = -A_{im} \leq u_{2}(s_{i}, s_{j}) since A_{im} \geq A_{ij}. And so Player 2 cannot unilaterally deviate and improve its outcome. Thus, (s_{i}, s_{j}) is a Nash equilibrium. QED.

The Nash equilibria of zero-sum games can be characterized in terms of prudent strategies. Intuitively, each player seeks to minimize its opponent’s payoff. As a zero-sum game is being considered, this leaves more for the individual. This notion is formalized as follows:

Theorem 3.2: In any finite, two-person zero-sum game, the following conditions hold:

  1. If (\sigma_{1}^{*}, \sigma_{2}^{*}) is a mixed strategies Nash equilibrium, then \sigma_{i}^{*} is a prudent strategy of player i \in \{1, 2\} and:

    \max_{\sigma_{1}} \min_{\sigma_{2}} u_{1}(\sigma_{1}, \sigma_{2}) = \min_{\sigma_{2}} \max_{\sigma_{1}} u_{1}(\sigma_{1}, \sigma_{2}) = u_{1}(\sigma_{1}^{*}, \sigma_{2}^{*})   (2)

  2. If \sigma_{i}^{*} is prudent for each i \in \{1, 2\}, then (\sigma_{1}^{*}, \sigma_{2}^{*}) is a mixed-strategies Nash equilibrium.

Proof: Suppose first that (\sigma_{1}^{*}, \sigma_{2}^{*}) is a mixed strategies Nash equilibrium. Now suppose to the contrary that for some i \in \{1, 2\}, \sigma_{i}^{*} is not prudent. It follows that there exists a strategy \sigma_{i}^{\prime} guaranteeing a better result than \sigma_{i}^{*}. Consider the mixed strategy profile (\sigma_{i}^{\prime}, \sigma_{-i}^{\prime}), where \sigma_{-i}^{\prime} is a best response to \sigma_{i}^{\prime}. We thus have u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{\prime}) > u_{i}(\sigma_{i}^{*}, \sigma_{-i}^{*}). As \sigma_{i}^{*} is a best response to \sigma_{-i}^{*}, we have u_{i}(\sigma^{*}, \sigma_{-i}^{*}) \geq u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{*}). As \sigma_{-i}^{\prime} is a best response to \sigma_{i}^{\prime} and the game is zero-sum, it follows that u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{*}) \geq u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{\prime}). Chaining the inequalities together implies u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{\prime}) > u_{i}(\sigma_{i}^{\prime}, \sigma_{-i}^{\prime}), a contradiction. It follows that \sigma_{i}^{*} is prudent for both players.

It will now be shown that (2) holds. Note that for any function f(x, y) and fixed x, y, we have \min_{y^{\prime}} f(x, y^{\prime}) \leq f(x, y) \leq \max_{x^{\prime}} f(x^{\prime}, y). Taking the max of both sides maintains this inequality. Thus:

\max_{\sigma_{1}} \min_{\sigma_{2}} u_{1}(\sigma_{1}, \sigma_{2}) \leq \min_{\sigma_{2}} \max_{\sigma_{1}} u_{1}(\sigma_{1}, \sigma_{2})

Similarly, as (\sigma_{1}^{*}, \sigma_{2}^{*}) is a saddle point, we have:

\max_{\sigma_{1}} u_{1}(\sigma_{1}, \sigma_{2}^{*}) \leq u_{1}(\sigma_{1}^{*}, \sigma_{2}^{*}) \leq \min_{\sigma_{2}} u_{1}(\sigma_{1}^{*}, \sigma_{2})

And so:

\min_{\sigma_{2}} \max_{\sigma_{1}} u_{1}(\sigma_{1}, \sigma_{2}) \leq \max_{\sigma_{1}} u_{1}(\sigma_{1}, \sigma_{2}^{*}) \leq \min_{\sigma_{2}} u_{1}(\sigma_{1}^{*}, \sigma_{2}) \leq \max_{\sigma_{1}} \min_{\sigma_{2}} u_{1}(\sigma_{1}, \sigma_{2}^{*})

Thus, (2) holds.

Conversely, suppose \sigma_{i}^{*} is prudent for each i \in \{1, 2\}. As \sigma_{i}^{*} is prudent, it solves \max_{\sigma_{i}} u_{i}(\sigma_{i}, \sigma_{-i}^{*}). So player i cannot unilaterally deviate and improve its payoff. Thus, (\sigma_{1}^{*}, \sigma_{2}^{*}) is a mixed-strategies Nash equilibrium. QED.

Game Theory: Normal Form Games- Part 1

I. Introduction

Game Theory is a mathematical field that studies how rational agents make decisions in both competitive and cooperative situations. It has widespread applications in economics, political science, psychology, biology, computer science, and data science. Some of the applications include radio spectrum auctions, voting, and organ donations. This tutorial introduces the basic strategic form game, also known as the normal form game. Attention will be restricted to pure strategies.

II. Model
In this section, we formally define the normal form game. Let’s begin with some intuition. A normal form game has a set of players. Each player has a set of strategies. These players each select a strategy and play their selections simultaneously. In this manner, no player is responding to another’s selection. Furthermore, we think of the players’ strategies as setting the rules of the game. Finally, the selection of strategies results in payoff or utility for each player. Each player’s goal in a game is to maximize utility, and each player is aware of the structure of the game; that is, the other players’ strategy sets and payoffs. The normal form game will now be formally defined.

Normal Form Game: A normal form game \Gamma is a three-tuple [N, (S_{i})_{i \in N}, (u_{i})_{i \in N}] where N is the set of players, S_{i} is player i‘s strategy set, and u_{i} : \prod_{i \in N} S_{i} \to \mathbb{R} is player i‘s payoff or utility function. The sequence of strategies (s_{1}, ..., s_{n}) \in \prod_{i \in N} S_{i} is referred to as a strategy profile.

In addition to the assumptions that the players are economically rational and play at the same time, it is also assumed that the structure of the game is perfectly known. In other words, each player knows every player’s strategy set and utility function.

Let’s examine an example of a normal form game, the standard Prisoner’s Dilemma.

Example 1 (Prisoner’s Dilemma): In this game, the police have two accomplices of a crime in separate rooms. They are each offered a deal: implicate the other prisoner and earn a reduced sentence if the other player remains silent. If both players remain silent, they each end up in jail for two years. If both players implicate each other, they each go to jail for five year.

Formally, we have two players N = \{ 1, 2\}. Each player has the strategy set S_{i} = \{ \text{Quiet}, \text{Fink}\}, and the utility function of the form u_{i} : S_{i} \times S_{i} \to \mathbb{R}. If both players play Quiet, they each earn utility of -2; and if both play Fink, they each earn utility of -5. If one player plays Quiet and the other Fink, they earn utilities of -10 and -1 respectively.

We represent the normal form game using the following matrix known as a payoff matrix. Player 1‘s strategies are on the left-side while Player 2‘s strategies are on the top of the matrix. Each cell represents the payoffs of the form (u_{1}(s_{1}, s_{2}), u_{2}(s_{1}, s_{2})) for the selected strategies s_{1} \in S_{1} and s_{2} \in S_{2}.

Prisoners_Dilemma
Not every normal form game can be represented as a matrix. When we have more than two players or continuous strategies, tables are not very helpful. Let’s consider a second example of a normal form game: the Cournot duopoly.

Example 2 (Cournot Duopoly): In this game, we have two players again: N = \{1, 2\}. Each player is a firm producing the same, identical good. The market sets the price for the good based on the total amount produced by the two firms. The two firms compete in the quantities of the good they each produce, incurring a fixed cost c > 0 for each unit of good produced. Each firm seeks to maximize its own profit. Suppose the inverse demand function (the price function) is given as follows where a, b > 0:

P(q_{1}, q_{2}) = \begin{cases} a - b(q_{1} + q_{2}) : & \text{ if } q_{1} + q_{2} \leq a/b \\ 0 : & \text{ if } q_{1} + q_{2} > a/b \end{cases}

Each firm has the strategy set S_{i} = \mathbb{R}_{+}, indicating the quantity of the good it can produce. Each firm also has the utility function of the form u_{i} : \mathbb{R}_{+}^{2} \to \mathbb{R} given by u_{i}(q_{1}, q_{2}) = q_{i}P(q_{1}, q_{2}) - cq_{i}. Since the strategies are uncountable, it is pointless to construct a payoff matrix to help in analyzing the game.

III. Solving Games and Nash Equilibrium
Recall that each player in a given game seeks to maximize its utility. How do agents select strategies? What is the solution concept for a game? The first notion of comparison is rather intuitive and straight-forward. We refer to it as strategy dominance. Basically, if strategy s_{i} yields at least as good a payoff as strategy s_{j} regardless of the other agents’ strategy selections, then why would the player ever choose strategy s_{j}? We first introduce the following notation. Let i \in N. We denote -i := N \setminus \{i\}. Now we formalize the notion of desirable strategies by defining a Best Response.

Best Response: Let i \in N and let s_{i} \in S_{i}. The strategy s_{i} is a best response of player i against s_{-i} \in S_{-i} if u_{i}(s_{i}, s_{-i}) \geq u_{i}(s_{i}^{\prime}, s_{-i}) for every s_{i}^{\prime} \in S_{i}.

We denote B_{i}(s_{-i}) = \{ s_{i} \in S_{i} : u_{i}(s_{i}, s_{-i}) \geq u_{i}(s_{i}^{\prime}, s_{-i}) \text{ } \forall s_{i}^{\prime} \in S_{i} \} as i‘s best response correspondence against s_{-i}, or the set of all i‘s strategies that are best responses to s_{-i}. Note that every element of B_{i}(s_{-i}) solves \max_{s_{i} \in S_{i}} u_{i}(s_{i}, s_{-i}).

Let’s consider an example with a new game, a voting game.

Example 3 (Voting Game): Suppose we have three players, N = \{1, 2, 3\} and two candidates A, B. Each player can vote for exactly one of A or B, so S_{i} = \{A, B\}, for all i \in N. The three players cast their votes simultaneously. Players 1 and 2 incur utility 1 if A wins and utility 0 if B wins. Player 3 incurs utility 0 if A wins and utility 1 if B wins.

Observe that for any s_{-1} \in S_{-1}, B_{1}(s_{-1}) = \{A\}. If s_{-1} = (B, B), player 1 selecting s_{1} = A incurs the same utility of 0 as selecting s_{1} = B. Otherwise, if player 1 selects s_{1} = A and at least one player of -1 selects A, then player 1 incurs utility 1 while selecting $late B$ may result in utility 0 if only one of the players in -1 selects A. In fact, we can say more strongly that for player 1, voting for A is a weakly dominant strategy. This is formally defined as follows.

Dominated Strategies: The strategy \overline{s_{i}} \in S_{i} is weakly dominated if there exists a second strategy \hat s_{i} \in S_{i} such that: u_{i}(\overline{s_{i}}, s_{-i}) \leq u_{i}(\hat s_{i}, s_{-i}) for every s_{-i} \in S_{-i}, with strict inequality for at least one s_{-i}. We say that \overline{s_{i}} is strictly dominated if the strict inequality holds for all s_{-i} \in S_{-i}.

Now that we have some notion of how a player compares its strategies, the next step is to discern how the players select their strategies in anticipation of each other. The solution concept is the Nash equilibrium. Formally, the Nash equilibrium is defined as follows.

Nash Equilibrium: The strategy profile s^{*} is said to be a Nash Equilibrium if s_{i}^{*} \in B_{i}(s_{-i}^{*}) for every i \in N.

Intuitively, a strategy profile s^{*} is a Nash equilibrium if no player can unilaterally change its strategy and improve its outcome. Let’s apply this reasoning to deduce the Nash equilibrium for the Prisoner’s Dilemma game from Example 1, with the payoff matrix included below. If the two players both select Quiet, then they each incur utility of -2. One of the players can unilaterally deviate, playing Fink instead, decreasing its utility to -1 while the other player’s utility is decreased to -10. So (Quiet, Quiet) is not a Nash equilibrium. Consider (Fink, Quiet). Player 2 can unilaterally deviate, playing Fink instead of Quiet to improve its payoff from -10 to -5. By symmetry, (Quiet, Fink) is not a Nash equilibrium. Finally, consider (Fink, Fink). By previous analysis, a single player unilaterally changing from Fink to Quiet will decrease its payoff from -5 to -10. So no player can unilaterally deviate from (Fink, Fink). Thus, (Fink, Fink) is the Nash equilibrium of the Prisoner’s Dilemma.

Prisoners_Dilemma

The first concern is whether every game has a Nash equilibrium. The answer is yes, but not necessarily in pure strategies. A pure strategy is the selection of a single strategy from the set S_{i} which player i always uses. The Nash equilibrium of (Fink, Fink) is the pure strategy Nash equilibrium for the Prisoner’s Dilemma. Nash equilibria are guaranteed to exist in mixed strategies, which will be introduced later. Additionally, we note that in a symmetric game (that is, a game where each player has the same strategy set and utility function), there exists a Nash equilibrium where each player selects the same strategy. The equilibrium of (Fink, Fink) in the Prisoner’s Dilemma is actually a symmetric Nash equilibrium.

The problem of computing Nash equilibria is difficult. Formally, it is a complete problem for the complexity class PPAD. This means that given an arbitrary game, there is (believed to be) no efficient procedure to compute a Nash equilibrium for an arbitrary game. Additionally, a game may have multiple Nash equilibria. Enumerating all such equilibria as well as selecting the most realistic equilibria are both difficult problems of interest. We examine two strategies to help compute pure strategies Nash equilibria: leveraging games with continuous strategy sets and the elimination of dominated strategies.

III.A Leveraging Continuity. Recall Example 2, the Cournot Duopoly. Each player’s strategy set is \mathbb{R}_{+}, an amount to produce. Furthermore, each player has the same utility function, so this game is symmetric. Therefore, we solve for a symmetric Nash equilibrium. Each player seeks to solve \max_{q_{i}} u_{i}(q_{1}, q_{2}) = (a-c)q_{i} - b(q_{1} + q_{2})q_{i}. We consider the first partial derivative of u_{i} with respect to q_{i}, as player i cannot vary q_{-i}, and set it to 0 to identify potential maximizers: a - c = 2bq_{i} + bq_{-i}. Solving for q_{i} yields:

q_{i} = \dfrac{a-c}{2b} - \dfrac{q_{-i}}{2}

As this game is symmetric, there exists a Nash equilibrium where each player selects the same strategy. So we set: q_{i} = q_{-i} and solve:

q_{-i} = \dfrac{a-c}{2b} - \dfrac{q_{-i}}{2} \implies q_{-i} = \dfrac{a-c}{3b}

Note that if q_{-i} \geq \dfrac{a-c}{b}, then q_{i} = 0 is player i‘s best response.

III.B Elimination of Dominated Strategies. Recall the approach in reasoning the Nash equilibrium for the Prisoner’s Dilemma. Checking each strategy profile to determine if it is a Nash equilibrium is tedious. We prove a simple lemma, upon which the approach of eliminating dominated strategies is based.

Lemma 3.1: Let i \in N. Suppose s, t \in S_{i}. If s strictly dominates t, then i will not play t in any Nash equilibrium.

Proof: If s strictly dominates t, then u_{i}(s, s_{-i}) > u_{i}(t, s_{-i}) for every s_{-i} \in S_{-i}. If i plays t, then i can unilaterally deviate and choose s instead. So i will never play t in a Nash equilibrium.

The procedure below is the same regardless if attention is restricted to strictly dominated strategies or weakly dominated strategies. Note that Lemma 3.1 is not a necessary condition of weakly dominated strategies. However, a Nash Equilibrium found in a game produced from eliminating weakly dominated strategies is also a Nash Equilibrium in the original game. This will be proven later. Let’s begin by examining the procedures.

Iterated Elimination of Strictly (Weakly) Dominated Strategies: The procedure begins by accepting a game \Gamma where each player’s strategy set is finite. While there is a player x \in N with strategies x_{1}, x_{2} \in S_{x} such that x_{1} strictly (weakly) dominates x_{2}, set S_{x} := S_{x} \setminus \{x_{2}\}. Consider \Gamma with the updated S_{x} at the next iteration of the procedure.

We apply the Iterated Elimination of Strictly Dominated Strategies to the Prisoner’s Dilemma, eliminating Quiet for the two respective players. This yields the sole strategy profile (Fink, Fink), which we recognize as the Nash Equilibrium for the game.

Now let’s apply the Iterated Elimination of Weakly Dominated Strategies to the game given by the following payoff matrix. Observe first this game has three Nash equilibria: (T, L), (B, L), and (B, R).

Elimination1

Observe that Player 1 does not have a dominant strategy in this game. However, L dominates both C and R for Player 2. We remove R from Player 2‘s strategy set and consider the reduced game:

Elimination2

In this new game, T dominates B for Player 1. So we eliminate B to obtain the following game:

Elimination3

Player 2 will play L in this new game, yielding the Nash equilibrium (T, L).

The Elimination of Weakly Dominated Strategies suffers from the fact that the order in which strategies are eliminated may result in a different Nash Equilibrium. This is due to the fact that weak dominance only requires one strict inequality, while strict dominance requires all strict inequalities. Consider again the above game:

Elimination1

If we instead eliminated M first from Player 2‘s strategy set initially, we would eliminate T from Player 1‘s strategy set at the next iteration. This would result in finding the Nash equilibrium (B, L). By exhaustion, it is possible to verify that the Nash equilibrium (B, R) cannot be found by eliminating weakly dominated strategies.

These algorithms do not always yield pure strategies equilibria, but they do reduce the search spaces considerably. Eliminating a strictly dominated strategy preserves all Nash equilibria in a game. We have already seen that this is not the case when eliminating weakly dominated strategies. However, in a game derived from eliminating a weakly dominated strategy has a Nash equilibrium, which is also a Nash equilibrium in the original game. Let’s prove these results formally.

I begin with the following Lemma:

Lemma 3.2: Let \Gamma be a finite game and let \Gamma^{\prime} be the game produced by eliminating a strictly dominated strategy in \Gamma. Then \Gamma and \Gamma^{\prime} have the same set of Nash equilibria.

Proof: Let \Gamma be a game and suppose the strategy s_{j} is eliminated from player j‘s strategy set by the algorithm. Let \Gamma^{\prime} be the resulting game. Let s^{*} be a Nash equilibrium for \Gamma^{\prime}. Player j cannot unilaterally deviate in \Gamma^{\prime} and improve its outcome. As s_{j} is strictly dominated, player j will not deviate to s_{j} in \Gamma. As every player k \in N \setminus \{j\} has the same strategy set in \Gamma and \Gamma^{\prime}, no other player can unilaterally deviate and improve its outcome. It follows that s^{*} is a Nash equilibrium of \Gamma.

Conversely, suppose q^{*} is a Nash equilibrium of \Gamma. By Lemma 3.1, s_{j} does not appear in any Nash equilibrium of \Gamma. It follows immediately that q^{*} is a Nash equilibrium of \Gamma^{\prime}.

It follows that \Gamma and \Gamma^{\prime} have the same set of Nash equilibria. QED.

Theorem 3.1: Let \Gamma_{0} be a finite game. Let \Gamma_{1}, ..., \Gamma_{k} be the sequence of games produced by the Iterated Elimination of Strictly Dominated Strategies. For every i \in \{0, ..., k-1\}, \Gamma_{i} and \Gamma_{i+1} have the same set of Nash equilibria.

Proof: Theorem 3.1 follows immediately by applying induction and Lemma 3.2.

Lemma 3.3: Let \Gamma be a game and let \Gamma^{\prime} be the game produced by eliminating a weakly dominated strategy in \Gamma. Then every Nash equilibrium in \Gamma^{\prime} is also a Nash equilibrium in \Gamma.

As \Gamma^{\prime} is a finite game, it has a Nash equilibrium. Suppose that s_{i} was eliminated from player i‘s strategy set in the construction of \Gamma^{\prime}. Suppose to the contrary that there exists a Nash equilibrium s^{*} of \Gamma^{\prime} that is not a Nash equilibrium of \Gamma. As deviating from s^{*} in \Gamma and \Gamma^{\prime} is equivalent for -i, only player i can unilaterally deviate and improve its outcome. The only such option is for i to deviate in \Gamma is s_{i}, contradicting the assumption that s_{i} was eliminated as a weakly dominant strategy. QED.

Applying induction and Lemma 3.3 immediately implies the correctness of the Iterated Elimination of Weakly Dominated Strategies.

IV. Conclusion
In this tutorial, the normal form game was introduced. In addition, the Nash equilibrium was defined and we explored ways to compute pure strategies Nash equilibria. The next tutorial will explore the role of mixed strategies.

Dijkstra’s Algorithm

I. Introduction
This tutorial will introduce Dijkstra’s algorithm, including a proof of correctness and time complexity analysis.

Dijkstra’s algorithm is used to find the shortest path between two vertices of a graph. More formally, we fix a starting vertex in the graph, vertex a. Dijkstra’s algorithm then returns the shortest path from vertex a to every other vertex in the graph. We assume the graph is weighted and has no negative weights.

II. Breadth-First Traversal
Dijkstra’s algorithm is an adaptation of the breadth-first traversal algorithm. So it is important to first understand the breadth-first traversal (BFS) algorithm. The BFS algorithm accepts a graph G(V, E) and initial vertex a \in V. The algorithm then manages a queue, which dictates the order to visit the vertices. It then visits each of a‘s neighbors, pushing them onto the queue as they are visited. Then as long as the queue is non-empty, we poll a vertex, mark it as visited, and add all of its unvisited neighbors to the queue.

Let’s consider an example. Given the graph below and the starting vertex 1, we examine the order in which the vertices are visited. While you can choose to visit neighbor vertices in any order, I will visit them from lowest label to highest label.
BFS_Sample

Start at the initial vertex 1 and mark it as visited. Now we visit each neighbor in the order 2, 3, 7, mark them as visited, and push each onto the queue respectively. So the queue is now: Q = [2, 3, 7].

Next, we poll 2 from the queue, leaving Q = [3, 7]. We have that 2‘s neighbors are 1, 3, 7, all of which have been visited. So we do nothing. Next, poll 3 from the queue. We push its unvisited neighbors- 4, 5, 6 onto the queue, marking them as visited along the way. This leaves Q = [7, 4, 5, 6].

Notice now that the vertices in Q have no unvisited neighbors in the graph. So the order the vertices are visited by the algorithm is: 1, 2, 3, 7, 4, 5, 6.

III. Dijkstra’s Algorithm
Dijkstra’s Algorithm works similarly as the BFS algorithm. We begin with a weighted graph G(V, E, W) where W is the weight function W : E \to \mathbb{R}^{+}, as well as an initial vertex a \in V. That is, each edge has a non-negative weight. With each vertex, we associate a distance marker which denotes the distance from a, as well as the predecessor in the shortest path found by the algorithm. This allows us to not only find the distance of the shortest a-v path for any vertex v \in V, but to explicitly access the path as well.

We begin by starting at a, and marking every other vertex as having distance infinity from a. We visit each neighbor v of a and: first set v‘s distance marker to W(a, v) then v‘s predecessor to a. Then, we push vertex adjacent to a onto a priority queue. The priority queue orders vertices by their distance markers. Finally, we mark the initial vertex as visited. No marked vertex can be used in future iterations.

Now, while the priority queue still has elements, we do the following. First, poll a vertex v from the priority queue. For each unmarked neighbor x of v, we check if \text{dist}(a, v) + W(v, x) < \text{dist}(a, x). If this condition is satisfied, we update x‘s distance marker to \text{dist}(a, v) + W(v, x). Next, we update x‘s predecessor to v, then update x‘s position in the priority queue.

After visiting all of v‘s neighbors, we mark v as visited.

Let’s work through an example. Consider the following graph, and suppose we want vertex A as the root.

Dijkstra_Graph

We start by setting \text{dist}(A, B) = 6, \text{dist}(A, D) = 1. Then we set B‘s and D‘s predecessor to A. Next, we push B and D into the priority queue, which is ordered: [D, B]. Finally, we mark A as visited.

Now poll D from the priority queue. We note \text{dist}(A, D) + W(D, B) = 3  \text{dist}(A, B), so we discard (E, B). Now consider (A, C). Since \text{dist}(A, E) + W(E, C) = 7  \text{dist}(A, C), we discard (B, C). We mark B as visited. The priority queue now contains [C] and no other vertices are unvisited. After polling C, the algorithm terminates.

The lengths of the shortest paths are as follows:

  • \text{dist}(A, B) = 3
  • \text{dist}(A, C) = 7
  • \text{dist}(A, D) = 1
  • \text{dist}(A, E) = 2

Now let’s examine an implementation. We design the Dijkstra’s class to accept a Graph and construct a shortest-path tree. We use HashMaps to store the predecessor of each vertex in the shortest paths, and to store the distances from the initial vertex to every other vertex in the graph.

We begin by visiting each of initialVertex’s neighbors, updating their distances from initialVertex, and pushing them onto the PriorityQueue. We then mark initialVertex as visited and proceed with the rest of the algorithm. The processGraph() method handles the remainder of the algorithm. It polls the first vertex from the PriorityQueue and updates the distances as necessary to each of its unvisited neighbors. It then removes and re-adds any updated neighbors to the PriorityQueue to update their positions. In this way, the unvisited vertex with the smallest distance from initialVertex is polled from the PriorityQueue.

The getPathTo() and getDistanceTo() methods return the path and distance respectively from initialVertex to a chosen vertex in the graph. The getPathTo() method starts at the target vertex and traces the predecessors back to initialVertex.

import java.util.*;

/**
 * 
 * @author Michael Levet
 */
public class Dijkstra {
    
    private Graph graph;
    private String initialVertexLabel;
    private HashMap<String, String> predecessors;
    private HashMap<String, Integer> distances; 
    private PriorityQueue<Vertex> availableVertices;
    private HashSet<Vertex> visitedVertices; 
    
    
    /**
     * This constructor initializes this Dijkstra object and executes
     * Dijkstra's algorithm on the graph given the specified initialVertexLabel.
     * After the algorithm terminates, the shortest a-b paths and the corresponding
     * distances will be available for all vertices b in the graph.
     * 
     * @param graph The Graph to traverse
     * @param initialVertexLabel The starting Vertex label
     * @throws IllegalArgumentException If the specified initial vertex is not in the Graph
     */
    public Dijkstra(Graph graph, String initialVertexLabel){
        this.graph = graph;
        Set<String> vertexKeys = this.graph.vertexKeys();
        
        if(!vertexKeys.contains(initialVertexLabel)){
            throw new IllegalArgumentException("The graph must contain the initial vertex.");
        }
        
        this.initialVertexLabel = initialVertexLabel;
        this.predecessors = new HashMap<String, String>();
        this.distances = new HashMap<String, Integer>();
        this.availableVertices = new PriorityQueue<Vertex>(vertexKeys.size(), new Comparator<Vertex>(){
            
            public int compare(Vertex one, Vertex two){
                int weightOne = Dijkstra.this.distances.get(one.getLabel());
                int weightTwo = Dijkstra.this.distances.get(two.getLabel());
                return weightOne - weightTwo;
            }
        });
        
        this.visitedVertices = new HashSet<Vertex>();
        
        //for each Vertex in the graph
        //assume it has distance infinity denoted by Integer.MAX_VALUE
        for(String key: vertexKeys){
            this.predecessors.put(key, null);
            this.distances.put(key, Integer.MAX_VALUE);
        }
        
        
        //the distance from the initial vertex to itself is 0
        this.distances.put(initialVertexLabel, 0);
        
        //and seed initialVertex's neighbors
        Vertex initialVertex = this.graph.getVertex(initialVertexLabel);
        ArrayList<Edge> initialVertexNeighbors = initialVertex.getNeighbors();
        for(Edge e : initialVertexNeighbors){
            Vertex other = e.getNeighbor(initialVertex);
            this.predecessors.put(other.getLabel(), initialVertexLabel);
            this.distances.put(other.getLabel(), e.getWeight());
            this.availableVertices.add(other);
        }
        
        this.visitedVertices.add(initialVertex);
        
        //now apply Dijkstra's algorithm to the Graph
        processGraph();
        
    }
    
    /**
     * This method applies Dijkstra's algorithm to the graph using the Vertex
     * specified by initialVertexLabel as the starting point.
     * 
     * @post The shortest a-b paths as specified by Dijkstra's algorithm and 
     *       their distances are available 
     */
    private void processGraph(){
        
        //as long as there are Edges to process
        while(this.availableVertices.size() > 0){
            
            //pick the cheapest vertex
            Vertex next = this.availableVertices.poll();
            int distanceToNext = this.distances.get(next.getLabel());
            
            //and for each available neighbor of the chosen vertex
            List<Edge> nextNeighbors = next.getNeighbors();     
            for(Edge e: nextNeighbors){
                Vertex other = e.getNeighbor(next);
                if(this.visitedVertices.contains(other)){
                    continue;
                }
                
                //we check if a shorter path exists
                //and update to indicate a new shortest found path
                //in the graph
                int currentWeight = this.distances.get(other.getLabel());
                int newWeight = distanceToNext + e.getWeight();
                
                if(newWeight < currentWeight){
                    this.predecessors.put(other.getLabel(), next.getLabel());
                    this.distances.put(other.getLabel(), newWeight);
                    this.availableVertices.remove(other);
                    this.availableVertices.add(other);
                }
                
            }
            
            // finally, mark the selected vertex as visited 
            // so we don't revisit it
            this.visitedVertices.add(next);
        }
    }
    
    
    /**
     * 
     * @param destinationLabel The Vertex whose shortest path from the initial Vertex is desired
     * @return LinkedList<Vertex> A sequence of Vertex objects starting at the 
     *         initial Vertex and terminating at the Vertex specified by destinationLabel.
     *         The path is the shortest path specified by Dijkstra's algorithm.
     */
    public List<Vertex> getPathTo(String destinationLabel){
        LinkedList<Vertex> path = new LinkedList<Vertex>();
        path.add(graph.getVertex(destinationLabel));
        
        while(!destinationLabel.equals(this.initialVertexLabel)){
            Vertex predecessor = graph.getVertex(this.predecessors.get(destinationLabel));
            destinationLabel = predecessor.getLabel();
            path.add(0, predecessor);
        }
        return path;
    }
    
    
    /**
     * 
     * @param destinationLabel The Vertex to determine the distance from the initial Vertex
     * @return int The distance from the initial Vertex to the Vertex specified by destinationLabel
     */
    public int getDistanceTo(String destinationLabel){
        return this.distances.get(destinationLabel);
    }
    
    
    public static void main(String[] args){
        Graph graph = new Graph();
        Vertex[] vertices = new Vertex[6];
        
        for(int i = 0; i < vertices.length; i++){
            vertices[i] = new Vertex(i + "");
            graph.addVertex(vertices[i], true);
        }
        
        Edge[] edges = new Edge[9];
        edges[0] = new Edge(vertices[0], vertices[1], 7);
        edges[1] = new Edge(vertices[0], vertices[2], 9);
        edges[2] = new Edge(vertices[0], vertices[5], 14);
        edges[3] = new Edge(vertices[1], vertices[2], 10);
        edges[4] = new Edge(vertices[1], vertices[3], 15);
        edges[5] = new Edge(vertices[2], vertices[3], 11);
        edges[6] = new Edge(vertices[2], vertices[5], 2);
        edges[7] = new Edge(vertices[3], vertices[4], 6);
        edges[8] = new Edge(vertices[4], vertices[5], 9);
        
        for(Edge e: edges){
            graph.addEdge(e.getOne(), e.getTwo(), e.getWeight());
        }
        
        Dijkstra dijkstra = new Dijkstra(graph, vertices[0].getLabel());
        System.out.println(dijkstra.getDistanceTo("5"));
        System.out.println(dijkstra.getPathTo("5"));
    }
}

And my graph implementation:

Vertex.java

import java.util.ArrayList;

/**
 * This class models a vertex in a graph. For ease of 
 * the reader, a label for this vertex is required. 
 * Note that the Graph object only accepts one Vertex per label,
 * so uniqueness of labels is important. This vertex's neighborhood
 * is described by the Edges incident to it. 
 * 
 * @author Michael Levet
 * @date June 09, 2015
 */
public class Vertex {

    private ArrayList<Edge> neighborhood;
    private String label;
    
    /**
     * 
     * @param label The unique label associated with this Vertex
     */
    public Vertex(String label){
        this.label = label;
        this.neighborhood = new ArrayList<Edge>();
    }
    
    
    /**
     * This method adds an Edge to the incidence neighborhood of this graph iff
     * the edge is not already present. 
     * 
     * @param edge The edge to add
     */
    public void addNeighbor(Edge edge){
        if(this.neighborhood.contains(edge)){
            return;
        }
        
        this.neighborhood.add(edge);
    }
    
    
    /**
     * 
     * @param other The edge for which to search
     * @return true iff other is contained in this.neighborhood
     */
    public boolean containsNeighbor(Edge other){
        return this.neighborhood.contains(other);
    }
    
    /**
     * 
     * @param index The index of the Edge to retrieve
     * @return Edge The Edge at the specified index in this.neighborhood
     */
    public Edge getNeighbor(int index){
        return this.neighborhood.get(index);
    }
    
    
    /**
     * 
     * @param index The index of the edge to remove from this.neighborhood
     * @return Edge The removed Edge
     */
    Edge removeNeighbor(int index){
        return this.neighborhood.remove(index);
    }
    
    /**
     * 
     * @param e The Edge to remove from this.neighborhood
     */
    public void removeNeighbor(Edge e){
        this.neighborhood.remove(e);
    }
    
    
    /**
     * 
     * @return int The number of neighbors of this Vertex
     */
    public int getNeighborCount(){
        return this.neighborhood.size();
    }
    
    
    /**
     * 
     * @return String The label of this Vertex
     */
    public String getLabel(){
        return this.label;
    }
    
    
    /**
     * 
     * @return String A String representation of this Vertex
     */
    public String toString(){
        return "Vertex " + label;
    }
    
    /**
     * 
     * @return The hash code of this Vertex's label
     */
    public int hashCode(){
        return this.label.hashCode();
    }
    
    /**
     * 
     * @param other The object to compare
     * @return true iff other instanceof Vertex and the two Vertex objects have the same label
     */
    public boolean equals(Object other){
        if(!(other instanceof Vertex)){
            return false;
        }
        
        Vertex v = (Vertex)other;
        return this.label.equals(v.label);
    }
    
    /**
     * 
     * @return ArrayList<Edge> A copy of this.neighborhood. Modifying the returned
     * ArrayList will not affect the neighborhood of this Vertex
     */
    public ArrayList<Edge> getNeighbors(){
        return new ArrayList<Edge>(this.neighborhood);
    }
    
}

Edge.java

/**
 * This class models an undirected Edge in the Graph implementation.
 * An Edge contains two vertices and a weight. If no weight is
 * specified, the default is a weight of 1. This is so traversing
 * edges is assumed to be of greater distance or cost than staying
 * at the given vertex.
 * 
 * This class also deviates from the expectations of the Comparable interface
 * in that a return value of 0 does not indicate that this.equals(other). The
 * equals() method only compares the vertices, while the compareTo() method 
 * compares the edge weights. This provides more efficient implementation for
 * checking uniqueness of edges, as well as the fact that two edges of equal weight
 * should be considered equitably in a pathfinding or spanning tree algorithm.
 * 
 * @author Michael Levet
 * @date June 09, 2015
 */
public class Edge implements Comparable<Edge> {

    private Vertex one, two;
    private int weight;
    
    /**
     * 
     * @param one The first vertex in the Edge
     * @param two The second vertex in the Edge
     */
    public Edge(Vertex one, Vertex two){
        this(one, two, 1);
    }
    
    /**
     * 
     * @param one The first vertex in the Edge
     * @param two The second vertex of the Edge
     * @param weight The weight of this Edge
     */
    public Edge(Vertex one, Vertex two, int weight){
        this.one = (one.getLabel().compareTo(two.getLabel()) <= 0) ? one : two;
        this.two = (this.one == one) ? two : one;
        this.weight = weight;
    }
    
    
    /**
     * 
     * @param current
     * @return The neighbor of current along this Edge
     */
    public Vertex getNeighbor(Vertex current){
        if(!(current.equals(one) || current.equals(two))){
            return null;
        }
        
        return (current.equals(one)) ? two : one;
    }
    
    /**
     * 
     * @return Vertex this.one
     */
    public Vertex getOne(){
        return this.one;
    }
    
    /**
     * 
     * @return Vertex this.two
     */
    public Vertex getTwo(){
        return this.two;
    }
    
    
    /**
     * 
     * @return int The weight of this Edge
     */
    public int getWeight(){
        return this.weight;
    }
    
    
    /**
     * 
     * @param weight The new weight of this Edge
     */
    public void setWeight(int weight){
        this.weight = weight;
    }
    
    
    /**
     * Note that the compareTo() method deviates from 
     * the specifications in the Comparable interface. A 
     * return value of 0 does not indicate that this.equals(other).
     * The equals() method checks the Vertex endpoints, while the 
     * compareTo() is used to compare Edge weights
     * 
     * @param other The Edge to compare against this
     * @return int this.weight - other.weight
     */
    public int compareTo(Edge other){
        return this.weight - other.weight;
    }
    
    /**
     * 
     * @return String A String representation of this Edge
     */
    public String toString(){
        return "({" + one + ", " + two + "}, " + weight + ")";
    }
    
    /**
     * 
     * @return int The hash code for this Edge 
     */
    public int hashCode(){
        return (one.getLabel() + two.getLabel()).hashCode(); 
    }
    
    /**
     * 
     * @param other The Object to compare against this
     * @return ture iff other is an Edge with the same Vertices as this
     */
    public boolean equals(Object other){
        if(!(other instanceof Edge)){
            return false;
        }
        
        Edge e = (Edge)other;
        
        return e.one.equals(this.one) && e.two.equals(this.two);
    }   
}

Graph.java

import java.util.*;

/**
 * This class models a simple, undirected graph using an 
 * incidence list representation. Vertices are identified 
 * uniquely by their labels, and only unique vertices are allowed.
 * At most one Edge per vertex pair is allowed in this Graph.
 * 
 * Note that the Graph is designed to manage the Edges. You
 * should not attempt to manually add Edges yourself.
 * 
 * @author Michael Levet
 * @date June 09, 2015
 */
public class Graph {
    
    private HashMap<String, Vertex> vertices;
    private HashMap<Integer, Edge> edges;
    
    public Graph(){
        this.vertices = new HashMap<String, Vertex>();
        this.edges = new HashMap<Integer, Edge>();
    }
    
    /**
     * This constructor accepts an ArrayList<Vertex> and populates
     * this.vertices. If multiple Vertex objects have the same label,
     * then the last Vertex with the given label is used. 
     * 
     * @param vertices The initial Vertices to populate this Graph
     */
    public Graph(ArrayList<Vertex> vertices){
        this.vertices = new HashMap<String, Vertex>();
        this.edges = new HashMap<Integer, Edge>();
        
        for(Vertex v: vertices){
            this.vertices.put(v.getLabel(), v);
        }
        
    }
    
    /**
     * This method adds am edge between Vertices one and two
     * of weight 1, if no Edge between these Vertices already
     * exists in the Graph.
     * 
     * @param one The first vertex to add
     * @param two The second vertex to add
     * @return true iff no Edge relating one and two exists in the Graph
     */
    public boolean addEdge(Vertex one, Vertex two){
        return addEdge(one, two, 1);
    }
    
    
    /**
     * Accepts two vertices and a weight, and adds the edge 
     * ({one, two}, weight) iff no Edge relating one and two 
     * exists in the Graph.
     * 
     * @param one The first Vertex of the Edge
     * @param two The second Vertex of the Edge
     * @param weight The weight of the Edge
     * @return true iff no Edge already exists in the Graph
     */
    public boolean addEdge(Vertex one, Vertex two, int weight){
        if(one.equals(two)){
            return false;   
        }
       
        //ensures the Edge is not in the Graph
        Edge e = new Edge(one, two, weight);
        if(edges.containsKey(e.hashCode())){
            return false;
        }
       
        //and that the Edge isn't already incident to one of the vertices
        else if(one.containsNeighbor(e) || two.containsNeighbor(e)){
            return false;
        }
            
        edges.put(e.hashCode(), e);
        one.addNeighbor(e);
        two.addNeighbor(e);
        return true;
    }
    
    /**
     * 
     * @param e The Edge to look up
     * @return true iff this Graph contains the Edge e
     */
    public boolean containsEdge(Edge e){
        if(e.getOne() == null || e.getTwo() == null){
            return false;
        }
        
        return this.edges.containsKey(e.hashCode());
    }
    
    
    /**
     * This method removes the specified Edge from the Graph,
     * including as each vertex's incidence neighborhood.
     * 
     * @param e The Edge to remove from the Graph
     * @return Edge The Edge removed from the Graph
     */
    public Edge removeEdge(Edge e){
       e.getOne().removeNeighbor(e);
       e.getTwo().removeNeighbor(e);
       return this.edges.remove(e.hashCode());
    }
    
    /**
     * 
     * @param vertex The Vertex to look up
     * @return true iff this Graph contains vertex
     */
    public boolean containsVertex(Vertex vertex){
        return this.vertices.get(vertex.getLabel()) != null;
    }
    
    /**
     * 
     * @param label The specified Vertex label
     * @return Vertex The Vertex with the specified label
     */
    public Vertex getVertex(String label){
        return vertices.get(label);
    }
    
    /**
     * This method adds a Vertex to the graph. If a Vertex with the same label
     * as the parameter exists in the Graph, the existing Vertex is overwritten
     * only if overwriteExisting is true. If the existing Vertex is overwritten,
     * the Edges incident to it are all removed from the Graph.
     * 
     * @param vertex
     * @param overwriteExisting
     * @return true iff vertex was added to the Graph
     */
    public boolean addVertex(Vertex vertex, boolean overwriteExisting){
        Vertex current = this.vertices.get(vertex.getLabel());
        if(current != null){
            if(!overwriteExisting){
                return false;
            }
            
            while(current.getNeighborCount() > 0){
                this.removeEdge(current.getNeighbor(0));
            }
        }
        
        
        vertices.put(vertex.getLabel(), vertex);
        return true;
    }
    
    /**
     * 
     * @param label The label of the Vertex to remove
     * @return Vertex The removed Vertex object
     */
    public Vertex removeVertex(String label){
        Vertex v = vertices.remove(label);
        
        while(v.getNeighborCount() > 0){
            this.removeEdge(v.getNeighbor((0)));
        }
        
        return v;
    }
    
    /**
     * 
     * @return Set<String> The unique labels of the Graph's Vertex objects
     */
    public Set<String> vertexKeys(){
        return this.vertices.keySet();
    }
    
    /**
     * 
     * @return Set<Edge> The Edges of this graph
     */
    public Set<Edge> getEdges(){
        return new HashSet<Edge>(this.edges.values());
    }
    
}

IV. Analysis of Dijkstra’s Algorithm
In this section, we analyze the correctness and complexity of Dijkstra’s Algorithm. The design of this algorithm leverages the optimal substructure exhibited by the shortest path problem. Formally, a problem is said to exhibit the optimal substructure property if an optimal solution contains within it solutions to the present optimal subproblems. We prove this formally.

Claim 1: Let G be a connected graph and let x, y \in V. Let P be a shortest x-y path. Then for any pair of vertices a, b \in P, it follows that P contains a shortest a-b path.

Proof: Suppose to the contrary. Let P be a shortest x-y path such that for vertices a, b \in P, that the a-b sub-path in P is not a shortest a-b path. Let Q be a shortest a-b path. We replace the a-b sub-path in P with Q to obtain an x-y path shorter than P, a contradiction.

Any proof of correctness for Dijkstra’s Algorithm leverages the optimal substructure problem. The main idea is this: when the algorithm marks a vertex v as visited, v‘s distance marker is the length of any shortest path from the initial vertex to v.

Before proving Dijkstra’s algorithm, define d : V \times V \to \mathbb{R}^{+} be the shortest path metric on the graph. That is, for any pair of vertices x and y in the graph, d(x, y) is the length of any shortest x-y path.

Theorem 1: Let G be a connected graph. Dijkstra’s algorithm terminates. Let v be the initial vertex used by the algorithm. Upon termination, the distance \text{dist}(v, y) computed by the algorithm is equal to d(v, y) for every vertex y \in G.

We begin by showing the algorithm terminates.

Claim 2: Dijkstra’s algorithm terminates.

Proof: Suppose to the contrary that the algorithm does not terminate. Then the priority queue always has an element. This implies that there is always some unvisited vertex in the graph added to the priority queue after polling a vertex from the priority queue. This contradicts the assumption that the graph is finite. QED.

Claim 3: Upon termination, the distance \text{dist}(v, y) computed by the algorithm is equal to d(v, y) for every vertex y \in G.

Proof: The proof is by induction on the number of vertices polled from the priority queue. When no elements have been polled from the priority queue, we have correctly computed \text{dist}(v, v) = d(v, v) = 0. Suppose the claim holds true for the first k-1 elements polled from the priority queue. Let x be the kth vertex polled from the priority queue.

Suppose that \text{dist}(v, x) > d(v, x). By the algorithm, \text{dist}(v, x) is computed using only the previous k marked vertices (the previously polled k-1 vertices and the initial vertex v). Then an unmarked vertex w must be present in any shortest path from v to x. Let P be the v-x path computed by the algorithm. Let P^{\prime} be a shortest x-v path containing w. Without loss of generality, suppose w is the first unmarked vertex in P^{\prime}. By Claim 1, the v-w sub-path in P^{\prime} is a shortest v-w path. It is necessary that d(v, w) \leq d(v, x) since w is along a shortest v-x path. It follows that w‘s predecessor would have visited w and pushed it onto the priority queue. So w would have been polled from the priority queue before x, a contradiction.

It follows that the algorithm correctly computes the lengths of the shortest v-y paths for all vertices y \in G. QED.

Theorem 2: Dijkstra’s Algorithm runs in \mathcal{O}(E \text{ log } V) time, where E is the number of edges and V is the number of vertices in the graph.

Proof: Suppose we use a heap where the key can be updated as the priority queue. Polling the vertex with the smallest distance marker from the heap takes \mathcal{O}(\text{log } V) time. For each polled vertex, we must evaluate all of its neighbors. While a vertex can have at most V-1 neighbors, there are E total neighbors to be considered. When evaluating a vertex’s neighbor, updating the distance takes \mathcal{O}(1) time. However, updating the vertex’s position in the heap takes \mathcal{O}(\text{log } V) time. So the runtime is \mathcal{O}(V \text{ log } V + E \text{ log } V). Since V \in \mathcal{O}(E) in the case of a connected graph, we have the runtime is \mathcal{O}(E \text{ log } V). QED.

Auction Theory- Revenue Equivalence Theorem

I. Introduction
This blog entry introduces the Revenue Equivalence Theorem and its applications. The Revenue Equivalence Theorem is one of the most celebrated results in auction theory and mechanism design. Recall from my previous blog entry that the auctioneer expects the same revenue when comparing the symmetric first and second price auctions, where the players’ distributions are drawn from continuous probability distribution. The natural question arises regarding when two auction formats yield the same expected revenue for the auctioneer. The Revenue Equivalence Theorem provides conditions to answer this question. This theorem’s power extends beyond determining the seller’s expected revenue in symmetric auctions. It also enables us to derive symmetric equilibrium bidding strategies in auctions where both the number of bidders is known and uncertain. In many cases, applying the Revenue Equivalence Theorem provides a simpler approach to derive the symmetric equilibrium bidding function in comparison to solving the optimization problem.

II. Revenue Equivalence Theorem
In this section, we introduce and prove the Revenue Equivalence Theorem. Let’s begin by defining the class of auctions which are revenue equivalent. These auctions are referred to as standard auctions.

Standard Auction: Considerf a n \in \mathbb{N} bidder auction and fix k \in \mathbb{N} with k \leq n. The auction is standard if the k highest bidders are all awarded an item.

The auctions discussed in my previous blog entries, such as the first-price and second-price auctions, are all standard auctions with k = 1. That is, only the highest bidder wins an item.

The Revenue Equivalence Theorem will now be introduced.

Theorem 1 (Revenue Equivalence Theorem): Let A be a standard auction, and suppose each player’s valuations are independent and identically distributed according to a continuous probability distribution F(\cdot). Suppose each player is risk neutral. Then any symmetric and increasing equilibrium bidding strategy \beta, such that the expected payment of a bidder with valuation 0 is 0, yields the same expected revenue for the seller.

Proof: Let A be a standard auction. Define X_{i}(v_{i}) to be the random variable describing player i‘s payment given valuation v_{i}. Let \beta be a symmetric and increasing equilibrium bidding strategy such that \mathbb{E}[X_{i}(v_{i})] = 0 for all players i whose valuations v_{i} = 0. Suppose each player j \in -i bids according to \beta(v_{j}). Define G(x) = F^{n-1}(x) as the probability that the highest valuation is x. We have player i‘s expected profit by bidding \beta(z_{i}) for some z_{i} \in [0, \omega] given below. That is, player i bids according to some valuation z_{i}.

\displaystyle \Pi(v_{i}, \beta(z_{i})) = G(z_{i})v_{i} - \mathbb{E}[X_{i}(z_{i})]

Player i seeks to maximize his profit. We consider the first order conditions, differentiating with respect to z_{i}:

\displaystyle \Pi^{\prime}(v_{i}, \beta(z_{i})) = G^{\prime}(z_{i})v_{i} - \dfrac{d}{dz_{i}} \mathbb{E}[X_{i}(z_{i})]

As the joint strategy profile of each bidder k submitting \beta(v_{k}) constitutes a Bayesian Nash Equilibrium, it follows that player i maximizes his profit when submitting z_{i} = v_{i}, or equivocally \beta(z_{i}) = \beta(v_{i}). So we have:

G^{\prime}(v_{i})v_{i} = \dfrac{d}{dv_{i}} \mathbb{E}[X_{i}(v_{i})]

Integrating both sides over the interval [0, v_{i}] yields:

\displaystyle \mathbb{E}[X_{i}(v_{i})] = \mathbb{E}[X_{i}(0)] + \int_{0}^{v_{i}} yG^{\prime}(y)dy

Recall that by assumption \mathbb{E}[X_{i}(0)] = 0. Note as well that:

\displaystyle \mathbb{E}[G(x) | x < v] = \dfrac{1}{G(v)} \int_{0}^{v} yG^{\prime}(y)dy

Thus,

\displaystyle \mathbb{E}[X_{i}(v_{i})] = \int_{0}^{v_{i}} yG^{\prime}(y)dy = G(v_{i}) \cdot \mathbb{E}[G(x) | x < v_{i}]

Observe that the final result does not depend on the particular auction. Revenue equivalence follows. QED.

Let’s now apply the Revenue Equivalence Theorem to determine the seller’s expected revenue.

Example: Consider a standard auction with n bidders whose valuations are independent and identically distributed according to the uniform distribution over [0, 1]. That is, the density function is F(x) = x. We have by the Revenue Equivalence Theorem that the expected payment of a bidder with valuation v_{i} is:

\displaystyle \mathbb{E}[X_{i}(v_{i})] = \int_{0}^{v_{i}} y G^{\prime}(y) dy = (n-1) \cdot \int_{0}^{v_{i}} y \cdot y^{n-2} dy = \dfrac{n-1}{n} \cdot v_{i}^{n}

As the seller does not know each player’s valuations, the seller calculates the expected value for each possible v_{i} \in [0, 1]. That is, given the winner, we calculate how much the seller expects to receive from this bidder. This yields:

\displaystyle \mathbb{E}[X_{i}] = \int_{0}^{1} \mathbb{E}[X_{i}(v_{i})] f(v_{i}) dv_{i} = \dfrac{n-1}{n} \int_{0}^{1} v_{i}^{n} dv_{i} = \dfrac{n-1}{n(n+1)}

The last step is to choose the winning bidder. By symmetry, this can be done in \binom{n}{1} = n ways. By rule of product, we multiply this by the expected payment of the winning bidder to get the expected revenue of the seller:

\mathbb{E}[R^{A}] = \dfrac{n-1}{n+1}
III. Applications of Revenue Equivalence Theorem- Fixed Number of Bidders
The Revenue Equivalence Theorem’s power extends beyond testing an auction to determine its expected payoff for the seller and expected payments of the bidders. It can also be used to derive symmetric and increasing equilibrium bidding strategies, both in situations when the number of bidders is known and uncertain. We start with examples of standard, symmetric auctions with a fixed number of bidders.

Example: Consider the symmetric, all-pay auction with n \in \mathbb{N} players. In the all pay auction, each player pays his or her bid regardless of winning the object. Let \beta be the symmetric and increasing equilibrium bidding strategy. Note that a player with value 0 will always pay nothing. By the Revenue Equivalence Theorem, we thus have:

\displaystyle \beta(v_{i}) = G(v_{i}) \cdot \mathbb{E}[G(x) | G(x) < v_{i}] = \int_{0}^{v_{i}} yG^{\prime}(y)dy

In order to appreciate the power of the Revenue Equivalence Theorem, let’s contrast this approach with that of solving the profit maximization problem. Observe that for the all-pay auction, the profit maximization for a given bidder is shown below. The bidder always pays his bid, but receives valuation only with probability G(\beta^{-1}(b_{i})), where \beta^{-1}(b_{i}) is the value associated with bid b_{i}.

\displaystyle \max_{b_{i}} G(\beta^{-1}(b_{i}))v_{i} - b_{i}

We consider the first order conditions:

\dfrac{G^{\prime}(\beta^{-1}(b_{i}))}{ \beta^{\prime}(\beta^{-1}(b_{i}))}v_{i} = 1

In equilibrium, we have v_{i} = \beta^{-1}(b_{i}). Thus, we have:

\beta^{\prime}(v_{i}) = G^{\prime}(v_{i})v_{i}

Integrating both sides over [0, v_{i}], noting \beta(0) = 0, yields:

\displaystyle \beta(v_{i}) = \int_{0}^{v_{i}} y G^{\prime}(y)dy

This is the function given by applying the Revenue Equivalence Theorem.

Example: Consider a 2-player war of attrition game, where the players compete for a prize. Each player stays in the game and incurs a cost associated with the time of play. The game terminates when one player drops out. Equivocally, each player submits a bid and pays the cost of the lowest bid. Lastly, suppose that each player’s valuations are independent and identically distributed according to the density function F(\cdot). We seek to derive the symmetric equilibrium bidding strategy in this game.

We first derive the expected payment for an individual player i. If the player is a winner, he expects to pay the lowest bid. If he loses, then he pays his bid. Let’s first calculate the payment for losing. Player i‘s probability of winning is F(v_{i}). So the probability that his opponent bids higher than v_{i} is given by F(v_{i}). So if player i loses, he expects to pay F(v_{i})\beta(v_{i}).

If player i wins, he expects to pay player j‘s bid. Player j with valuation v_{j} bids \beta(v_{j}. The probability that player j has valuation v_{j} is f(v_{j}). So if player i wins, he expects to pay:

\displaystyle \int_{0}^{v_{i}} \beta(v_{j})f(v_{j})dv_{j}

Noting that:

F(v_{i}) = \displaystyle \int_{0}^{v_{i}} f(v_{i})

So we have:

\mathbb{E}[X_{i}(v_{i})] = \displaystyle \int_{0}^{v_{i}} \beta(v_{j})f(v_{j})dv_{j} + (1 - F(v_{i}))\beta(v_{i})

We next check if the conditions of the Revenue Equivalence Theorem hold. By assumption, both players’ valuations are independent and identically distributed. We also have the item awarded to the highest bidder, and we expect a player with valuation 0 to pay nothing in the symmetric and increasing equilibrium. Lastly, we assume both players are risk neutral. That is, they seek to maximize their expected payoffs. Thus, the hypotheses of the Revenue Equivalence Theorem hold, so we have:

\mathbb{E}[X_{i}(v_{i})] = \displaystyle \int_{0}^{v_{i}} yf(y)dy = \displaystyle \int_{0}^{v_{i}} \beta(v_{j})f(v_{j})dv_{j} + (1 - F(v_{i}))\beta(v_{i})

We differentiate both sides to get:

v_{i}f(v_{i}) = \beta(v_{i})f(v_{i}) + (1 - F(v_{i}))\beta^{\prime}(v_{i}) - f(v_{i})\beta(v_{i}) = (1 - F(v_{i}))\beta^{\prime}(v_{i})

It follows that:

\beta^{\prime}(v_{i}) = \dfrac{v_{i} f(v_{i})}{1 - F(v_{i})}

We integrate both sides over the interval [0, v_{i}], noting that \beta(0) = 0 to get the equilibrium bid function:

\beta(v_{i}) = \displaystyle \int_{0}^{v_{i}} \dfrac{xf(x)}{1 - F(x)} dx
Example: Consider the N-player losers pay auction. In this auction, the bidder with the highest valuation wins the item and pays nothing, while the losing bidders each pay their respective bids. Suppose the bidders’ valuations are independent and identically distributed according to the density function F(\cdot). We seek to derive the equilibrium bidding strategy in this auction.

Our first step is to check that the conditions of the Revenue Equivalence Theorem are satisfied. We assume that bidders are risk neutral. By assumption, bidders’ valuations are independent and identically distributed. The highest bidder wins the auction, and a player with valuation 0 expects to pay 0. Thus, the hypotheses of the Revenue Equivalence Theorem hold, and we have:

\mathbb{E}[X_{i}(v_{i})] = \displaystyle \int_{0}^{v_{i}} yG^{\prime}(y)dy

We note as well that a player’s expected payoff is \mathbb{E}[X_{i}(v_{i})] = Pr[Lose] \cdot \beta(v_{i}). Recall that G(v_{i}) is the probability that v_{i} is the highest valuation. So Pr[Lose] = (1 - G(v_{i})). Thus, we have:

\mathbb{E}[X_{i}(v_{i})] = (1 - G(v_{i})) \cdot \beta(v_{i}) = \displaystyle \int_{0}^{v_{i}} yG^{\prime}(y)dy

It follows that:

\beta(v_{i}) = \dfrac{1}{1 - G(v_{i})} \cdot \displaystyle \int_{0}^{v_{i}} yG^{\prime}(y)dy
IV. Applications of Revenue Equivalence Theorem: Uncertain Number of Bidders
In this section, we examine how to leverage the Revenue Equivalence Theorem to derive a symmetric equilibrium bidding strategy in the case where there is uncertainty about the number of bidders participating in the auction.

We first extend the framework to discuss this model. Consider the set of potential players N = \{ 1, ..., n \}, each of whom have independent and identically distributed valuations given by the density function F(\cdot). Let A \subset N be the set of actual bidders. Define p_{k} as the probability player i \in A assigns to bidding against k opponents. That is, p_{k} denotes the probability player i assigns to there being k+1 participants in the auction.

In order to apply the Revenue Equivalence Theorem, we need each symmetry of the bidders. In order to achieve this, each player’s beliefs about the number of bidders in the auction must be the same. That is, for each k \in N, p_{k} must be the same for each bidder.

We now define G^{k}(v) = F^{k}(v) as the probability that k players all have valuation no more than v. In other words, if there are k+1 players, then G^{k}(v_{i}) is the probability that player i wins. Without knowing the number of bidders a priori, player i‘s probability of winning with valuation v_{i} is simply a weighted sum, considering the probability of having k opponents times the probability of winning with k opponents:

G(v_{i}) = \displaystyle \sum_{k=0}^{n-1} p_{k}G^{k}(v_{i})

We apply this definition of G(\cdot) to obtain player i‘s profit when bidding \beta(z_{i}):

\Pi(v_{i}, \beta(z_{i})) = G(z_{i})v_{i} - \mathbb{E}[X_{i}(v_{i})]

Observe that this is the same formula from the proof of the Revenue Equivalence Theorem. So in the case of multiple bidders, we have:

\displaystyle \mathbb{E}[X_{i}(v_{i})] = \int_{0}^{v_{i}} yG^{\prime}(y)dy = G(v_{i}) \cdot \mathbb{E}[G(x) | x < v_{i}]

Now let’s consider an example.

Example: We seek to determine the symmetric equilibrium bidding strategy in the first-price auction with an uncertain number of players. Suppose instead we have a second price auction. By the Revenue Equivalence Theorem, each bidder has the same expected payment in the two auctions. We begin by calculating this expected payment in the second price auction, which is easier to compute than the expected payment in the first price auction under this framework. Recall that in the second price auction, it is a Nash equilibrium for each player to bid his or her valuation. Thus, consider for a fixed k the probability that player i wins times the expected second highest bid. We then consider for all such k \in \{0, ..., n-1\}. We multiply the expected bid for a fixed k by p_{k}; and by rule of sum, add them up:

\displaystyle \mathbb{E}[X_{i}(v_{i})] = \sum_{k=0}^{n-1} p_{k}G^{k}(v_{i}) \mathbb{E}[G^{k}(x) : x < v_{i}]

Recall from the first price auction that \mathbb{E}[X_{i}(v_{i})] = G(v_{i}) \beta(v_{i}), where \beta is the symmetric equilibrium bidding strategy in the first price auction. In the case where the number of bidders are known to be k, we have by prior result that:

\displaystyle \beta^{k}(v_{i}) = \mathbb{E}[G^{k}(x) : x < v_{i}] = \dfrac{1}{G^{k}(v_{i})} \int_{0}^{v_{i}} y(G^{k}(y))^{\prime} dy

By the Revenue Equivalence Theorem, we have that:

G(v_{i})\beta(v_{i}) = \displaystyle \sum_{k=0}^{n-1} p_{k}G^{k}(v_{i}) \mathbb{E}[G^{k}(x) : x < v_{i}]

Substituting in the result for \beta^{k}(v_{i}) and dividing both sides by G(v_{i}), we obtain the symmetric equilibrium bidding function for the first price auction with an uncertain number of bidders:

\beta(v_{i}) = \dfrac{1}{G(v_{i})} \displaystyle \sum_{k=0}^{n-1} p_{k}G^{k}(v_{i}) \beta^{k}(v_{i})

Auction Theory: Post-Auction Resale

I. Introduction
This blog entry extends the model of auctions introduced in my prior blog entry by introducing the possibility of post-auction resale. In this model, the winning bidder can sell the item to the losing bidders at a fixed price. Initially, this mechanism may seem to favor the highest bidder, giving him or her the power to extort additional profit from the losing bidders. In the case of the first-price auction, the post-auction resale mechanism results in the same equilibrium bids and outcome as in the standard symmetric first-price auction. Similarly, the post-auction resale mechanism makes little sense to employ in the case of the second-price auction.

II. Auction Resale Problem
We consider the symmetric, sealed bid, first-price auction where each bidder’s valuation is drawn from the probability distribution given by F([0, \omega]), for some \omega \in \mathbb{R}_{++}. Let \beta : [0, \omega] \to \mathbb{R}_{+} be the symmetric equilibrium bidding function in the case of the first-price auction. Recall from my prior blog entry that:

\beta(v) = \displaystyle \dfrac{1}{G(v)} \int_{0}^{v} xG^{\prime}(x)dx

The auctioneer begins by holding the auction. Then, after the auction, each player’s bid is made public. The winning bidder then decides whether or not to sell the item. If the winning bidder chooses to sell the item after the auction, he then decides upon a price p \in \mathbb{R}_{+} after the auction. Any of the other bidder can then choose to accept the item at price p or to reject this item. Note that the possibility of post-auction resale is known to all bidders a priori. We seek to determine how the winning bidder should set the price p, as well as how the losing bidder should respond.

In order to analyze this mechanism, we consider the post-auction resale mechanism as a dynamic game. We apply dynamic programming, which is referred to as backward induction in game theory, to find the equilibrium strategies. In particular, this equilibrium is a subgame perfect Nash equilibrium, which induces a Nash equilibrium at every subgame.

We start by examining the last subgame, the post-auction resale. Let player i be the winning bidder, and let j be a player with the second highest bid. By monotonicity of the bidding strategies, we have v_{i} \geq v_{j}, where v_{i}, v_{j} are the bidders’ respective valuations. Let p \in \mathbb{R}_{+} be the fixed price at which player i chooses to sell the item. As the bids are public information, player i will set p > b_{j}, player j‘s bid. Player j will purchase the item from player i if and only if p \leq v_{j}. If player j purchases the item from player i, then player i‘s profit is p - b_{i}. As player i will not own the item if he resells it, player i does not obtain valuation v from winning the item in the auction. Since p \leq v_{i} \leq v_{j}, it follows that p - b_{i} \leq v_{i} - b_{i}. So player i has no incentive to resell the item.

Since the winning bidder has no incentive to resell the item after the auction, each bidder will submit his or her bid in an attempt to win and keep the item. Thus, each player should bid \beta in the subgame perfect Nash equilibrium, then the winner should opt not to resell the item and a losing bidder should purchase the item if and only if p is less than its valuation.

The above proof holds as well in the second price auction with the possibility of post-auction resale, noting that the winning bidder’s profit upon successful resale is p - b_{j} \leq v_{j} - b_{j} \leq v_{i} - b_{j}. So the subgame perfect Nash equilibrium is for each player to bid his or her valuation, and for the winner not to resell the item after the auction.

We can more strongly say that there exists no incentive compatible, individually rational mechanism for the winning bidder to use to liquidate the item post-auction. This follows from the fact that no player will pay more than his or her valuation for the item, so the maximum payoff the winning bidder can obtain in choosing to liquidate the item post auction is v_{j} - b_{i} in the case of the first price auction or v_{j} - b_{j} in a second price auction, where v_{j} is the valuation of the second highest bidder.

The Lambda Auction

I. Introduction
This blog entry introduces the \lambda-auction. Intuitively, the \lambda-auction is a mix between the first and second price auctions. Formally, the auctioneer fixes a value \lambda \in (0, 1) and awards the item to the highest bidder i, who pays a convex combination of his or her bid and the second highest bid.

\displaystyle \lambda \beta(v_{i}) + (1 - \lambda) \max_{j \neq i} b_{j}

In order to study the \lambda-auction, we adopt the framework presented in my previous entry introducing auction theory. That is, the auction consists of n \in \mathbb{N} bidders, each with a private valuation drawn from the probability distribution given by F_{i}([0, \omega]), for some \omega \in \mathbb{R}_{++}. Each bidder submits his or her bid in a sealed manner. This blog entry focuses on the symmetric case, where each player’s valuation is drawn from the same probability distribution F([0, \omega]). Furthermore, each player’s valuation is independent of the other players’ valuations. The symmetric equilibrium bidding function will be derived, and then verified to be an equilibrium bidding function.

II. Derivation of Symmetric Equilibrium Bidding Strategy
In this section, the symmetric equilibrium bidding strategy will be derived for the \lambda auction. The next section will verify that the derived bidding strategy indeed constitutes an equilibrium bidding strategy.

The goal of each bidder is to maximize his or her expected payoff. Each bidder’s valuation is fixed, and so a given player can only vary his or her bid. As we are considering the symmetric case, each player’s value is drawn from the probability distribution given by F([0, \omega]) for some fixed \omega \in \mathbb{R}_{++}. Suppose player i has valuation v_{i}. The probability that some player j has valuation less than v_{i} is given by F(v_{i}). As each player’s valuation is independent, we multiply each F(v_{i}) to get F^{n-1}(v_{i}) as the probability that the remaining n-1 players each have valuation less than v_{i}. That is, F^{n-1}(v_{i}) describes the probability that player i has the highest valuation given that he has valuation i. Define G(x) = F^{n-1}(x).

Let’s now define the optimization problem each bidder seeks to solve. We start by assuming that the symmetric equilibrium bidding function \beta is continuous, differentiable, and strictly increasing. Consider first the term G(\beta^{-1}(b)) \cdot (v - \lambda b). By symmetry, we expect each player to bid according to \beta in equilibrium. As \beta is strictly increasing and continuous, it is invertible. So \beta^{-1}(b) denotes the valuation associated with b if b were an equilibrium bid. As no player will bid more than his or her valuation, G(\beta^{-1}(b)) denotes the probability that player i has the highest bid. We thus have G(\beta^{-1}(b)) \cdot (v - \lambda b) as the expected payment under the first price auction, pro-weighted according to \lambda.

We then subtract out from G(v) \cdot (v - \lambda b) the weight of the expected second highest bid. Observe that the integral calculates the expected highest bid of the remaining n-1 players, limiting the highest valuation to b.

\displaystyle \max_{b} G(\beta^{-1}(b)) \cdot (v - \lambda b) - (1 - \lambda) \cdot \int_{0}^{b} z dG(\beta^{-1}(z))

The next step is to consider the first order conditions, differentiating with respect to b. Note that by the Fundamental Theorem of Calculus, \dfrac{d}{db} \displaystyle \int_{0}^{b} zdG(\beta^{-1}(z)) = b \cdot dG(\beta^{-1}(b)). We then differentiate G(\beta^{-1}(b)) as noted by the term dG(\beta^{-1}(b)).

\displaystyle \dfrac{G^{\prime}(\beta^{-1}(b))}{\beta^{\prime}(\beta^{-1}(b))} \cdot (v - \lambda b) - \lambda G(\beta^{-1}(b)) - (1 - \lambda) b\dfrac{G^{\prime}(\beta^{-1}(b))}{\beta^{\prime}(\beta^{-1}(b))} = 0

Note that in the symmetric equilibrium, each player applies the same strategy. So we substitute \beta^{-1}(b) = v and b = \beta(v). We then multiply out by \beta^{\prime}(v) to get:

\displaystyle G^{\prime}(v) \cdot (v - \lambda \beta(v)) - \lambda G(v)\beta^{\prime}(v) - (1 - \lambda)\beta(v)G^{\prime}(v) = 0

Expanding out and collecting terms yields:

\displaystyle G^{\prime}(v)v = G^{\prime}(v)\beta(v) + \lambda G(v)\beta^{\prime}(v)

This differential equation looks very similar to that in my previous blog entry for deriving the symmetric equilibrium bid in the first price auction. The \lambda constant in the G(v)\beta^{\prime}(v) term requires extra steps to solve the differential equation. Let H(x) = (G(x))^{1/\lambda}, so G(x) = (H(x))^{\lambda}. Then G^{\prime}(x) = \lambda (H^{\prime}(x))^{\lambda - 1}. Substituting in H(\cdot) for G(\cdot) yields:

\lambda \cdot v H^{\prime}(v) (H(v))^{\lambda - 1} = \lambda H^{\prime}(v)(H(v))^{\lambda - 1}\beta(v) + \lambda \beta^{\prime}(v) (H(v))^{\lambda}

We cancel out the \lambda and (H(v))^{\lambda - 1} terms, leaving:

\displaystyle vH^{\prime}(v) = H^{\prime}(v)\beta(v) + \beta^{\prime}(v)H(v)

We note that H^{\prime}(v)\beta(v) + \beta^{\prime}(v)H(v) = (H(v)\beta(v))^{\prime} by the product rule. So integrating both sides yields:

\displaystyle \int_{0}^{v} zH^{\prime}(z) dz = H(v)\beta(v) \implies \beta(v) = \dfrac{1}{H(v)} \int_{0}^{v} zH^{\prime}(z)dz

Note that \beta(0) = 0. We simplify \beta(v), integrating by parts. Let u = z, du = dz, dw = H^{\prime}(z)dz and w = H(z). So

\displaystyle \int_{0}^{v} zH^{\prime}(z) dz = \int_{0}^{v}zH^{\prime}(z)dz = vH(v) - \int_{0}^{v} H(z)dz

Plugging this expression into \beta(v) yields:

\displaystyle \beta(v) = v - \dfrac{1}{H(v)} \int_{0}^{v} H(z) dz = v - \int_{0}^{v} \biggr ( \dfrac{G(z)}{G(v)} \biggr )^{1/\lambda} dz
III. Verification of Symmetric Equilibrium Bidding Strategy
In this section, we verify that the function \beta(v) derived in the previous section actually constitutes a symmetric Bayesian Nash equilibrium.

Theorem 1: In a symmetric \lambda-auction where the valuations for each player are independent and identically distributed, the symmetric Bayesian Nash equilibrium occurs when each player bids according to the bidding function:

\beta(v) = v - \displaystyle \int_{0}^{v} \biggr ( \dfrac{G(z)}{G(v)} \biggr )^{1/\lambda} dz

Proof: Consider player i, and suppose player i bids b_{i} \neq \beta(v_{i}). Let z_{i} = \beta^{-1}(b_{i}) be the valuation for b_{i} to be an equilibrium bid. If player i bids b_{i} > v_{i}, then the second highest bidder j could bid \beta(v_{j}) > b_{i}, resulting in a loss for player i if he wins the object. If instead player j wins the object, player i pays nothing. So player i won’t bid more than v_{i}.

Denote the expected profit of player i with valuation v_{i} and bid b_{i} as \mathbb{E}[\Pi(v_{i}, b_{i})]. Observe that the expected profit of bidding b_{i} is:

\displaystyle \mathbb{E}[\Pi(v_{i}, b_{i})] = G(z_{i}) \cdot (v - \lambda b_{i}) - (1 - \lambda) \int_{0}^{z_{i}} \beta(z_{i})G^{\prime}(z)dz

It suffices to show that \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] \geq 0 for all z_{i} \in [0, \omega].

Consider:

\displaystyle \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] = G(v_{i})v_{i} - G(v_{i}) \beta(v_{i}) + (1 - \lambda) \int_{0}^{v_{i}} \beta^{\prime}(x)G(x)dx) -
\displaystyle G(z_{i})v_{i} + G(z_{i})\beta(z_{i}) - (1 - \lambda) \int_{0}^{z_{i}} \beta^{\prime}(x)G(x)dx

Factoring out terms, we obtain:

\displaystyle v_{i}(G(v_{i}) - G(z_{i})) - (G(v_{i})\beta(v_{i}) - G(z_{i})\beta(z_{i})) + (1 - \lambda) \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx

Observe that v \geq \beta(v_{i}) > \beta(z_{i}). So v_{i}(G(v_{i}) - G(z_{i})) > (G(v_{i})\beta(v_{i}) - G(z_{i})\beta(z_{i})). It follows that if z_{i} < v_{i} (which is equivalent to b_{i} < \beta(v_{i})), then \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] \geq 0.

Now suppose \beta(z_{i}) \in (\beta(v_{i}), v_{i}]. Thus, z_{i} > v_{i}. Consider again:

\displaystyle \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] = v(G(v_{i}) - G(z_{i})) - G(v_{i})\beta(v_{i}) + G(z_{i})\beta(z_{i}) + (1 - \lambda) \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx

We note that:

\displaystyle (1 - \lambda) \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx = \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx - \lambda \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx

And evaluate the integral with coefficient 1 by parts to obtain:

\displaystyle \int_{z_{i}}^{v_{i}} \beta^{\prime}(x)G(x)dx = \beta(z_{i})G(z_{i}) - \beta(v_{i})G(v_{i}) - \int_{z_{i}}^{v_{i}} \beta(x)G^{\prime}(x)dx

Applying this result and the Fundamental Theorem of calculus yields:

\displaystyle \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] = v(G(v_{i}) - G(z_{i})) + \int_{v_{i}}^{z_{i}} \beta(x)G^{\prime}(x)dx + \lambda \int_{v_{i}}^{z_{i}} \beta^{\prime}(x)G(x)dx

Recall from the derivation of \beta(v) that:

vG^{\prime}(v) = G^{\prime}(v)\beta(v) + \lambda G(v)\beta^{\prime}(v)

We consolidate:

\displaystyle \int_{v_{i}}^{z_{i}} \beta(x)G^{\prime}(x)dx + \lambda \int_{v_{i}}^{z_{i}} \beta^{\prime}(x)G(x)dx =
\displaystyle \int_{v_{i}}^{z_{i}} \biggr ( \beta(x)G^{\prime}(x) + \lambda \beta^{\prime}(x)G(x) \biggr)dx =
\displaystyle \int_{v_{i}}^{z_{i}} xG^{\prime}(x) dx =
z_{i}G(z_{i}) - v_{i}G(v_{i}) - \displaystyle \int_{v_{i}}^{z_{i}} G(x) dx

With the last equality obtained integrating by parts. We thus have:

\displaystyle \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] =
v_{i}(G(v_{i}) - G(z_{i})) + z_{i}G(z_{i})  - v_{i}G(v_{i}) - \displaystyle \int_{v_{i}}^{z_{i}} G(x)dx =
G(z_{i})(z_{i} - v_{i}) - \displaystyle \int_{v_{i}}^{z_{i}} G(x) dx

Observe that G(z_{i})(z_{i} - v_{i}) describes the area under the rectangle of width z_{i} - v_{i} whose top-right vertex is at the point (z_{i}, G(z_{i}). As G(z_{i}) is monotone, this rectangle potentially covers area above G(\cdot). The integral \displaystyle \int_{v_{i}}^{z_{i}} G(x)dx covers exactly the area under G(\cdot) for the same interval. Thus, we have:

G(z_{i})(z_{i} - v_{i}) \geq \displaystyle \int_{v_{i}}^{z_{i}} G(x) dx \geq 0

Which implies that:

\displaystyle \mathbb{E}[\Pi(v_{i}, \beta(v_{i}))] - \mathbb{E}[\Pi(v_{i}, \beta(z_{i}))] \geq 0

Whenever z_{i} > v_{i}. Thus, whenever z_{i} \neq v_{i}, player i expects to profit less than by bidding \beta(v_{i}). Thus, \beta(v_{i}) is an equilibrium bidding strategy. QED.