Optimisation & Mathematical Methods for Economics The University of Edinburgh · School of Economics
Real economic constraints are often inequalities: budgets are upper bounds, quantities must be non-negative, capacity is limited. This week introduces the Karush–Kuhn–Tucker (KKT) conditions.
1. Inequality Constraints and KKT Conditions
Problem: Minimise \(f(\mathbf{x})\) subject to \(g_i(\mathbf{x}) \leq 0\), \(i = 1,\ldots,m\) and \(h_j(\mathbf{x}) = 0\), \(j = 1,\ldots,p\).
KKT conditions (necessary for a local minimum under constraint qualification): 1. Stationarity:\(\nabla f + \sum_i \mu_i \nabla g_i + \sum_j \lambda_j \nabla h_j = 0\) 2. Primal feasibility:\(g_i(\mathbf{x}) \leq 0\), \(h_j(\mathbf{x}) = 0\) 3. Dual feasibility:\(\mu_i \geq 0\) 4. Complementary slackness:\(\mu_i g_i(\mathbf{x}) = 0\) for all \(i\)
2. Complementary Slackness
The condition \(\mu_i g_i(\mathbf{x}) = 0\) means: - Either the constraint is binding (\(g_i = 0\)) and the multiplier can be positive (\(\mu_i > 0\)) - Or the constraint is slack (\(g_i < 0\)) and the multiplier must be zero (\(\mu_i = 0\))
Economically: a resource has a positive shadow price only if it is fully used.
import numpy as npimport matplotlib.pyplot as pltfrom scipy.optimize import minimize# Example: Minimise f(x,y) = (x-3)^2 + (y-2)^2# subject to: x + y <= 4, x >= 0, y >= 0result = minimize( fun=lambda x: (x[0]-3)**2+ (x[1]-2)**2, x0=[1, 1], constraints=[ {'type': 'ineq', 'fun': lambda x: 4- x[0] - x[1]}, # x+y <= 4 ], bounds=[(0, None), (0, None)])print(f"Optimal x* = ({result.x[0]:.4f}, {result.x[1]:.4f})")print(f"Minimum f* = {result.fun:.4f}")print(f"x + y = {sum(result.x):.4f} (constraint bound = 4)")ifabs(sum(result.x) -4) <0.01:print("=> Budget constraint is BINDING")
Optimal x* = (2.5000, 1.5000)
Minimum f* = 0.5000
x + y = 4.0000 (constraint bound = 4)
=> Budget constraint is BINDING
Exercise 1: A consumer maximises \(u = \ln(x_1) + \ln(x_2)\) subject to \(2x_1 + 3x_2 \leq 12\), \(x_1 \geq 0\), \(x_2 \geq 0\). Write down the KKT conditions and solve.
The budget constraint will be binding (since \(u\) is monotonically increasing). \(x_1^* = 3\), \(x_2^* = 2\), \(\mu = 1/6\) (shadow price of the budget).