ADMM
The alternating direction method of multipliers (ADMM) splits a problem into pieces that are easy on their own and coordinates them with a multiplier. It combines the robustness of the augmented Lagrangian method with the decomposability of dual methods, and it powers solvers for lasso-type problems, total-variation denoising, consensus optimization across machines, and the QP solver OSQP.
The splitting
ADMM solves problems of the form
Often you create this form by duplicating a variable: becomes s.t. . With the scaled multiplier and penalty , one iteration is
Instead of minimizing the augmented Lagrangian jointly over , which is hard, ADMM does one pass of alternating minimization, then the multiplier update.
ADMM for the lasso
Split with . The -step is a ridge regression with a fixed matrix (factor it once), the -step is soft thresholding:
import numpy as np
rng = np.random.default_rng(0)
n, d = 100, 200
X = rng.normal(size=(n, d)) / np.sqrt(n)
w_true = np.zeros(d); w_true[rng.choice(d, 8, replace=False)] = rng.normal(scale=3, size=8)
y = X @ w_true + 0.05 * rng.normal(size=n)
lam, rho = 0.05, 1.0
soft = lambda v, k: np.sign(v) * np.maximum(np.abs(v) - k, 0)
Lc = np.linalg.cholesky(X.T @ X + rho * np.eye(d)) # factor once
Xty = X.T @ y
w = z = u = np.zeros(d)
for k in range(1, 501):
w = np.linalg.solve(Lc.T, np.linalg.solve(Lc, Xty + rho * (z - u)))
z_old = z
z = soft(w + u, lam / rho)
u = u + w - z
r_norm, s_norm = np.linalg.norm(w - z), rho * np.linalg.norm(z - z_old)
if k in (10, 25, 50, 100):
F = 0.5 * np.sum((X @ z - y)**2) + lam * np.abs(z).sum()
print(f"k = {k:3d}: objective {F:.6f}, primal residual {r_norm:.1e}, dual residual {s_norm:.1e}")
print("non-zeros:", int(np.sum(z != 0)))k = 10: objective 1.450294, primal residual 5.8e-02, dual residual 2.3e-01
k = 25: objective 1.036939, primal residual 3.5e-02, dual residual 1.0e-01
k = 50: objective 0.999157, primal residual 1.0e-03, dual residual 1.5e-03
k = 100: objective 0.999153, primal residual 9.6e-08, dual residual 1.1e-07
non-zeros: 41
The primal residual measures constraint violation, the dual residual measures how far from stationarity; stop when both are small. Note that is exactly sparse at every iteration.
Total-variation denoising
Denoise a piecewise-constant signal by minimizing , where takes differences of neighbours. The L1 norm of has no simple prox, but with ADMM's steps are a linear solve and a soft threshold:
import numpy as np
rng = np.random.default_rng(1)
clean = np.repeat([0.0, 2.0, 1.0, 3.0], 25)
y = clean + 0.4 * rng.normal(size=clean.size)
n = y.size
D = np.eye(n)[1:] - np.eye(n)[:-1]
lam, rho = 1.0, 2.0
M = np.eye(n) + rho * D.T @ D
soft = lambda v, k: np.sign(v) * np.maximum(np.abs(v) - k, 0)
x, z, u = y.copy(), np.zeros(n - 1), np.zeros(n - 1)
for _ in range(500):
x = np.linalg.solve(M, y + rho * D.T @ (z - u))
z = soft(D @ x + u, lam / rho)
u = u + D @ x - z
print("RMSE noisy: ", round(float(np.sqrt(np.mean((y - clean)**2))), 4))
print("RMSE denoised:", round(float(np.sqrt(np.mean((x - clean)**2))), 4))
print("jumps detected at:", np.nonzero(np.abs(z) > 0.3)[0] + 1)RMSE noisy: 0.3419
RMSE denoised: 0.1085
jumps detected at: [25 26 50 75]
The three jumps of the clean signal (at positions 25, 50 and 75) are found; the first is spread over two neighbouring differences. Total variation keeps edges sharp, which a moving average would blur.
Properties
- Converges for any when and are closed convex functions (and a saddle point exists), but only at a modest rate: fast to moderate accuracy, slow to high accuracy.
- The choice of matters in practice; adaptive schemes balance the primal and dual residuals.
- Consensus ADMM splits a dataset across machines, each solving a local problem, with the -step averaging: a natural fit for distributed training.
In software
- OSQP (QPs), SCS (cone programs), and many imaging, graphical-lasso and distributed-ML codes are ADMM at heart.
- Boyd et al.'s monograph Distributed Optimization and Statistical Learning via ADMM (2011) is the standard reference and comes with example code.
Exercises
Exercise 1: Write the splitting
Write s.t. in ADMM form. What is the -step?
Answer
= indicator of , constraint ; the -step is .
Solution
The prox of an indicator is a projection, here clipping at zero.
Exercise 2: Residuals
ADMM reports primal residual and dual residual . Is it done?
Answer
No: the constraint holds but the point is not yet optimal.
Solution
Both residuals must be small. A large dual residual means is still moving; adaptive schemes would decrease to put more weight on the objective.
Exercise 3: Effect of (code)
Run the lasso ADMM for 100 iterations with , 1 and 10 and compare the final objective gaps to the 2000-iteration solution.
Answer
Here is by far the best: its gap is below , while and are much further from the optimum.
Solution
import numpy as np
rng = np.random.default_rng(0)
n, d = 100, 200
X = rng.normal(size=(n, d)) / np.sqrt(n)
w_true = np.zeros(d); w_true[rng.choice(d, 8, replace=False)] = rng.normal(scale=3, size=8)
y = X @ w_true + 0.05 * rng.normal(size=n); lam = 0.05
soft = lambda v, k: np.sign(v) * np.maximum(np.abs(v) - k, 0)
F = lambda z: 0.5 * np.sum((X @ z - y)**2) + lam * np.abs(z).sum()
def admm(rho, iters):
Minv = np.linalg.inv(X.T @ X + rho * np.eye(d)); z = u = np.zeros(d)
for _ in range(iters):
w = Minv @ (X.T @ y + rho * (z - u)); z = soft(w + u, lam / rho); u = u + w - z
return z
best = F(admm(1.0, 2000))
for rho in (0.1, 1.0, 10.0):
gap = F(admm(rho, 100)) - best
print(f"rho = {rho:4}: gap after 100 iterations", f"{gap:.1e}" if gap > 1e-10 else "below 1e-10")rho = 0.1: gap after 100 iterations 8.5e-07
rho = 1.0: gap after 100 iterations below 1e-10
rho = 10.0: gap after 100 iterations 4.5e-01
Test yourself
ADMM alternates between…
- an -minimization, a -minimization and a multiplier update
- simplex pivots
- random restarts
- Newton steps on the full problem
In ADMM for the lasso, the -step is…
- a ridge regression
- soft thresholding
- a projection onto a sphere
- an eigenvalue computation
ADMM is typically…
- fast to moderate accuracy, slow to very high accuracy
- quadratically convergent
- only for integer problems
- faster than Newton at high accuracy