---
title: "Tragedy of the commons — game-theoretic analysis"
description: "Hardin's tragedy of the commons modelled as an N-player commons dilemma with continuous extraction, comparing Nash equilibrium over-extraction to the social optimum and simulating Ostrom's institutional design principles."
author: "Raban Heller"
date: 2026-05-08
date-modified: 2026-05-08
categories:
- case-studies
- commons-dilemma
- public-goods
- institutional-design
keywords: ["tragedy of the commons", "Hardin", "Ostrom", "common-pool resources", "Nash equilibrium", "social optimum", "institutional design", "N-player game"]
labels: ["case-studies", "institutional-design"]
tier: 1
bibliography: ../../../references.bib
vgwort: "TODO_VGWORT_case-studies_tragedy-of-the-commons"
image: thumbnail.png
image-alt: "Line plot showing the growing inefficiency gap between Nash equilibrium extraction and social optimum as the number of players increases"
citation:
type: webpage
url: https://r-heller.github.io/equilibria/tutorials/case-studies/tragedy-of-the-commons/
license: "CC BY-SA 4.0"
draft: false
has_static_fig: true
has_interactive_fig: true
has_shiny_app: false
---
```{r}
#| label: setup
#| include: false
library(ggplot2)
library(dplyr)
library(tidyr)
library(plotly)
okabe_ito <- c("#E69F00", "#56B4E9", "#009E73", "#F0E442",
"#0072B2", "#D55E00", "#CC79A7", "#999999")
theme_publication <- function(base_size = 12) {
theme_minimal(base_size = base_size) +
theme(plot.title = element_text(size = base_size * 1.2, face = "bold"),
plot.subtitle = element_text(size = base_size * 0.9, color = "grey40"),
axis.line = element_line(color = "grey30", linewidth = 0.3),
panel.grid.minor = element_blank(), legend.position = "bottom",
plot.margin = margin(10, 10, 10, 10))
}
```
## Introduction & motivation
In 1968, Garrett Hardin published his influential essay "The Tragedy of the Commons," arguing that shared resources are inevitably overexploited when individuals act in their own self-interest. His canonical example --- herdsmen adding cattle to a common pasture --- illustrated how individually rational decisions aggregate into collectively disastrous outcomes. Each herdsman captures the full benefit of adding one more animal but bears only a fraction of the resulting overgrazing cost, creating a negative externality that degrades the resource for everyone.
The tragedy of the commons is not merely a parable; it describes real resource management failures across domains. Overfishing in open-access fisheries has led to the collapse of cod stocks in the North Atlantic, sardine populations off the California coast, and bluefin tuna in the Mediterranean. Groundwater aquifers in India, the American Midwest, and the Middle East are being depleted faster than they can recharge. Carbon emissions represent perhaps the largest commons dilemma of all: the atmosphere's capacity to absorb greenhouse gases is a shared resource that every nation has an incentive to overuse.
From a game-theoretic perspective, the commons dilemma is an N-player generalisation of the prisoner's dilemma. Each player's dominant strategy is to extract more than the socially optimal amount, and the resulting Nash equilibrium is Pareto-inferior to the cooperative outcome. The inefficiency gap --- the difference between Nash equilibrium welfare and the social optimum --- grows with the number of players, because each additional player further dilutes the individual cost of overextraction.
However, Hardin's conclusion that the only solutions are privatisation or government regulation was challenged decisively by Elinor Ostrom, who documented hundreds of cases where communities successfully managed common-pool resources through self-governance. Her eight design principles --- including clearly defined boundaries, collective-choice arrangements, monitoring, and graduated sanctions --- provide a framework for institutional solutions that sustain cooperation without external enforcement. Ostrom's work earned her the 2009 Nobel Prize in Economics and fundamentally reshaped how economists and political scientists think about collective action.
In this tutorial, we formally model the commons as an N-player extraction game with diminishing returns, derive the Nash equilibrium and social optimum analytically, and simulate commons dynamics under different institutional arrangements inspired by Ostrom's principles.
## Mathematical formulation
Consider $N$ symmetric players who extract from a common resource of capacity $K$. Each player $i$ chooses extraction level $e_i \geq 0$. Total extraction is $E = \sum_{i=1}^{N} e_i$. The resource generates value according to a production function with diminishing returns:
$$
f(E) = E \cdot \left(1 - \frac{E}{K}\right)
$$
when $E \leq K$, and $f(E) = 0$ otherwise. Player $i$'s payoff is their share of total production, proportional to their extraction:
$$
u_i(e_i, E_{-i}) = \frac{e_i}{E} \cdot f(E) = e_i \left(1 - \frac{E}{K}\right)
$$
**Nash equilibrium.** Each player maximises $u_i$ taking $E_{-i} = \sum_{j \neq i} e_j$ as given. The first-order condition is:
$$
\frac{\partial u_i}{\partial e_i} = 1 - \frac{E_{-i} + 2e_i}{K} = 0
$$
By symmetry, $e_i^* = e^*$ for all $i$, so $E_{-i} = (N-1)e^*$. Substituting:
$$
1 - \frac{(N-1)e^* + 2e^*}{K} = 0 \implies e^*_{\text{NE}} = \frac{K}{N+1}
$$
Total Nash extraction: $E_{\text{NE}} = \frac{NK}{N+1}$.
**Social optimum.** A social planner maximises total welfare $W = f(E) = E(1 - E/K)$:
$$
\frac{dW}{dE} = 1 - \frac{2E}{K} = 0 \implies E_{\text{SO}} = \frac{K}{2}
$$
Per-player extraction at the social optimum: $e^*_{\text{SO}} = \frac{K}{2N}$.
**Inefficiency ratio.** The ratio of Nash to socially optimal total extraction is:
$$
\frac{E_{\text{NE}}}{E_{\text{SO}}} = \frac{2N}{N+1}
$$
As $N \to \infty$, this ratio approaches 2: the commons is exploited at twice the optimal rate. The welfare loss (price of anarchy) is:
$$
\frac{W_{\text{SO}} - W_{\text{NE}}}{W_{\text{SO}}} = 1 - \frac{N}{(N+1)^2} \cdot 4 = 1 - \frac{4N}{(N+1)^2}
$$
Wait --- let us compute welfare at each equilibrium. $W_{\text{SO}} = \frac{K}{2}(1 - \frac{1}{2}) = \frac{K}{4}$. And $W_{\text{NE}} = \frac{NK}{N+1}(1 - \frac{N}{N+1}) = \frac{NK}{(N+1)^2}$. So:
$$
\text{Efficiency} = \frac{W_{\text{NE}}}{W_{\text{SO}}} = \frac{4N}{(N+1)^2}
$$
For $N=2$, efficiency is $8/9 \approx 89\%$. For $N=10$, efficiency is $40/121 \approx 33\%$. For $N \to \infty$, efficiency approaches zero.
## R implementation
We compute Nash equilibrium and social optimum extraction levels for varying numbers of players, then simulate commons dynamics with and without Ostrom-inspired institutions (extraction quotas and monitoring with graduated sanctions).
```{r}
#| label: commons-simulation
K <- 100 # resource capacity
# Analytical solutions
analytics <- tibble(
N = 2:50,
E_NE = N * K / (N + 1),
E_SO = K / 2,
e_NE = K / (N + 1),
e_SO = K / (2 * N),
W_NE = N * K / (N + 1)^2,
W_SO = K / 4,
efficiency = 4 * N / (N + 1)^2,
welfare_loss_pct = (1 - efficiency) * 100
)
cat("=== Commons Dilemma: Analytical Results ===\n\n")
cat(sprintf(" %-5s | %-10s | %-10s | %-10s | %-12s\n",
"N", "E_Nash", "E_Social", "Efficiency", "Welfare loss"))
cat(paste(rep("-", 60), collapse = ""), "\n")
for (n in c(2, 5, 10, 20, 50)) {
row <- analytics %>% filter(N == n)
cat(sprintf(" %-5d | %-10.1f | %-10.1f | %-10.1f%% | %-10.1f%%\n",
n, row$E_NE, row$E_SO, row$efficiency * 100, row$welfare_loss_pct))
}
# Dynamic simulation: repeated extraction over T periods with resource regeneration
simulate_commons <- function(N, K, T_periods, institution = "none",
quota = NULL, monitor_prob = 0, sanction = 0) {
stock <- K
history <- tibble(period = integer(), stock = double(),
extraction = double(), welfare = double())
for (t in 1:T_periods) {
if (institution == "none") {
# Nash: each player extracts K/(N+1) of current stock
e_each <- stock / (N + 1)
} else if (institution == "quota") {
# Quota: social optimum extraction, but some cheat
e_target <- stock / (2 * N)
# Each player cheats with probability (1 - monitor_prob)
cheaters <- rbinom(N, 1, prob = 1 - monitor_prob)
# Cheaters extract Nash level; compliers extract quota
e_nash <- stock / (N + 1)
e_vec <- ifelse(cheaters == 1, e_nash, e_target)
# Sanctions: cheaters caught with prob monitor_prob lose a fraction
caught <- cheaters & (runif(N) < monitor_prob)
e_vec[caught] <- e_vec[caught] * (1 - sanction)
e_each <- mean(e_vec)
}
total_extraction <- N * e_each
total_extraction <- min(total_extraction, stock)
welfare <- total_extraction * (1 - total_extraction / stock)
history <- bind_rows(history, tibble(
period = t, stock = stock,
extraction = total_extraction, welfare = welfare
))
# Resource regeneration: logistic growth
remaining <- stock - total_extraction
stock <- remaining + remaining * 0.3 * (1 - remaining / K)
stock <- max(stock, 0)
}
history
}
set.seed(123)
T_periods <- 30
N_sim <- 15
# Scenario 1: No institution (Nash play)
hist_none <- simulate_commons(N_sim, K, T_periods, "none") %>%
mutate(scenario = "No institution (Nash)")
# Scenario 2: Quota with weak monitoring
hist_weak <- simulate_commons(N_sim, K, T_periods, "quota",
monitor_prob = 0.3, sanction = 0.3) %>%
mutate(scenario = "Weak monitoring (30%)")
# Scenario 3: Quota with strong monitoring (Ostrom)
hist_strong <- simulate_commons(N_sim, K, T_periods, "quota",
monitor_prob = 0.8, sanction = 0.5) %>%
mutate(scenario = "Strong monitoring (80%)")
dynamics <- bind_rows(hist_none, hist_weak, hist_strong)
cat("\n=== Resource Stock After 30 Periods (N=15 players) ===\n\n")
dynamics %>%
filter(period == T_periods) %>%
{
for (i in seq_len(nrow(.))) {
cat(sprintf(" %-30s | Stock: %5.1f | Welfare: %5.2f\n",
.$scenario[i], .$stock[i], .$welfare[i]))
}
}
```
## Static publication-ready figure
The figure shows two panels: (left) the inefficiency gap between Nash extraction and the social optimum as a function of the number of players, and (right) resource stock trajectories under different institutional regimes.
```{r}
#| label: fig-commons-static
#| fig-cap: "Figure 1. Left: Efficiency of Nash equilibrium relative to social optimum declines sharply with the number of players. Right: Simulated resource stock dynamics (N = 15) under no institution, weak monitoring, and Ostrom-style strong monitoring with graduated sanctions."
#| dev: [png, pdf]
#| fig-width: 10
#| fig-height: 5
#| dpi: 300
# Panel A: Efficiency vs N
p_efficiency <- ggplot(analytics, aes(x = N, y = efficiency)) +
geom_line(colour = okabe_ito[1], linewidth = 1.2) +
geom_hline(yintercept = 1, linetype = "dashed", colour = "grey50") +
annotate("text", x = 40, y = 0.95, label = "Social optimum", colour = "grey50",
size = 3.5, hjust = 0) +
scale_y_continuous(labels = scales::percent_format(), limits = c(0, 1)) +
labs(title = "A. Efficiency loss grows with N",
x = "Number of players (N)",
y = "Nash efficiency (W_NE / W_SO)") +
theme_publication()
# Panel B: Resource dynamics
p_dynamics <- ggplot(dynamics,
aes(x = period, y = stock, colour = scenario,
text = paste0("Scenario: ", scenario,
"\nPeriod: ", period,
"\nStock: ", round(stock, 1)))) +
geom_line(linewidth = 1.1) +
geom_point(size = 1.2, alpha = 0.5) +
scale_colour_manual(values = okabe_ito[c(6, 1, 3)]) +
labs(title = "B. Commons dynamics under institutions",
x = "Period",
y = "Resource stock",
colour = "Regime") +
theme_publication() +
theme(legend.position = "right")
# Combine using patchwork-style approach with grid
gridExtra_available <- requireNamespace("gridExtra", quietly = TRUE)
if (gridExtra_available) {
gridExtra::grid.arrange(p_efficiency, p_dynamics, ncol = 2)
} else {
# Fallback: show efficiency plot
p_efficiency
}
```
## Interactive figure
Explore the resource stock dynamics interactively. Hover to see exact stock levels at each period and compare institutional regimes.
```{r}
#| label: fig-commons-interactive
p_interact <- ggplot(dynamics,
aes(x = period, y = stock, colour = scenario,
text = paste0("Scenario: ", scenario,
"\nPeriod: ", period,
"\nStock: ", round(stock, 1),
"\nExtraction: ", round(extraction, 1),
"\nWelfare: ", round(welfare, 2)))) +
geom_line(linewidth = 1) +
geom_point(size = 1.5) +
scale_colour_manual(values = okabe_ito[c(6, 1, 3)]) +
labs(title = "Commons dynamics: resource stock over time",
x = "Period", y = "Resource stock", colour = "Institutional regime") +
theme_publication()
ggplotly(p_interact, tooltip = "text") %>%
config(displaylogo = FALSE) %>%
layout(legend = list(orientation = "h", y = -0.2))
```
## Interpretation
The analytical results confirm Hardin's core insight: in the absence of institutions, self-interested agents over-extract common-pool resources, and the inefficiency worsens dramatically with the number of players. With just 10 players, Nash equilibrium welfare is only about a third of the social optimum. With 50 players, it drops below 8 percent. The mathematical structure reveals why: each player captures $1/N$ of the marginal damage from their extraction but receives the full marginal benefit, so the private cost of extraction is $N$ times smaller than the social cost.
The dynamic simulations tell a more nuanced story. Under unregulated Nash play, the resource stock declines steadily as extraction consistently exceeds the regeneration rate. The tragedy unfolds gradually --- not as a sudden collapse, but as a slow erosion of the commons that each individual player has little incentive to prevent. Weak monitoring (where cheaters face only a 30 percent chance of detection and mild sanctions) slows the decline but does not prevent it, because the expected cost of cheating remains below the benefit.
Strong monitoring, inspired by Ostrom's design principles, fundamentally changes the outcome. When the probability of detection is high (80 percent) and sanctions are graduated (cheaters forfeit 50 percent of their excess extraction), most agents comply with the socially optimal quota. The resource stock stabilises at a sustainable level, and cumulative welfare over the 30-period simulation is dramatically higher.
These results have direct implications for real-world resource management. The model suggests that the critical institutional variables are not the severity of punishment per se, but the *probability of detection* and the *credibility of enforcement*. This is consistent with Ostrom's observation that successful commons management relies on mutual monitoring by community members rather than on draconian penalties imposed by distant authorities. Graduated sanctions --- where first-time offenders face mild penalties and repeat offenders face escalating consequences --- maintain social cohesion while deterring systematic cheating.
The model's key limitation is its assumption of symmetric players. In practice, heterogeneity in extraction capacity, discount rates, and political power profoundly shapes commons governance. Large firms or politically connected actors may capture regulatory institutions, leading to outcomes worse than the unregulated Nash equilibrium.
## Extensions & related tutorials
The tragedy of the commons connects to many foundational concepts in game theory, mechanism design, and institutional economics. The N-player structure generalises the two-player prisoner's dilemma, and the institutional solutions relate to repeated-game cooperation and mechanism design.
- [Public goods experiment](../../experimental-economics/public-goods-experiment/) --- experimental evidence on voluntary contributions to shared resources and the role of punishment
- [Mechanism design fundamentals](../../mechanism-design/) --- designing rules and institutions to align private incentives with social welfare
- [Difference-in-differences with strategic agents](../../causal-inference/difference-in-differences-strategic/) --- evaluating the causal impact of institutional interventions on strategic behaviour
- [Nash equilibrium existence proof](../../history-of-gt-mathematics/nash-equilibrium-original-proof/) --- the mathematical foundation underlying the equilibrium concept used throughout this analysis
## References
::: {#refs}
:::