TExcelTAD
Home › Optimization › ADMM

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

min⁡ f(x)+g(z)s.t.Ax+Bz=c\min\ f(\mathbf{x}) + g(\mathbf{z}) \quad \text{s.t.} \quad A\mathbf{x} + B\mathbf{z} = \mathbf{c}

Often you create this form by duplicating a variable: min⁡f(x)+g(x)\min f(\mathbf{x}) + g(\mathbf{x}) becomes min⁡f(x)+g(z)\min f(\mathbf{x}) + g(\mathbf{z}) s.t. x−z=0\mathbf{x} - \mathbf{z} = 0. With the scaled multiplier u\mathbf{u} and penalty ρ>0\rho > 0, one iteration is

xk+1=arg⁡min⁡x f(x)+ρ2∥Ax+Bzk−c+uk∥2zk+1=arg⁡min⁡z g(z)+ρ2∥Axk+1+Bz−c+uk∥2uk+1=uk+Axk+1+Bzk+1−c\begin{aligned} \mathbf{x}_{k+1} &= \arg\min_{\mathbf{x}}\ f(\mathbf{x}) + \frac{\rho}{2}\lVert A\mathbf{x} + B\mathbf{z}_k - \mathbf{c} + \mathbf{u}_k \rVert^2 \\ \mathbf{z}_{k+1} &= \arg\min_{\mathbf{z}}\ g(\mathbf{z}) + \frac{\rho}{2}\lVert A\mathbf{x}_{k+1} + B\mathbf{z} - \mathbf{c} + \mathbf{u}_k \rVert^2 \\ \mathbf{u}_{k+1} &= \mathbf{u}_k + A\mathbf{x}_{k+1} + B\mathbf{z}_{k+1} - \mathbf{c} \end{aligned}

Instead of minimizing the augmented Lagrangian jointly over (x,z)(\mathbf{x}, \mathbf{z}), which is hard, ADMM does one pass of alternating minimization, then the multiplier update.

ADMM for the lasso

Split 12∥Xw−y∥2+λ∥z∥1\frac{1}{2}\lVert X\mathbf{w} - \mathbf{y} \rVert^2 + \lambda\lVert \mathbf{z} \rVert_1 with w=z\mathbf{w} = \mathbf{z}. The w\mathbf{w}-step is a ridge regression with a fixed matrix (factor it once), the z\mathbf{z}-step is soft thresholding:

python · try it yourself
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 ∥w−z∥\lVert \mathbf{w} - \mathbf{z} \rVert measures constraint violation, the dual residual ρ∥zk+1−zk∥\rho\lVert \mathbf{z}_{k+1} - \mathbf{z}_k \rVert measures how far from stationarity; stop when both are small. Note that z\mathbf{z} is exactly sparse at every iteration.

Total-variation denoising

Denoise a piecewise-constant signal by minimizing 12∥x−y∥2+λ∥Dx∥1\frac{1}{2}\lVert \mathbf{x} - \mathbf{y} \rVert^2 + \lambda\lVert D\mathbf{x} \rVert_1, where DD takes differences of neighbours. The L1 norm of DxD\mathbf{x} has no simple prox, but with z=Dx\mathbf{z} = D\mathbf{x} ADMM's steps are a linear solve and a soft threshold:

python · try it yourself
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 ρ>0\rho > 0 when ff and gg 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 ρ\rho 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 z\mathbf{z}-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 min⁡12∥Ax−b∥2\min \frac{1}{2}\lVert A\mathbf{x} - \mathbf{b} \rVert^2 s.t. x≥0\mathbf{x} \ge 0 in ADMM form. What is the z\mathbf{z}-step?

Answer

gg = indicator of z≥0\mathbf{z} \ge 0, constraint x−z=0\mathbf{x} - \mathbf{z} = 0; the z\mathbf{z}-step is max⁡(xk+1+uk,0)\max(\mathbf{x}_{k+1} + \mathbf{u}_k, 0).

Solution

The prox of an indicator is a projection, here clipping at zero.

Exercise 2: Residuals

ADMM reports primal residual 10−710^{-7} and dual residual 10−110^{-1}. 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 z\mathbf{z} is still moving; adaptive schemes would decrease ρ\rho to put more weight on the objective.

Exercise 3: Effect of ρ\rho (code)

Run the lasso ADMM for 100 iterations with ρ=0.1\rho = 0.1, 1 and 10 and compare the final objective gaps to the 2000-iteration solution.

Answer

Here ρ=1\rho = 1 is by far the best: its gap is below 10−1010^{-10}, while ρ=0.1\rho = 0.1 and ρ=10\rho = 10 are much further from the optimum.

Solution
python · try it yourself
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…

  1. an x\mathbf{x}-minimization, a z\mathbf{z}-minimization and a multiplier update
  2. simplex pivots
  3. random restarts
  4. Newton steps on the full problem

In ADMM for the lasso, the z\mathbf{z}-step is…

  1. a ridge regression
  2. soft thresholding
  3. a projection onto a sphere
  4. an eigenvalue computation

ADMM is typically…

  1. fast to moderate accuracy, slow to very high accuracy
  2. quadratically convergent
  3. only for integer problems
  4. faster than Newton at high accuracy