Module contents
Lesson 17 of 27Advanced 110 min

Penalties, augmented Lagrangian and ADMM

Explore methods that move constraints into the objective: quadratic penalties, ill-conditioning, multipliers, dual decomposition and ADMM.

After this lesson you can

  • Explain the ill-conditioning of quadratic penalties as ρ approaches infinity.
  • Derive the method of multipliers as dual ascent on the augmented Lagrangian.
  • Implement dual ascent and dual decomposition for separable problems.
  • Derive ADMM for lasso, distributed consensus and box-constrained regression, stopping on primal and dual residuals.
  • Tune ρ and recognize slow convergence.

Before you start

Motivation: when the solver does not fit on one machine

The methods in earlier lessons assume the entire problem is in one place: a parameter vector, an objective and a gradient computed in one go. Many real problems do not look like that.

  • Distributed data. A bank wants to fit a risk model using data from eight subsidiaries which, by law, cannot leave their countries. Each can compute on its own data, but nobody has the complete loss function.
  • Huge structured problems. A lasso with ten million features, MRI reconstruction or power allocation in an electricity grid has one easy term (a norm or a box) and one difficult term (data fitting or physics), coupled together. Each piece can be solved in one line separately; together they cannot.
  • General-purpose solvers. OSQP, a quadratic programming solver included with CVXPY and used in embedded model predictive controllers, solves problems with thousands of constraints in milliseconds without a single interior-point step.

The three situations have the same form: an objective decomposed into simple pieces, plus constraints coupling them. This lesson builds the family of methods that handles constraints by moving them into the objective. There are two ways, and the useful one combines both:

  1. Penalize constraint violation with a term ρ2∥h(x)∥2\frac{\rho}{2}\norm{h(\vb{x})}^2. This is simple, but forces ρ\rho to infinity and makes the problem intractable through ill-conditioning.
  2. Price the constraint with a Lagrange multiplier and adjust it by ascent on the dual function. If the objective is separable, the problem breaks into independent pieces that can be solved in parallel, but the method is fragile.
  3. Both at once: the augmented Lagrangian. From it come the method of multipliers and ADMM, which splits a large problem into two blocks solved in turn and powers OSQP, SCS and much of distributed and federated learning.

Throughout the lesson, the model problem is

min⁡x∈Rn  f(x)subject toAx=b,A∈Rm×n,\min_{\vb{x} \in \R^n} \; f(\vb{x}) \quad \text{subject to} \quad \mat{A}\vb{x} = \vb{b}, \qquad \mat{A} \in \R^{m\times n},

with ff convex unless stated otherwise. Inequality constraints are handled similarly (using max⁡(0,⋅)\max(0, \cdot) or slack variables); barriers that keep them strictly inside are the topic of the interior-point lesson.

Penalties: charging for violations

The most direct idea is to forget the constraint and charge for violating it.

A one-dimensional example shows everything. Minimize 12(x−3)2\frac12(x - 3)^2 subject to x=1x = 1. Clearly the optimum is x⋆=1x^\star = 1, and the KKT condition (x⋆−3)+ν⋆=0(x^\star - 3) + \nu^\star = 0 gives multiplier ν⋆=2\nu^\star = 2. The penalized problem is 12(x−3)2+ρ2(x−1)2\frac12(x - 3)^2 + \frac{\rho}{2}(x - 1)^2, a parabola whose minimum follows by differentiation:

(x−3)+ρ(x−1)=0⟹xρ=3+ρ1+ρ=1+21+ρ.(x - 3) + \rho(x - 1) = 0 \quad\Longrightarrow\quad x_\rho = \frac{3 + \rho}{1 + \rho} = 1 + \frac{2}{1 + \rho}.

With ρ=9\rho = 9 the error is 0.20.2; with ρ=99\rho = 99, 0.020.02. An error of 2⋅10−62\cdot 10^{-6} requires ρ≈106\rho \approx 10^6. Notice the error’s numerator: it is ν⋆=2\nu^\star = 2. This is no coincidence.

What a penalty guarantees

Proof

Write hρ=Axρ−b\vb{h}_\rho = \mat{A}\vb{x}_\rho - \vb{b}. Since x⋆\vb{x}^\star is feasible, Qρ(xρ)≤Qρ(x⋆)=p⋆Q_\rho(\vb{x}_\rho) \le Q_\rho(\vb{x}^\star) = p^\star, that is, f(xρ)+ρ2∥hρ∥2≤p⋆f(\vb{x}_\rho) + \frac{\rho}{2}\norm{\vb{h}_\rho}^2 \le p^\star, giving (1). By strong duality, p⋆=g(ν⋆)≤L(xρ,ν⋆)=f(xρ)+ν⋆⊤hρp^\star = g(\vb{\nu}^\star) \le L(\vb{x}_\rho, \vb{\nu}^\star) = f(\vb{x}_\rho) + \vb{\nu}^{\star\T}\vb{h}_\rho, so f(xρ)≥p⋆−∥ν⋆∥∥hρ∥f(\vb{x}_\rho) \ge p^\star - \norm{\vb{\nu}^\star}\norm{\vb{h}_\rho} by Cauchy–Schwarz. Combining the inequalities,

p⋆−∥ν⋆∥∥hρ∥+ρ2∥hρ∥2≤p⋆⟹∥hρ∥≤2∥ν⋆∥ρ.p^\star - \norm{\vb{\nu}^\star}\norm{\vb{h}_\rho} + \frac{\rho}{2}\norm{\vb{h}_\rho}^2 \le p^\star \quad\Longrightarrow\quad \norm{\vb{h}_\rho} \le \frac{2\norm{\vb{\nu}^\star}}{\rho}.

For (3), the optimality condition for xρ\vb{x}_\rho is ∇f(xρ)+A⊤(ρhρ)=0\grad f(\vb{x}_\rho) + \mat{A}\T(\rho\vb{h}_\rho) = \vb{0}, saying precisely that xρ\vb{x}_\rho minimizes the convex Lagrangian L(⋅,νρ)L(\cdot, \vb{\nu}_\rho). Thus g(νρ)=f(xρ)+ρ∥hρ∥2≥f(xρ)≥p⋆−∥ν⋆∥∥hρ∥≥p⋆−2∥ν⋆∥2/ρg(\vb{\nu}_\rho) = f(\vb{x}_\rho) + \rho\norm{\vb{h}_\rho}^2 \ge f(\vb{x}_\rho) \ge p^\star - \norm{\vb{\nu}^\star}\norm{\vb{h}_\rho} \ge p^\star - 2\norm{\vb{\nu}^\star}^2/\rho.

∎

Point (2) is the heart of the problem. At the penalty optimum, the gradient of ff must be balanced by something, and all it has is ρA⊤hρ\rho\mat{A}\T\vb{h}_\rho. That “something” must resemble A⊤ν⋆\mat{A}\T\vb{\nu}^\star, so hρ≈ν⋆/ρ\vb{h}_\rho \approx \vb{\nu}^\star/\rho: the constraint holds exactly only if ν⋆=0\vb{\nu}^\star = \vb{0}, when it was unnecessary. To achieve infeasibility ε\eps, ρ\rho must be on the order of ∥ν⋆∥/ε\norm{\vb{\nu}^\star}/\eps.

The price: ill-conditioning

Increasing ρ\rho has a cost. The penalized problem’s Hessian is

∇2Qρ(x)=∇2f(x)+ρ A⊤A.\hess Q_\rho(\vb{x}) = \hess f(\vb{x}) + \rho\,\mat{A}\T\mat{A}.

If m<nm < n, the term ρA⊤A\rho\mat{A}\T\mat{A} acts only on the row space of A\mat{A} and leaves its null space intact. By the Courant–Fischer minimax principle applied to the null space of A\mat{A} (of dimension at least n−mn - m), at least n−mn - m eigenvalues of ∇2Qρ\hess Q_\rho lie below λmax⁡(∇2f)\lambda_{\max}(\hess f), while the largest exceeds ρ∥A∥22\rho\norm{\mat{A}}_2^2. Therefore

κ(∇2Qρ)  ≥  ρ ∥A∥22λmax⁡(∇2f)  →ρ→∞  ∞.\kappa(\hess Q_\rho) \;\ge\; \frac{\rho\,\norm{\mat{A}}_2^2}{\lambda_{\max}(\hess f)} \;\xrightarrow[\rho \to \infty]{}\; \infty .

The condition number grows linearly with ρ\rho, as does the iteration count of any first-order method: gradient descent takes on the order of κlog⁡(1/ε)\kappa\log(1/\eps) steps (see GD dynamics on a quadratic). Together, achieving infeasibility ε\eps with a penalty and gradient descent costs on the order of (1/ε)log⁡(1/ε)(1/\eps)\log(1/\eps) iterations. Geometrically, contours become a narrow valley around the constraint, and the method bounces between its walls while creeping along the bottom.

InteractiveThe cost of penalizing
  • constraint a⊤x=b\vb{a}\T\vb{x} = b
  • path of xρ\vb{x}_\rho as ρ\rho varies
  • gradient descent
  • Hessian κ
  • GD iterations to 10⁻⁶
  • infeasibility |aᵀxᵨ − b|
Method
10
Minimizer xρ\vb{x}_\rho(0.2558, 0.9186)
Infeasibility ∣a⊤xρ−b∣|\vb{a}\T\vb{x}_\rho - b|0.1744
ρ h(xρ)\rho\,h(\vb{x}_\rho) versus ν⋆=1.875\nu^\star = 1.8751.7442
κ(∇2Qρ)\kappa(\nabla^2 Q_\rho)11.31
GD steps to error 10−610^{-6}123
We minimize 12(x−c)⊤Q(x−c)\frac12(\vb{x} - \vb{c})\T\mat{Q}(\vb{x} - \vb{c}) with Q=diag⁡(1,3)\mat{Q} = \diag(1, 3) subject to the line x1+x2=1x_1 + x_2 = 1. Increase ρ\rho: the minimizer xρ\vb{x}_\rho moves along the dashed segment from c\vb{c} to x⋆\vb{x}^\star (straight because xρ=c−ρh(xρ) Q−1a\vb{x}_\rho = \vb{c} - \rho h(\vb{x}_\rho)\,\mat{Q}\inv\vb{a}), but never reaches it, and contours flatten against the line. The log-log plot shows the cost: κ\kappa and GD iterations grow as ρ\rho, infeasibility decreases as 1/ρ1/\rho. Also watch ρ h(xρ)\rho\,h(\vb{x}_\rho): it approaches multiplier ν⋆=1.875\nu^\star = 1.875. Then switch to augmented Lagrangian and play: with fixed ρ\rho, the contour center slides to x⋆\vb{x}^\star and κ\kappa stays unchanged.

In the figure, with ρ=104\rho = 10^4 infeasibility is 1.9⋅10−41.9\cdot 10^{-4} and the condition number is 10410^4: gradient descent with step 1/L1/L takes over one hundred thousand steps to converge to 10−610^{-6}. For a two-variable problem. Newton’s iteration count barely suffers, since Newton is invariant to linear rescaling, but its linear system at each step is just as ill-conditioned, limiting attainable floating-point accuracy (as the sphere lab shows).

Exact penalties

Is there a penalty that does not need ρ→∞\rho \to \infty? Yes, if we give up smoothness.

Proof

For every x\vb{x}, Hölder’s inequality gives ν⋆⊤(Ax−b)≤∥ν⋆∥∞∥Ax−b∥1\vb{\nu}^{\star\T}(\mat{A}\vb{x} - \vb{b}) \le \norm{\vb{\nu}^\star}_\infty\norm{\mat{A}\vb{x} - \vb{b}}_1, strictly less than ρ∥Ax−b∥1\rho\norm{\mat{A}\vb{x} - \vb{b}}_1 if Ax≠b\mat{A}\vb{x} \neq \vb{b}. Hence f(x)+ρ∥Ax−b∥1≥f(x)+ν⋆⊤(Ax−b)=L(x,ν⋆)≥g(ν⋆)=p⋆f(\vb{x}) + \rho\norm{\mat{A}\vb{x} - \vb{b}}_1 \ge f(\vb{x}) + \vb{\nu}^{\star\T}(\mat{A}\vb{x} - \vb{b}) = L(\vb{x}, \vb{\nu}^\star) \ge g(\vb{\nu}^\star) = p^\star, with the first inequality strict at infeasible points. At feasible points, the penalty equals f(x)≥p⋆f(\vb{x}) \ge p^\star, with equality at solutions. Thus the penalty minimum is p⋆p^\star and is attained only at original solutions.

∎

The cost is nondifferentiability: ∥⋅∥1\norm{\cdot}_1 has a corner exactly on the feasible set, and nonsmooth methods such as the subgradient method are slow. Moreover, a bound on ∥ν⋆∥∞\norm{\vb{\nu}^\star}_\infty is needed in advance. Exact penalties are mainly used as merit functions to decide whether another method’s step is acceptable (for example in SQP), rather than as a method themselves.

Dual ascent and dual decomposition: setting prices

The other route comes from duality. The model problem’s Lagrangian is L(x,ν)=f(x)+ν⊤(Ax−b)L(\vb{x}, \vb{\nu}) = f(\vb{x}) + \vb{\nu}\T(\mat{A}\vb{x} - \vb{b}) and its dual function, g(ν)=inf⁡xL(x,ν)g(\vb{\nu}) = \inf_{\vb{x}} L(\vb{x}, \vb{\nu}), is concave. Under strong duality, maximizing gg gives ν⋆\vb{\nu}^\star, and then x⋆\vb{x}^\star is recovered by minimizing L(⋅,ν⋆)L(\cdot, \vb{\nu}^\star) (if that minimizer is unique). Dual ascent maximizes gg by gradient ascent:

xk+1=arg min⁡x  L(x,νk),νk+1=νk+αk(Axk+1−b).\begin{aligned} \vb{x}^{k+1} &= \argmin_{\vb{x}}\; L(\vb{x}, \vb{\nu}^k), \\ \vb{\nu}^{k+1} &= \vb{\nu}^k + \alpha_k(\mat{A}\vb{x}^{k+1} - \vb{b}). \end{aligned}

The second line is a gradient step because, when gg is differentiable, ∇g(ν)=Ax~−b\grad g(\vb{\nu}) = \mat{A}\tilde{\vb{x}} - \vb{b}, the constraint residual at the Lagrangian minimizer x~\tilde{\vb{x}}. You will prove it in the exercises; it takes one line. The economic interpretation is immediate: ν\vb{\nu} are prices, the x\vb{x} step is what each agent does at those prices, and the ν\vb{\nu} step raises prices for over-demanded resources and lowers them for excess resources.

When does it work? If ff is μ\mu-strongly convex, g(ν)=−b⊤ν−f∗(−A⊤ν)g(\vb{\nu}) = -\vb{b}\T\vb{\nu} - f^*(-\mat{A}\T\vb{\nu}) in terms of the conjugate, and f∗f^* has a (1/μ)(1/\mu)-Lipschitz gradient. Then ∇g\grad g is (∥A∥22/μ)(\norm{\mat{A}}_2^2/\mu)-Lipschitz and dual ascent with α≤μ/∥A∥22\alpha \le \mu/\norm{\mat{A}}_2^2 converges like any gradient descent. If ff is not strictly convex, everything breaks: with f(x)=xf(x) = x and constraint x=1x = 1, the Lagrangian x+ν(x−1)x + \nu(x - 1) is unbounded below except at ν=−1\nu = -1, and the x\vb{x} step is undefined.

Dual decomposition

What makes dual ascent interesting is not its mediocre speed but its structure. Suppose the objective is separable, f(x)=∑i=1Nfi(xi)f(\vb{x}) = \sum_{i=1}^N f_i(\vb{x}_i) with x=(x1,…,xN)\vb{x} = (\vb{x}_1, \dots, \vb{x}_N), and constraints couple blocks: Ax=∑iAixi=b\mat{A}\vb{x} = \sum_i \mat{A}_i\vb{x}_i = \vb{b}. Then the Lagrangian also separates,

L(x,ν)=∑i=1N(fi(xi)+ν⊤Aixi)−ν⊤b,L(\vb{x}, \vb{\nu}) = \sum_{i=1}^N \Big( f_i(\vb{x}_i) + \vb{\nu}\T\mat{A}_i\vb{x}_i \Big) - \vb{\nu}\T\vb{b},

and minimizing it over x\vb{x} means NN independent problems.

The problem with dual decomposition is its assumptions: each fif_i must be strictly convex (or the xi\vb{x}_i step is undefined), the step α\alpha must be small and well chosen, and convergence is slow. In the consensus lab you will see that with the safe step it remains 2.5% from optimum after 150 iterations, while ADMM reaches 10−1010^{-10}. The solution is to augment the Lagrangian.

The augmented Lagrangian and the method of multipliers

It is the usual Lagrangian plus a quadratic penalty, and also the ordinary Lagrangian of the equivalent problem min⁡f(x)+ρ2∥h(x)∥2\min f(\vb{x}) + \frac{\rho}{2}\norm{h(\vb{x})}^2 subject to h(x)=0h(\vb{x}) = \vb{0}, which has the same solutions because the added term vanishes at feasible points. Two details distinguish it from the earlier methods.

The multiplier step is exactly ρ\rho. This is not arbitrary. The optimality condition for xk+1\vb{x}^{k+1} is

∇f(xk+1)+Jh(xk+1)⊤(νk+ρ h(xk+1))=0,\grad f(\vb{x}^{k+1}) + \mat{J}_h(\vb{x}^{k+1})\T\big(\vb{\nu}^k + \rho\,h(\vb{x}^{k+1})\big) = \vb{0},

and the parenthesized expression is νk+1\vb{\nu}^{k+1}. Thus the pair (xk+1,νk+1)(\vb{x}^{k+1}, \vb{\nu}^{k+1}) satisfies the KKT stationarity condition ∇f+Jh⊤ν=0\grad f + \mat{J}_h\T\vb{\nu} = \vb{0} exactly at every iteration. Only feasibility remains, and the loop corrects it.

We no longer need ρ→∞\rho \to \infty. In the example 12(x−3)2\frac12(x - 3)^2 with x=1x = 1, the xx step gives (x−3)+νk+ρ(x−1)=0(x - 3) + \nu^k + \rho(x - 1) = 0, so xk+1−1=(2−νk)/(1+ρ)x^{k+1} - 1 = (2 - \nu^k)/(1 + \rho), and the multiplier step gives

νk+1−2=(νk−2)+ρ(xk+1−1)=νk−21+ρ.\nu^{k+1} - 2 = (\nu^k - 2) + \rho(x^{k+1} - 1) = \frac{\nu^k - 2}{1 + \rho}.

The multiplier error is divided by 1+ρ1 + \rho at each iteration. With ρ=9\rho = 9 and ν0=0\nu^0 = 0, the first iteration agrees with the penalty (x1−1=0.2x^1 - 1 = 0.2), but the second gives 0.020.02, the third 0.0020.002, and at the fifth the error is 2⋅10−52\cdot 10^{-5}. The pure penalty would need ρ≈105\rho \approx 10^5 for the same result, and in higher dimensions that means a condition number roughly ten thousand times worse than with ρ=9\rho = 9 (recall κ\kappa grows as ρ\rho). In the figure above, “augmented Lagrangian” mode does the same in two dimensions: the contraction factor is 1/(1+ρ a⊤Q−1a)1/(1 + \rho\,\vb{a}\T\mat{Q}\inv\vb{a}) and the condition number is that of the penalty at the same moderate ρ\rho.

Why it works: proximal point on the dual

The deeper reason is that the method of multipliers is a known algorithm applied to the dual function.

Proof

The function ν↦g(ν)−12ρ∥ν−νk∥2\vb{\nu} \mapsto g(\vb{\nu}) - \frac{1}{2\rho}\norm{\vb{\nu} - \vb{\nu}^k}^2 is strongly concave, so has at most one maximizer, and ν+\vb{\nu}^+ is one if and only if (ν+−νk)/ρ(\vb{\nu}^+ - \vb{\nu}^k)/\rho is a supergradient of gg at ν+\vb{\nu}^+. Set ν+=νk+ρ(Axk+1−b)\vb{\nu}^+ = \vb{\nu}^k + \rho(\mat{A}\vb{x}^{k+1} - \vb{b}), so (ν+−νk)/ρ=Axk+1−b(\vb{\nu}^+ - \vb{\nu}^k)/\rho = \mat{A}\vb{x}^{k+1} - \vb{b}. The optimality condition for xk+1\vb{x}^{k+1} for Lρ(⋅,νk)L_\rho(\cdot, \vb{\nu}^k) is 0∈∂f(xk+1)+A⊤ν+\vb{0} \in \partial f(\vb{x}^{k+1}) + \mat{A}\T\vb{\nu}^+, saying xk+1\vb{x}^{k+1} minimizes the convex Lagrangian L(⋅,ν+)L(\cdot, \vb{\nu}^+). Therefore g(ν+)=L(xk+1,ν+)g(\vb{\nu}^+) = L(\vb{x}^{k+1}, \vb{\nu}^+) and, for every ν\vb{\nu},

g(ν)≤L(xk+1,ν)=L(xk+1,ν+)+(ν−ν+)⊤(Axk+1−b)=g(ν+)+(Axk+1−b)⊤(ν−ν+),g(\vb{\nu}) \le L(\vb{x}^{k+1}, \vb{\nu}) = L(\vb{x}^{k+1}, \vb{\nu}^+) + (\vb{\nu} - \vb{\nu}^+)\T(\mat{A}\vb{x}^{k+1} - \vb{b}) = g(\vb{\nu}^+) + (\mat{A}\vb{x}^{k+1} - \vb{b})\T(\vb{\nu} - \vb{\nu}^+),

which is precisely the supergradient inequality.

∎

The proximal point algorithm converges for any fixed ρ>0\rho > 0, requiring neither differentiability nor strict convexity: if a maximizer ν⋆\vb{\nu}^\star of gg exists, g(ν⋆)−g(νk)≤∥ν0−ν⋆∥2/(2ρk)g(\vb{\nu}^\star) - g(\vb{\nu}^k) \le \norm{\vb{\nu}^0 - \vb{\nu}^\star}^2/(2\rho k) (Güler, 1991), and convergence is linear when −g-g is strongly convex, as in the example. A larger ρ\rho accelerates convergence, but is not necessary for exactness. Proximal regularization also makes the x\vb{x} step well defined where dual ascent failed: with f(x)=xf(x) = x and x=1x = 1, the augmented Lagrangian x+ν(x−1)+ρ2(x−1)2x + \nu(x - 1) + \frac{\rho}{2}(x - 1)^2 is a parabola with a minimum for any ν\nu.

ADMM: splitting the problem into two blocks

The method of multipliers solves the conditioning problem but destroys separability: ρ2∥∑iAixi−b∥2\frac{\rho}{2}\norm{\sum_i \mat{A}_i\vb{x}_i - \vb{b}}^2 mixes all the blocks, so the x\vb{x} step can no longer be distributed. ADMM recovers the best of both with a simple idea: minimize the augmented Lagrangian by blocks in a single pass, rather than exactly.

Consider the problem in two-block form

min⁡x,z  f(x)+g(z)subject toAx+Bz=c,\min_{\vb{x}, \vb{z}}\; f(\vb{x}) + g(\vb{z}) \quad \text{subject to} \quad \mat{A}\vb{x} + \mat{B}\vb{z} = \vb{c},

with ff and gg convex, closed and proper (they may take +∞+\infty, so constraints can be indicators). Its augmented Lagrangian is

Lρ(x,z,ν)=f(x)+g(z)+ν⊤(Ax+Bz−c)+ρ2∥Ax+Bz−c∥22.L_\rho(\vb{x}, \vb{z}, \vb{\nu}) = f(\vb{x}) + g(\vb{z}) + \vb{\nu}\T(\mat{A}\vb{x} + \mat{B}\vb{z} - \vb{c}) + \frac{\rho}{2}\norm{\mat{A}\vb{x} + \mat{B}\vb{z} - \vb{c}}_2^2 .

The scaled form comes from completing the square: ν⊤r+ρ2∥r∥2=ρ2∥r+u∥2−ρ2∥u∥2\vb{\nu}\T\vb{r} + \frac{\rho}{2}\norm{\vb{r}}^2 = \frac{\rho}{2}\norm{\vb{r} + \vb{u}}^2 - \frac{\rho}{2}\norm{\vb{u}}^2, and the last term depends on neither x\vb{x} nor z\vb{z}. You will reconstruct this step by step in an exercise. Notice uk=u0+∑j≤krj\vb{u}^k = \vb{u}^0 + \sum_{j \le k}\vb{r}^j: the scaled multiplier is the cumulative sum of residuals, like a PID controller’s integral term.

The most important case is A=I\mat{A} = \mat{I}, B=−I\mat{B} = -\mat{I}, c=0\vb{c} = \vb{0}: the constraint x=z\vb{x} = \vb{z} just says the two copies agree. Each step is then a proximal operator,

xk+1=prox⁡f/ρ(zk−uk),zk+1=prox⁡g/ρ(xk+1+uk),uk+1=uk+xk+1−zk+1,\vb{x}^{k+1} = \operatorname{prox}_{f/\rho}(\vb{z}^k - \vb{u}^k), \qquad \vb{z}^{k+1} = \operatorname{prox}_{g/\rho}(\vb{x}^{k+1} + \vb{u}^k), \qquad \vb{u}^{k+1} = \vb{u}^k + \vb{x}^{k+1} - \vb{z}^{k+1},

and ADMM works for any f+gf + g where each term has a cheap proximal, even when their sum does not. This is the same situation as proximal gradient, with two differences: ADMM requires neither function to be differentiable, and treats ff by its proximal rather than its gradient, allowing large steps when ff is ill-conditioned but its proximal is a linear system factored once.

InteractiveADMM in two blocks
  • xk\vb{x}^k (ff block)
  • zk\vb{z}^k (gg block)
  • optimum
  • box [−1,1]2[-1, 1]^2
  • contours of ff
  • primal ‖r‖
  • dual ‖s‖
  • fixed ρ
  • adaptive ρ
Term g
0.1
start
Start: z0=(−1,−1)\vb{z}^0 = (-1, -1) and u0=0\vb{u}^0 = \vb{0}. Press play or advance one substep.
ρ\rho on this iteration0.1
Primal residual ∥xk−zk∥\|\vb{x}^k - \vb{z}^k\|·
Dual residual ρ∥zk−zk−1∥\rho\|\vb{z}^k - \vb{z}^{k-1}\|·
f(x)+g(z)−p⋆f(\vb{x}) + g(\vb{z}) - p^\star5.96
Iterations to 10−610^{-6}183
Best fixed ρ\rho on chart1.58 (26 it.)
We minimize a quadratic ff (blue contours, unconstrained minimum at p\vb{p}) plus gg, the indicator of the box [−1,1]2[-1, 1]^2 or the norm λ∥z∥1\lambda\norm{\vb{z}}_1. Advance one substep at a time: the x\vb{x} step pulls from zk−uk\vb{z}^k - \vb{u}^k toward the minimum of ff; the z\vb{z} step projects (or shrinks) xk+1+uk\vb{x}^{k+1} + \vb{u}^k; the u\vb{u} step accumulates disagreement x−z\vb{x} - \vb{z}. Top right are the primal and dual residuals at each iteration. With ρ=0.1\rho = 0.1 the primal dominates: x\vb{x} and z\vb{z} take time to agree. Increase ρ\rho to 10 and watch the roles reverse. The bottom plot matters in practice: iterations to 10−610^{-6} form a U in ρ\rho, flattened by adaptive tuning.

Douglas–Rachford, the close relative

With constraint x=z\vb{x} = \vb{z}, ADMM is a classical algorithm in disguise. Define wk=zk+uk\vb{w}^k = \vb{z}^k + \vb{u}^k. Since zk=prox⁡g/ρ(xk+uk−1)\vb{z}^k = \operatorname{prox}_{g/\rho}(\vb{x}^k + \vb{u}^{k-1}) and uk=uk−1+xk−zk\vb{u}^k = \vb{u}^{k-1} + \vb{x}^k - \vb{z}^k, we get xk+uk−1=wk\vb{x}^k + \vb{u}^{k-1} = \vb{w}^k, that is, zk=prox⁡g/ρ(wk)\vb{z}^k = \operatorname{prox}_{g/\rho}(\vb{w}^k) and uk=wk−zk\vb{u}^k = \vb{w}^k - \vb{z}^k. Substituting into the iterations,

wk+1=wk+prox⁡f/ρ(2prox⁡g/ρ(wk)−wk)−prox⁡g/ρ(wk),\vb{w}^{k+1} = \vb{w}^k + \operatorname{prox}_{f/\rho}\big(2\operatorname{prox}_{g/\rho}(\vb{w}^k) - \vb{w}^k\big) - \operatorname{prox}_{g/\rho}(\vb{w}^k),

which is Douglas–Rachford (1956, devised for heat equations) applied to g+fg + f. For the general problem with A\mat{A} and B\mat{B}, Gabay (1983) proved that ADMM is Douglas–Rachford applied to the dual. This connection enables analysis of ADMM using monotone operator theory and is the thread of Ryu and Yin’s book in the sources: almost all splitting methods (proximal gradient, Douglas–Rachford, ADMM, Chambolle–Pock) are fixed-point iterations of averaged operators.

Canonical examples

Lasso

Lasso, min⁡12∥Ax−b∥22+λ∥x∥1\min \frac12\norm{\mat{A}\vb{x} - \vb{b}}_2^2 + \lambda\norm{\vb{x}}_1, splits into f(x)=12∥Ax−b∥2f(\vb{x}) = \frac12\norm{\mat{A}\vb{x} - \vb{b}}^2 and g(z)=λ∥z∥1g(\vb{z}) = \lambda\norm{\vb{z}}_1 with x=z\vb{x} = \vb{z}. The two proximals are:

xk+1=(A⊤A+ρI)−1(A⊤b+ρ(zk−uk)),zk+1=Sλ/ρ(xk+1+uk),uk+1=uk+xk+1−zk+1,\begin{aligned} \vb{x}^{k+1} &= (\mat{A}\T\mat{A} + \rho\mat{I})\inv\big(\mat{A}\T\vb{b} + \rho(\vb{z}^k - \vb{u}^k)\big), \\ \vb{z}^{k+1} &= S_{\lambda/\rho}(\vb{x}^{k+1} + \vb{u}^k), \\ \vb{u}^{k+1} &= \vb{u}^k + \vb{x}^{k+1} - \vb{z}^{k+1}, \end{aligned}

where StS_t is soft thresholding. The x\vb{x} step is a linear system with the same matrix at every iteration, symmetric positive definite. Factor it once by Cholesky, A⊤A+ρI=LL⊤\mat{A}\T\mat{A} + \rho\mat{I} = \mat{L}\mat{L}\T, at cost O(n3)\bigO(n^3), and each iteration becomes two triangular solves costing O(n2)\bigO(n^2). If features greatly outnumber examples (n≫mn \gg m), the Woodbury identity,

(A⊤A+ρI)−1=1ρI−1ρ2A⊤(Im+1ρAA⊤)−1A,(\mat{A}\T\mat{A} + \rho\mat{I})\inv = \frac{1}{\rho}\mat{I} - \frac{1}{\rho^2}\mat{A}\T\Big(\mat{I}_m + \frac{1}{\rho}\mat{A}\mat{A}\T\Big)\inv\mat{A},

reduces the factorization to an m×mm \times m matrix. This is ADMM’s structural advantage over ISTA and FISTA: all second-order information in ff enters the x\vb{x} step and is paid for only once.

Consensus

To minimize ∑i=1Nfi(x)\sum_{i=1}^N f_i(\vb{x}) when each fif_i lives on a different machine, give each node its own copy xi\vb{x}_i and require all copies to agree with a global variable:

min⁡x1,…,xN,z  ∑i=1Nfi(xi)subject toxi−z=0,i=1,…,N.\min_{\vb{x}_1, \dots, \vb{x}_N, \vb{z}}\; \sum_{i=1}^N f_i(\vb{x}_i) \quad \text{subject to} \quad \vb{x}_i - \vb{z} = \vb{0}, \quad i = 1, \dots, N.

The x\vb{x} block contains all copies and the z\vb{z} block is the global variable. ADMM gives

xik+1=arg min⁡xi  fi(xi)+ρ2∥xi−zk+uik∥2(in parallel, at each node),zk+1=1N∑i=1N(xik+1+uik)(una reduccioˊn, como un all-reduce),uik+1=uik+xik+1−zk+1.\begin{aligned} \vb{x}_i^{k+1} &= \argmin_{\vb{x}_i}\; f_i(\vb{x}_i) + \frac{\rho}{2}\norm{\vb{x}_i - \vb{z}^k + \vb{u}_i^k}^2 \qquad \text{(in parallel, at each node)}, \\ \vb{z}^{k+1} &= \frac{1}{N}\sum_{i=1}^N\big(\vb{x}_i^{k+1} + \vb{u}_i^k\big) \qquad \text{(una reducción, como un all-reduce)}, \\ \vb{u}_i^{k+1} &= \vb{u}_i^k + \vb{x}_i^{k+1} - \vb{z}^{k+1}. \end{aligned}

Each node solves its local problem with a quadratic pull toward current consensus, corrected by its own multiplier; data never leave the node, only parameter vectors travel. The mean of ui\vb{u}_i vanishes after the first iteration, so zk+1\vb{z}^{k+1} is simply the mean of xik+1\vb{x}_i^{k+1}. If a regularizer g(z)g(\vb{z}) is added, the z\vb{z} step becomes a proximal of that mean.

InteractiveDistributed consensus
  • each node’s valley (hollow circle: local solution)
  • estimate vbxik\\vb{x}_i^k
  • consensus vbzk\\vb{z}^k
  • node 1 (biasable)
12345678z
  • primal ‖r‖ (disagreement)
  • dual ‖s‖
  • ‖zᵏ − w*‖
k = 60
1.0
0.00
Active nodes8 of 8
Disagreement ∥rk∥\|\vb{r}^k\|3.7·10⁻³
Dual residual ∥sk∥\|\vb{s}^k\|6.9·10⁻⁵
Global error ∥zk−w⋆∥\|\vb{z}^k - \vb{w}^\star\|5.8·10⁻⁴
∥w⋆−wtrue∥\|\vb{w}^\star - \vb{w}_{\text{true}}\|0.0568
Eight nodes fit a linear regression y≈w⊤ay \approx \vb{w}\T\vb{a} with w∈R2\vb{w} \in \R^2. Each node's features mostly point in one direction (the segment inside each circle in the diagram), so by itself each node barely determines w\vb{w} in the perpendicular direction: its near-optimal solutions form an elongated valley (faint lines). Consensus is the intersection of all valleys. Play from k=0k = 0 and watch estimates xik\vb{x}_i^k converge to zk\vb{z}^k; each diagram spoke's thickness is that node's disagreement. Turn nodes off by clicking them, change ρ\rho or add bias to node 1 and compare w⋆\vb{w}^\star with the truth.

The figure shows two lessons independent of the example. First, information from one node may be nearly useless alone and decisive together, and ADMM combines it without moving data. Second, less comfortably, ADMM faithfully solves the global problem, so if one node has biased data, consensus inherits that bias, weighted by how informative that node is in each direction. Making consensus robust requires changing the problem (robust losses, medians, anomaly detection), not the algorithm.

Box-constrained least squares

For min⁡12∥Ax−b∥2\min \frac12\norm{\mat{A}\vb{x} - \vb{b}}^2 subject to x‾≤x≤x‾\underline{\vb{x}} \le \vb{x} \le \overline{\vb{x}}, take gg as the box indicator. The x\vb{x} step is the same linear system as lasso, and the z\vb{z} step is a projection, which for a box clips coordinate by coordinate: zk+1=min⁡(max⁡(xk+1+uk,x‾),x‾)\vb{z}^{k+1} = \min(\max(\vb{x}^{k+1} + \vb{u}^k, \underline{\vb{x}}), \overline{\vb{x}}). This is “Box” mode in the two-block figure. The pattern is general: any convex set with cheap projection (balls, simplices, the semidefinite cone via eigendecomposition) can be incorporated into ADMM without changing the rest.

Resource allocation with ADMM

The data center example also has an ADMM version, the exchange problem: min⁡∑ifi(xi)\min \sum_i f_i(\vb{x}_i) subject to ∑ixi=0\sum_i \vb{x}_i = \vb{0} (what one gives up another receives). With a little algebra (Boyd and coauthors, section 7.3), ADMM becomes xik+1=arg min⁡fi(xi)+ρ2∥xi−xik+xˉk+uk∥2\vb{x}_i^{k+1} = \argmin f_i(\vb{x}_i) + \frac{\rho}{2}\norm{\vb{x}_i - \vb{x}_i^k + \bar{\vb{x}}^k + \vb{u}^k}^2 and uk+1=uk+xˉk+1\vb{u}^{k+1} = \vb{u}^k + \bar{\vb{x}}^{k+1}, with xˉ\bar{\vb{x}} the mean request. This is dual decomposition with two changes: the price is ρu\rho\vb{u}, and each agent adds a pull preventing a sudden reaction to the price. This pull removes the need for strict convexity and step-size fragility.

Convergence, residuals and tuning ρ

Proof

Proof sketch from appendix A of Boyd and coauthors. Let Vk=1ρ∥νk−ν⋆∥2+ρ∥B(zk−z⋆)∥2V^k = \frac{1}{\rho}\norm{\vb{\nu}^k - \vb{\nu}^\star}^2 + \rho\norm{\mat{B}(\vb{z}^k - \vb{z}^\star)}^2. Combine three inequalities (the saddle-point inequality p⋆−pk+1≤ν⋆⊤rk+1p^\star - p^{k+1} \le \vb{\nu}^{\star\T}\vb{r}^{k+1}; the one from the optimality conditions of the x\vb{x} and z\vb{z} steps; and monotonicity of the subdifferential of gg between consecutive iterations) to obtain

Vk+1≤Vk−ρ∥rk+1∥2−ρ∥B(zk+1−zk)∥2.V^{k+1} \le V^k - \rho\norm{\vb{r}^{k+1}}^2 - \rho\norm{\mat{B}(\vb{z}^{k+1} - \vb{z}^k)}^2 .

VV is a Lyapunov function: it does not increase and, summing the inequality, ∑k(∥rk+1∥2+∥B(zk+1−zk)∥2)≤V0/ρ<∞\sum_k \big(\norm{\vb{r}^{k+1}}^2 + \norm{\mat{B}(\vb{z}^{k+1} - \vb{z}^k)}^2\big) \le V^0/\rho < \infty. Thus rk→0\vb{r}^k \to \vb{0} and B(zk+1−zk)→0\mat{B}(\vb{z}^{k+1} - \vb{z}^k) \to \vb{0}, and bounds on pk+1−p⋆p^{k+1} - p^\star in terms of those two terms give (2). Boundedness of VV bounds νk\vb{\nu}^k, and a limit-point argument gives (3).

∎

The theorem is generous in assumptions (no differentiability, strict convexity or large ρ\rho needed) and modest in conclusions: it does not guarantee that xk\vb{x}^k and zk\vb{z}^k converge, only the residual, value and multiplier (under additional assumptions, such as strictly convex ff, the primal iterates also converge). For speed, averaged errors decay as O(1/k)\bigO(1/k) generally (He and Yuan, 2012), and convergence is linear if one function is strongly convex and smooth and the matrices have full rank (Deng and Yin, 2016).

Primal and dual residuals

The two-block problem has three optimality conditions: primal feasibility, Ax⋆+Bz⋆=c\mat{A}\vb{x}^\star + \mat{B}\vb{z}^\star = \vb{c}, and two dual feasibility conditions, 0∈∂f(x⋆)+A⊤ν⋆\vb{0} \in \partial f(\vb{x}^\star) + \mat{A}\T\vb{\nu}^\star and 0∈∂g(z⋆)+B⊤ν⋆\vb{0} \in \partial g(\vb{z}^\star) + \mat{B}\T\vb{\nu}^\star. Which does ADMM satisfy each iteration?

  • The z\vb{z} step gives 0∈∂g(zk+1)+B⊤νk+ρB⊤rk+1=∂g(zk+1)+B⊤νk+1\vb{0} \in \partial g(\vb{z}^{k+1}) + \mat{B}\T\vb{\nu}^k + \rho\mat{B}\T\vb{r}^{k+1} = \partial g(\vb{z}^{k+1}) + \mat{B}\T\vb{\nu}^{k+1}: the dual condition for gg always holds exactly.
  • The x\vb{x} step gives 0∈∂f(xk+1)+A⊤(νk+ρ(Axk+1+Bzk−c))\vb{0} \in \partial f(\vb{x}^{k+1}) + \mat{A}\T\big(\vb{\nu}^k + \rho(\mat{A}\vb{x}^{k+1} + \mat{B}\vb{z}^k - \vb{c})\big). Adding and subtracting ρA⊤Bzk+1\rho\mat{A}\T\mat{B}\vb{z}^{k+1},
sk+1:=ρA⊤B(zk+1−zk)  ∈  ∂f(xk+1)+A⊤νk+1.\vb{s}^{k+1} := \rho\mat{A}\T\mat{B}(\vb{z}^{k+1} - \vb{z}^k) \;\in\; \partial f(\vb{x}^{k+1}) + \mat{A}\T\vb{\nu}^{k+1}.

Thus two residuals remain to monitor: the primal residual rk+1\vb{r}^{k+1} and the dual residual sk+1\vb{s}^{k+1}, measuring the failure of ff‘s dual condition. For lasso and consensus, with A=I\mat{A} = \mat{I} and B=−I\mat{B} = -\mat{I}, the dual is simply ρ\rho times the movement of z\vb{z}. The standard stopping criterion (Boyd and coauthors, section 3.3) compares them with tolerances combining absolute and relative parts:

∥rk∥2≤εpri=p εabs+εrelmax⁡{∥Axk∥,∥Bzk∥,∥c∥},∥sk∥2≤εdual=n εabs+εrel∥A⊤νk∥,\norm{\vb{r}^k}_2 \le \eps^{\text{pri}} = \sqrt{p}\,\eps^{\text{abs}} + \eps^{\text{rel}}\max\{\norm{\mat{A}\vb{x}^k}, \norm{\mat{B}\vb{z}^k}, \norm{\vb{c}}\}, \qquad \norm{\vb{s}^k}_2 \le \eps^{\text{dual}} = \sqrt{n}\,\eps^{\text{abs}} + \eps^{\text{rel}}\norm{\mat{A}\T\vb{\nu}^k},

where pp is the number of constraints and nn the dimension of x\vb{x}. Typical values: εabs=10−4\eps^{\text{abs}} = 10^{-4} or 10−610^{-6} and εrel=10−3\eps^{\text{rel}} = 10^{-3} or 10−410^{-4}, depending on accuracy required. In scaled form, A⊤νk=ρA⊤uk\mat{A}\T\vb{\nu}^k = \rho\mat{A}\T\vb{u}^k.

The role of ρ and adaptive tuning

In ADMM, ρ\rho no longer determines whether the method converges, but determines how fast; its effect appears in the residuals. Large ρ\rho heavily penalizes disagreement: x\vb{x} and z\vb{z} quickly stick together (small primal residual), but each step moves them little and the dual residual, containing a factor ρ\rho, dominates. Small ρ\rho does the opposite: each block pursues its objective almost ignoring the other. In the two-block figure you saw a U, with a minimum near ρ≈1\rho \approx 1, the scale of ff‘s curvature (its eigenvalues are 0.630.63 and 1.971.97). For a quadratic, the rule of thumb is to choose ρ\rho on the order of the geometric mean of the extreme eigenvalues of the curvature entering the x\vb{x} step.

When that scale is unknown, adapt it during iteration with residual balancing (He, Yang and Wang, 2000):

ρk+1={τρkif ∥rk∥>μ∥sk∥,ρk/τif ∥sk∥>μ∥rk∥,ρkotherwise,\rho^{k+1} = \begin{cases} \tau\rho^k & \text{if } \norm{\vb{r}^k} > \mu\norm{\vb{s}^k}, \\ \rho^k/\tau & \text{if } \norm{\vb{s}^k} > \mu\norm{\vb{r}^k}, \\ \rho^k & \text{otherwise,} \end{cases}

with typical values μ=10\mu = 10 and τ=2\tau = 2. Two easily forgotten details: changing ρ\rho requires rescaling the scaled multiplier (u←u/τ\vb{u} \leftarrow \vb{u}/\tau if ρ\rho is multiplied by τ\tau), because ν=ρu\vb{\nu} = \rho\vb{u} is conserved; and if the x\vb{x} step uses a cached factorization, it must be refactored. Solvers therefore change ρ\rho only a few times. OSQP also compares residuals normalized by their scales (the same ones in the tolerances), not absolute residuals, because poorly scaled data make absolute comparisons misleading, as the lab shows.

Another standard improvement is over-relaxation: replace Axk+1\mat{A}\vb{x}^{k+1} by αAxk+1−(1−α)(Bzk−c)\alpha\mat{A}\vb{x}^{k+1} - (1 - \alpha)(\mat{B}\vb{z}^k - \vb{c}) in the z\vb{z} and u\vb{u} steps, with α∈[1.5,1.8]\alpha \in [1.5, 1.8] (Boyd and coauthors, section 3.4.3). It costs the same per iteration and often appreciably reduces iteration count; OSQP defaults to α=1.6\alpha = 1.6.

ADMM as a solver engine: OSQP and SCS

OSQP solves quadratic programs in the form

min⁡x  12x⊤Px+q⊤xsubject tol≤Ax≤u.\min_{\vb{x}}\; \frac12\vb{x}\T\mat{P}\vb{x} + \vb{q}\T\vb{x} \quad \text{subject to} \quad \vb{l} \le \mat{A}\vb{x} \le \vb{u}.

(Here l\vb{l} and u\vb{u} are bounds, using OSQP’s notation, not the scaled multiplier.) The splitting is this lesson’s: a variable z=Ax\vb{z} = \mat{A}\vb{x} carrying constraints as the indicator of the box [l,u][\vb{l}, \vb{u}], and a copy of x\vb{x} carrying the quadratic. The z\vb{z} step clips coordinate by coordinate. The x\vb{x} step solves a linear system with the quasi-definite matrix

[P+σIA⊤A−ρ−1I],\begin{bmatrix} \mat{P} + \sigma\mat{I} & \mat{A}\T \\ \mat{A} & -\rho\inv\mat{I} \end{bmatrix},

which is factored once with a sparse LDL⊤\mat{L}\mat{D}\mat{L}\T and reused at every iteration (refactored only when adaptive tuning changes ρ\rho). Add data prescaling (Ruiz equilibration) so ρ\rho makes sense for all constraints at once, over-relaxation with α=1.6\alpha = 1.6, infeasibility detection from differences between iterates, and final polishing that, once the active set is identified, solves an equality system for a high-accuracy solution. This is the full recipe for industrial ADMM, explaining why it runs on microcontrollers, where each iteration is a few triangular solves.

SCS (O’Donoghue and coauthors, 2016) does the same for conic programs: it writes primal and dual optimality conditions as a linear system plus a cone (the “homogeneous self-dual embedding”) and applies ADMM to that form. Each iteration solves with a fixed matrix and projects onto the cone (an eigendecomposition for the semidefinite cone). It thus solves enormous SOCPs and SDPs to moderate accuracy, and also detects infeasibility or unboundedness.

Implementation from scratch

Augmented Lagrangian on a sphere

Start with a nonconvex problem with a nonlinear equality constraint: minimize the indefinite quadratic f(x)=12x⊤Bx+g⊤xf(\vb{x}) = \frac12\vb{x}\T\mat{B}\vb{x} + \vb{g}\T\vb{x} on the sphere ∥x∥2=1\norm{\vb{x}}_2 = 1, with h(x)=∥x∥2−1h(\vb{x}) = \norm{\vb{x}}^2 - 1. This is the trust-region subproblem when the solution lies on the boundary, and has a reference solution: KKT gives (B+2νI)x=−g(\mat{B} + 2\nu\mat{I})\vb{x} = -\vb{g} with ∥x∥=1\norm{\vb{x}} = 1 and B+2ν⋆I\mat{B} + 2\nu^\star\mat{I} semidefinite, a one-variable equation in ν\nu. The inner solver is damped Newton (with Hessian eigenvalues replaced by their absolute values so the direction always descends).

[ ]Increasing penalty versus multipliersBrowser
import numpy as np
from scipy.optimize import brentq

rng = np.random.default_rng(1)
n = 10
Qr, _ = np.linalg.qr(rng.normal(size=(n, n)))
evals = np.linspace(-2, 3, n)                       # B indefinida
Bm = Qr @ np.diag(evals) @ Qr.T
g = rng.normal(size=n)
f = lambda x: 0.5 * x @ Bm @ x + g @ x

# referencia: (B + 2 nu I) x = -g con ||x|| = 1 y nu > -lambda_min / 2 (ecuación secular)
c = Qr.T @ g
nu_star = brentq(lambda nu: np.sum((c / (evals + 2 * nu)) ** 2) - 1, -evals[0] / 2 + 1e-9, 100)
x_star = -Qr @ (c / (evals + 2 * nu_star))
print(f"nu* = {nu_star:.10f}   ||x*|| = {np.linalg.norm(x_star):.12f}   f* = {f(x_star):.10f}")

def newton_inner(x, nu, rho, tol=1e-12, max_iter=100):
    """min_x f(x) + nu h(x) + rho/2 h(x)^2 con h(x) = ||x||^2 - 1, por Newton amortiguado."""
    def F(x):
        h = x @ x - 1
        return f(x) + nu * h + 0.5 * rho * h * h
    for its in range(1, max_iter + 1):
        h = x @ x - 1
        grad = Bm @ x + g + 2 * (nu + rho * h) * x
        if np.linalg.norm(grad) <= tol * max(1.0, rho):
            break
        H = Bm + 2 * (nu + rho * h) * np.eye(n) + 4 * rho * np.outer(x, x)
        w, V = np.linalg.eigh(H)
        d = -V @ ((V.T @ grad) / np.maximum(np.abs(w), 1e-8))   # siempre de descenso
        t = 1.0
        if w[0] <= 0 or np.linalg.norm(grad) > 1e-4:            # lejos: Armijo; cerca: Newton puro
            while F(x + t * d) > F(x) + 1e-4 * t * grad @ d and t > 1e-10:
                t *= 0.5
        x = x + t * d
    h = x @ x - 1
    H = Bm + 2 * (nu + rho * h) * np.eye(n) + 4 * rho * np.outer(x, x)
    return x, its, np.linalg.cond(H)

x0 = np.ones(n) / np.sqrt(n)
print("\nPENALIZACIÓN CRECIENTE (cada problema parte de la solución del anterior)")
x, total = x0.copy(), 0
for rho in [1e1, 1e2, 1e3, 1e4, 1e6, 1e8, 1e10]:
    x, its, kappa = newton_inner(x, 0.0, rho)
    total += its
    print(f"  rho = {rho:7.0e}  Newton: {its:3d} (total {total:3d})  |h| = {abs(x @ x - 1):.1e}  "
          f"||x - x*|| = {np.linalg.norm(x - x_star):.1e}  rho*h = {rho * (x @ x - 1):.8f}  kappa = {kappa:.1e}")

print("\nMÉTODO DE MULTIPLICADORES con rho = 10 fijo")
x, nu, total = x0.copy(), 0.0, 0
for k in range(15):
    x, its, kappa = newton_inner(x, nu, 10.0)
    total += its
    h = x @ x - 1
    nu += 10.0 * h
    print(f"  k = {k:2d}  Newton: {its:3d} (total {total:3d})  |h| = {abs(h):.1e}  "
          f"||x - x*|| = {np.linalg.norm(x - x_star):.1e}  nu = {nu:.10f}  kappa = {kappa:.1e}")
    if abs(h) < 1e-12:
        break

The two columns to compare are accuracy and κ\kappa. The penalty needs ρ=1010\rho = 10^{10} to bring infeasibility to 10−1010^{-10}, with Hessian condition number 4⋅10104\cdot 10^{10}, and even so the error in x\vb{x} remains 3.5⋅10−93.5\cdot 10^{-9}. Penalty bias at that ρ\rho is on the order of 10−1010^{-10} (the column falls by a factor of 10 for each factor of 10 in ρ\rho up to 10810^8), so the actual error is roughly forty times larger than expected. Conditioning is responsible, through the stopping criterion. The gradient contains 2ρh x2\rho h\,\vb{x}, and h=∥x∥2−1≈10−10h = \norm{\vb{x}}^2 - 1 \approx 10^{-10} comes from subtraction with cancellation whose absolute error is on the order of εmach≈10−16\eps_{\text{mach}} \approx 10^{-16}; multiplied by ρ\rho, it leaves gradient noise of order 10−610^{-6}. Hence the inner tolerance must grow with ρ\rho (in the cell, 10−12ρ10^{-12}\rho), and with a minimum eigenvalue around 1, a gradient of that size no longer guarantees small error in flat directions: Newton stops after two steps, far from theoretical bias. (If forced to take thirty steps, it does reach the theoretical bias, 8⋅10−118\cdot 10^{-11}, but the gradient can no longer certify it.) The same noise spoils the multiplier estimate: rho*h stops improving from ρ=106\rho = 10^6, and at 10810^8 even worsens because the inner tolerance, 10−410^{-4}, is already loose. The method of multipliers reaches 4⋅10−144\cdot 10^{-14} with ρ=10\rho = 10 and κ=44\kappa = 44 at every iteration, and error is divided by about 23 on each pass (linear convergence, as in the one-dimensional example). Also notice the penalty’s rho*h column: while rounding does not interfere, it approaches ν⋆\nu^\star as 1/ρ1/\rho, as predicted by the theorem. Total Newton steps are similar for both methods because Newton is insensitive to conditioning in exact arithmetic; with a first-order inner solver requiring on the order of κ\kappa iterations, the penalty would be impractical.

ADMM for lasso with cached factorization

[ ]ADMM for lasso from scratchBrowser
import numpy as np
from scipy.linalg import cho_factor, cho_solve

def soft(v, k):
    return np.sign(v) * np.maximum(np.abs(v) - k, 0.0)

def admm_lasso(A, b, lam, rho=1.0, abstol=1e-6, reltol=1e-4, max_iter=5000, adapt=False):
    """min 1/2 ||Ax - b||^2 + lam ||z||_1  s.a.  x - z = 0, en forma escalada."""
    m, n = A.shape
    Atb = A.T @ b
    def factor(rho):
        if m >= n:                                          # A^T A + rho I, n x n
            F = cho_factor(A.T @ A + rho * np.eye(n))
            return lambda q: cho_solve(F, q)
        F = cho_factor(np.eye(m) + (A @ A.T) / rho)         # Woodbury: solo m x m
        return lambda q: q / rho - A.T @ cho_solve(F, A @ q) / rho**2
    solve = factor(rho)
    x = z = u = np.zeros(n)
    hist = []
    for k in range(1, max_iter + 1):
        x = solve(Atb + rho * (z - u))                      # dos sustituciones triangulares
        z_old = z
        z = soft(x + u, lam / rho)
        u = u + x - z
        r = np.linalg.norm(x - z)
        s = rho * np.linalg.norm(z - z_old)
        eps_pri = np.sqrt(n) * abstol + reltol * max(np.linalg.norm(x), np.linalg.norm(z))
        eps_dual = np.sqrt(n) * abstol + reltol * rho * np.linalg.norm(u)
        hist.append((r, s, eps_pri, eps_dual, rho))
        if r <= eps_pri and s <= eps_dual:
            break
        if adapt:                                           # balance de residuos normalizados
            rp, sd = r / eps_pri, s / eps_dual
            if rp > 10 * sd or sd > 10 * rp:
                tau = 2.0 if rp > 10 * sd else 0.5
                rho, u = rho * tau, u / tau                 # nu = rho u se conserva
                solve = factor(rho)                         # hay que refactorizar
    return z, np.array(hist)

def lasso_obj(A, b, lam, x):
    return 0.5 * np.sum((A @ x - b) ** 2) + lam * np.sum(np.abs(x))

def fista(A, b, lam, iters):
    L = np.linalg.norm(A, 2) ** 2
    x = y = np.zeros(A.shape[1]); t = 1.0
    for _ in range(iters):
        x_new = soft(y - A.T @ (A @ y - b) / L, lam / L)
        t_new = (1 + np.sqrt(1 + 4 * t * t)) / 2
        y = x_new + (t - 1) / t_new * (x_new - x)
        x, t = x_new, t_new
    return x

rng = np.random.default_rng(0)
m, n = 300, 100
A = rng.normal(size=(m, n)) / np.sqrt(m)
x_true = np.zeros(n); x_true[rng.choice(n, 8, replace=False)] = rng.normal(0, 3, 8)
b = A @ x_true + 0.05 * rng.normal(size=m)
lam = 0.1 * np.max(np.abs(A.T @ b))

z, hist = admm_lasso(A, b, lam, rho=1.0)
x_ref = fista(A, b, lam, 5000)
f_ref = lasso_obj(A, b, lam, x_ref)
print(f"ADMM, m = {m} > n = {n}: {len(hist)} iteraciones")
print(f"  gap relativo frente a FISTA (5000 it.): {(lasso_obj(A, b, lam, z) - f_ref) / f_ref:.1e}")
print("  soporte ADMM: ", np.flatnonzero(z))
print("  soporte FISTA:", np.flatnonzero(np.abs(x_ref) > 1e-8))
r, s, ep, ed, _ = hist[-1]
print(f"  al parar: r = {r:.1e} <= {ep:.1e},  s = {s:.1e} <= {ed:.1e}")

# n > m: el paso x usa Woodbury (sistema 80 x 80 en lugar de 400 x 400)
A2 = rng.normal(size=(80, 400)) / np.sqrt(80)
x2 = np.zeros(400); x2[:6] = [3, -2, 2.5, -3, 1.5, 2]
b2 = A2 @ x2 + 0.02 * rng.normal(size=80)
z2, hist2 = admm_lasso(A2, b2, 0.1 * np.max(np.abs(A2.T @ b2)), rho=1.0)
print(f"\nADMM, m = 80 < n = 400: {len(hist2)} iteraciones, coeficientes no nulos: {np.flatnonzero(z2)}")

ADMM’s solution support matches FISTA run for 5000 iterations, and the objective value matches to one part in 10910^9 in 19 iterations. (The support not matching x_true exactly is a property of lasso, not the algorithm: at this λ\lambda, the smallest true coefficient is below the threshold.) With n≫mn \gg m, the Woodbury identity avoids factoring a 400×400400 \times 400 matrix, and ADMM recovers exactly the six coefficients that generated the data.

ρ, scale and accuracy

Now for what makes ADMM struggle in practice: the choice of ρ\rho, data scale and high accuracy.

[ ]Sensitivity to ρ and scaleBrowser
import numpy as np
import matplotlib.pyplot as plt

print(f"{'rho':>8} {'iteraciones':>12} {'datos x100':>12}")
for rho in [0.01, 0.1, 1.0, 10.0, 100.0]:
    it1 = len(admm_lasso(A, b, lam, rho=rho, max_iter=2000)[1])
    it2 = len(admm_lasso(100 * A, 100 * b, 1e4 * lam, rho=rho, max_iter=2000)[1])
    print(f"{rho:8.2f} {it1:12d} {it2:12d}")
print("\nrho adaptativo (balance de residuos normalizados):")
for rho in [0.01, 1.0, 100.0]:
    it1 = len(admm_lasso(A, b, lam, rho=rho, adapt=True)[1])
    it2 = len(admm_lasso(100 * A, 100 * b, 1e4 * lam, rho=rho, adapt=True)[1])
    print(f"  desde rho = {rho:6.2f}: {it1:4d} iteraciones   datos x100: {it2:4d}")

# precisión moderada frente a alta en un problema mal condicionado (kappa(A) = 100)
rng = np.random.default_rng(1)
U, _ = np.linalg.qr(rng.normal(size=(300, 100))); V, _ = np.linalg.qr(rng.normal(size=(100, 100)))
Ac = U @ np.diag(np.logspace(0, -2, 100)) @ V.T
bc = Ac @ x_true + 0.01 * rng.normal(size=300)
lc = 0.05 * np.max(np.abs(Ac.T @ bc))
z_ref, _ = admm_lasso(Ac, bc, lc, rho=0.1, abstol=1e-13, reltol=1e-13, max_iter=5000)
fc = lasso_obj(Ac, bc, lc, z_ref)

def trayectoria(rho, K):
    F = cho_factor(Ac.T @ Ac + rho * np.eye(100))
    x = z = u = np.zeros(100); gaps = []
    for _ in range(K):
        x = cho_solve(F, Ac.T @ bc + rho * (z - u)); z = soft(x + u, lc / rho); u = u + x - z
        gaps.append(max((lasso_obj(Ac, bc, lc, z) - fc) / fc, 1e-16))
    return np.array(gaps)

for rho in [0.01, 0.1, 1.0]:
    gaps = trayectoria(rho, 800)
    hitos = [int(np.argmax(gaps < t)) + 1 if (gaps < t).any() else None for t in [1e-2, 1e-4, 1e-6, 1e-8]]
    print(f"rho = {rho:5.2f}: iteraciones hasta gap 1e-2, 1e-4, 1e-6, 1e-8 = {hitos}")
    plt.semilogy(gaps, label=f"ρ = {rho}")
plt.xlabel("iteración"); plt.ylabel("gap relativo del objetivo"); plt.legend(); plt.show()

The table tells three stories. With well-scaled data there is a clear U around ρ=1\rho = 1, and being wrong by two orders of magnitude costs 55 to 66 times more iterations. Multiplying data by 100 does not change the solution (the entire objective is multiplied by 10410^4), but shifts the good ρ\rho to 10410^4: with any “reasonable” ρ\rho the method does not finish (2000 is the table’s iteration cap). Adaptive tuning fixes this only if it compares residuals normalized by their tolerances; with absolute comparison, it remains stuck for over a thousand iterations on rescaled data (check by changing rp, sd to r, s).

The final part shows the accuracy pattern. With well-chosen ρ\rho for this problem (0.10.1), ADMM reaches 10−810^{-8} in about 50 iterations. With ρ=0.01\rho = 0.01 it reaches 10−210^{-2} in 26, but needs 79 for 10−410^{-4}, 188 for 10−610^{-6} and 326 for 10−810^{-8}: each pair of digits costs more than the last. With ρ=1\rho = 1, which was good in the previous problem, it takes 137 iterations just to reach 10−210^{-2}, because here ff‘s curvature is much lower (eigenvalues of A⊤A\mat{A}\T\mat{A} fall to 10−410^{-4}) and good ρ\rho falls with it. This is typical of ADMM: a few dozen iterations give a useful solution, and the last digits are costly. In machine learning moderate accuracy usually suffices; otherwise ADMM finds the active set and a second-order method finishes, as in OSQP polishing.

Consensus for logistic regression in eight blocks

Now for distributed data: regularized logistic regression with 800 examples split across 8 nodes with different distributions. Each local step is a small logistic regression with a quadratic pull, solved using a few Newton iterations starting from the previous solution.

[ ]Consensus ADMMBrowser
import numpy as np
from scipy.special import expit

rng = np.random.default_rng(0)
N, mi, d = 8, 100, 20
w_true = rng.normal(size=d)
bloques = []
for i in range(N):
    Ai = rng.normal(size=(mi, d)) + 0.5 * i / N            # cada nodo ve datos desplazados
    yi = np.where(rng.random(mi) < expit(Ai @ w_true), 1.0, -1.0)
    bloques.append((Ai, yi))
gamma = 1.0                                                # (gamma/2)||w||^2 repartido entre los nodos

def newton_local(Ai, yi, v, rho, x, lin=None, tol=1e-10):
    """argmin_x sum log(1 + exp(-y a^T x)) + gamma/(2N) ||x||^2 + rho/2 ||x - v||^2 (+ lin^T x)."""
    for _ in range(50):
        p = expit(-yi * (Ai @ x))
        grad = -Ai.T @ (yi * p) + (gamma / N) * x + rho * (x - v)
        if lin is not None:
            grad = grad + lin
        if np.linalg.norm(grad) < tol:
            break
        H = (Ai.T * (p * (1 - p))) @ Ai + (gamma / N + rho) * np.eye(len(x))
        x = x - np.linalg.solve(H, grad)
    return x

# referencia centralizada (lo que haría quien tuviera todos los datos)
A_all = np.vstack([B[0] for B in bloques]); y_all = np.concatenate([B[1] for B in bloques])
w_star = np.zeros(d)
for _ in range(30):
    p = expit(-y_all * (A_all @ w_star))
    H = (A_all.T * (p * (1 - p))) @ A_all + gamma * np.eye(d)
    w_star -= np.linalg.solve(H, -A_all.T @ (y_all * p) + gamma * w_star)

def admm_consenso(rho, iters):
    X = np.zeros((N, d)); U = np.zeros((N, d)); z = np.zeros(d); hist = []
    for k in range(iters):
        for i, (Ai, yi) in enumerate(bloques):             # en un clúster, en paralelo
            X[i] = newton_local(Ai, yi, z - U[i], rho, X[i])
        z_old = z
        z = (X + U).mean(axis=0)                           # all-reduce
        U += X - z
        hist.append((np.linalg.norm(X - z), rho * np.sqrt(N) * np.linalg.norm(z - z_old),
                     np.linalg.norm(z - w_star) / np.linalg.norm(w_star)))
    return z, np.array(hist)

z, h_admm = admm_consenso(rho=5.0, iters=150)
for k in [10, 30, 60, 150]:
    r, s, e = h_admm[k - 1]
    print(f"k = {k:3d}   r = {r:.1e}   s = {s:.1e}   error relativo frente al centralizado = {e:.1e}")
for rho in [0.5, 50.0]:
    _, h = admm_consenso(rho, 60)
    print(f"rho = {rho:4.1f}: error relativo tras 60 iteraciones = {h[-1, 2]:.1e}")

With ρ=5\rho = 5, consensus agrees with the centralized solution to ten digits after 150 communication rounds, and no node has revealed its data. With ρ=0.5\rho = 0.5 or ρ=50\rho = 50, after 60 rounds error is three to four orders of magnitude worse than with ρ=5\rho = 5: the same U as before.

For comparison, dual decomposition of the same problem. Without the quadratic term, each node minimizes fi(xi)+νi⊤xif_i(\vb{x}_i) + \vb{\nu}_i\T\vb{x}_i, and multipliers ascend along the dual gradient projected onto ∑iνi=0\sum_i\vb{\nu}_i = \vb{0} (the condition for the infimum over z\vb{z} to be finite). Each fif_i is μ\mu-strongly convex with μ=γ/N\mu = \gamma/N, so the safe step is α=μ\alpha = \mu.

[ ]Dual decomposition of the same problemBrowser
import numpy as np

def ascenso_dual(alpha, iters):
    Nu = np.zeros((N, d)); X = np.zeros((N, d)); hist = []
    for k in range(iters):
        for i, (Ai, yi) in enumerate(bloques):
            X[i] = newton_local(Ai, yi, np.zeros(d), 0.0, X[i], lin=Nu[i])
        xbar = X.mean(axis=0)
        if not np.all(np.isfinite(X)) or np.abs(X).max() > 1e6:
            hist.append(np.inf); break
        Nu += alpha * (X - xbar)                            # conserva sum(nu_i) = 0
        hist.append(np.linalg.norm(xbar - w_star) / np.linalg.norm(w_star))
    return np.array(hist)

mu = gamma / N
for fac in [1, 4, 8, 12]:
    h = ascenso_dual(fac * mu, 150)
    if np.isfinite(h[-1]):
        print(f"alpha = {fac:2d} mu:  " + ", ".join(f"k={k}: {h[k - 1]:.1e}" for k in [10, 60, 150]))
    else:
        print(f"alpha = {fac:2d} mu:  diverge en la iteración {len(h)}")
print(f"ADMM, rho = 5:   k=10: {h_admm[9, 2]:.1e}, k=60: {h_admm[59, 2]:.1e}, k=150: {h_admm[149, 2]:.1e}")

Dual ascent with the safe step remains 2.5% from the solution after 150 rounds. Larger steps improve it (with 8μ8\mu it reaches 2⋅10−42\cdot 10^{-4}), but 12μ12\mu diverges within a few iterations: the best step is at the edge of divergence, and that edge is not known in advance. ADMM, at the same cost per round and without tuning, is six orders of magnitude ahead of the best dual ascent and eight ahead of the safe one. The difference is ρ2∥xi−z+ui∥2\frac{\rho}{2}\norm{\vb{x}_i - \vb{z} + \vb{u}_i}^2: it prevents each node from overreacting to prices.

Using libraries

In practice, ADMM is rarely hand-coded for standard problems: formulate the problem in a modeling language and pass it to a solver using ADMM internally. Checking lasso with scikit-learn ties things together (beware its scale: it minimizes 12m∥Ax−b∥2+α∥x∥1\frac{1}{2m}\norm{\mat{A}\vb{x} - \vb{b}}^2 + \alpha\norm{\vb{x}}_1, so α=λ/m\alpha = \lambda/m).

[ ]Checking with scikit-learnBrowser
import numpy as np
from sklearn.linear_model import Lasso

m_, n_ = A.shape
sk = Lasso(alpha=lam / m_, fit_intercept=False, tol=1e-12, max_iter=100000).fit(A, b)
z_admm, _ = admm_lasso(A, b, lam, rho=1.0, abstol=1e-10, reltol=1e-10)
print("max |ADMM - scikit-learn| =", np.max(np.abs(z_admm - sk.coef_)))
print("objetivos:", lasso_obj(A, b, lam, z_admm), lasso_obj(A, b, lam, sk.coef_))

Outside the browser, the same lasso is solved with CVXPY, which translates the problem into OSQP standard form (quadratic program) or SCS form (conic program). The relevant parameters are exactly those of this lesson:

import cvxpy as cp
import osqp, scipy.sparse as sp

x = cp.Variable(n)
prob = cp.Problem(cp.Minimize(0.5 * cp.sum_squares(A @ x - b) + lam * cp.norm1(x)))
prob.solve(solver=cp.OSQP, eps_abs=1e-6, eps_rel=1e-6, polish=True)   # ADMM + pulido final
prob.solve(solver=cp.SCS, eps=1e-6)                                    # ADMM sobre el embebido homogéneo

# OSQP directamente: min 1/2 x'Px + q'x  s.a.  l <= Ax <= u
# (P, q, Acons, l, u son los datos de tu programa cuadrático)
solver = osqp.OSQP()
solver.setup(P=sp.csc_matrix(P), q=q, A=sp.csc_matrix(Acons), l=l, u=u,
             rho=0.1, adaptive_rho=True, alpha=1.6, eps_abs=1e-5, eps_rel=1e-5,
             scaling=10, warm_start=True)
res = solver.solve()
print(res.info.iter, res.info.status, res.info.rho_estimate)

adaptive_rho is normalized residual balancing, alpha over-relaxation, scaling the Ruiz equilibration passes and polish the final high-accuracy phase. For problems solved repeatedly with similar data (model predictive control, portfolio backtesting), warm_start reuses the previous solution and multiplier, and this is where ADMM shines: a few iterations per problem.

Common mistakes

Exercises

NumericThe penalized minimizer
To minimize x2x^2 subject to x=1x = 1, use the penalty x2+ρ2(x−1)2x^2 + \frac{\rho}{2}(x - 1)^2 with ρ=18\rho = 18. What is the minimizer of the penalized problem?
NumericThree steps of the method of multipliers
Apply the method of multipliers to min⁡12(x−3)2\min \frac12(x - 3)^2 subject to x=1x = 1, with ρ=4\rho = 4 and ν0=0\nu^0 = 0. What is ∣x3−1∣\abs{x^3 - 1}, the infeasibility after the third minimization?
NumericCondition number of a penalty
Let f(x)=12(x12+4x22)f(\vb{x}) = \frac12(x_1^2 + 4x_2^2) with constraint x1+x2=1x_1 + x_2 = 1 and penalty ρ2(x1+x2−1)2\frac{\rho}{2}(x_1 + x_2 - 1)^2 with ρ=100\rho = 100. What is the penalized Hessian's condition number?
QuizWhy is finite ρ enough?
The method of multipliers converges to the exact solution with fixed ρ\rho, whereas quadratic penalty needs ρ→∞\rho \to \infty. Why?
QuizReading residuals
You run ADMM and after 200 iterations the primal residual is 10−710^{-7} and the dual is 10−110^{-1}, barely changing between iterations. What do you do?
QuizWhat ADMM does and does not guarantee
Apply ADMM to min⁡f(x)+g(z)\min f(\vb{x}) + g(\vb{z}) subject to x−z=0\vb{x} - \vb{z} = \vb{0}, with f,gf, g convex, closed and proper, and a saddle point of L0L_0. Which statements are true?

More than one answer may be correct.

ProofDual ascent is gradient ascent
Prove: Let g(ν)=inf⁡xL(x,ν)g(\vb{\nu}) = \inf_{\vb{x}} L(\vb{x}, \vb{\nu}) with L(x,ν)=f(x)+ν⊤(Ax−b)L(\vb{x}, \vb{\nu}) = f(\vb{x}) + \vb{\nu}\T(\mat{A}\vb{x} - \vb{b}), and let x~\tilde{\vb{x}} minimize L(⋅,ν)L(\cdot, \vb{\nu}). If gg is differentiable at ν\vb{\nu}, then ∇g(ν)=Ax~−b\grad g(\vb{\nu}) = \mat{A}\tilde{\vb{x}} - \vb{b}, and dual ascent is gradient ascent on gg.
0
Fix ν\vb{\nu} and a minimizer x~\tilde{\vb{x}}, so g(ν)=L(x~,ν)g(\vb{\nu}) = L(\tilde{\vb{x}}, \vb{\nu}).

Step 1 of 4. What bound do you obtain for g(ν′)g(\vb{\nu}') at another point ν′\vb{\nu}'?

ProofADMM in scaled form
Prove: For min⁡f(x)+g(z)\min f(\vb{x}) + g(\vb{z}) subject to x−z=0\vb{x} - \vb{z} = \vb{0}, ADMM iterations with scaled multiplier u=ν/ρ\vb{u} = \vb{\nu}/\rho are xk+1=prox⁡f/ρ(zk−uk)\vb{x}^{k+1} = \operatorname{prox}_{f/\rho}(\vb{z}^k - \vb{u}^k), zk+1=prox⁡g/ρ(xk+1+uk)\vb{z}^{k+1} = \operatorname{prox}_{g/\rho}(\vb{x}^{k+1} + \vb{u}^k) and uk+1=uk+xk+1−zk+1\vb{u}^{k+1} = \vb{u}^k + \vb{x}^{k+1} - \vb{z}^{k+1}.
0
Start from Lρ(x,z,ν)=f(x)+g(z)+ν⊤(x−z)+ρ2∥x−z∥2L_\rho(\vb{x}, \vb{z}, \vb{\nu}) = f(\vb{x}) + g(\vb{z}) + \vb{\nu}\T(\vb{x} - \vb{z}) + \frac{\rho}{2}\norm{\vb{x} - \vb{z}}^2 and write r=x−z\vb{r} = \vb{x} - \vb{z}.

Step 1 of 4. How do you rewrite ν⊤r+ρ2∥r∥2\vb{\nu}\T\vb{r} + \frac{\rho}{2}\norm{\vb{r}}^2?

CodeADMM for lasso with a stopping criterion
Implement admm_lasso(A, b, lam, rho, abstol=1e-6, reltol=1e-4, max_iter=5000) in scaled form for min⁡12∥Ax−b∥2+λ∥z∥1\min \frac12\norm{\mat{A}\vb{x} - \vb{b}}^2 + \lambda\norm{\vb{z}}_1 subject to x=z\vb{x} = \vb{z}. Factor A⊤A+ρI\mat{A}\T\mat{A} + \rho\mat{I} once (Cholesky) and reuse it. At each iteration compute r=∥x−z∥r = \norm{\vb{x} - \vb{z}}, s=ρ∥z−zant∥s = \rho\norm{\vb{z} - \vb{z}_{\text{ant}}}, εpri=n εabs+εrelmax⁡(∥x∥,∥z∥)\eps^{\text{pri}} = \sqrt{n}\,\eps^{\text{abs}} + \eps^{\text{rel}}\max(\norm{\vb{x}}, \norm{\vb{z}}) and εdual=n εabs+εrel∥ρu∥\eps^{\text{dual}} = \sqrt{n}\,\eps^{\text{abs}} + \eps^{\text{rel}}\norm{\rho\vb{u}}, save the row (r, s, eps_pri, eps_dual) in the history and stop as soon as r≤εprir \le \eps^{\text{pri}} and s≤εduals \le \eps^{\text{dual}}. Return (z, hist) with hist as a NumPy array of shape (iteraciones, 4).
import numpy as np
from scipy.linalg import cho_factor, cho_solve

def admm_lasso(A, b, lam, rho, abstol=1e-6, reltol=1e-4, max_iter=5000):
  m, n = A.shape
  x = np.zeros(n)
  z = np.zeros(n)
  u = np.zeros(n)
  hist = []
  # tu código: factoriza una vez, itera x, z, u, calcula residuos y tolerancias, para
  return z, np.array(hist)
Shift+Enter to run

Summary

Key idea
A penalty punishes violation and needs ρ→∞\rho \to \infty, with conditioning growing as ρ\rho; the augmented Lagrangian learns the constraint price using a multiplier and converges with finite ρ\rho; ADMM minimizes that Lagrangian by blocks, so each piece is solved with its own proximal, separately and in parallel.
  • Quadratic penalty leaves infeasibility on the order of ∥ν⋆∥/ρ\norm{\vb{\nu}^\star}/\rho and a Hessian with κ≳ρ∥A∥2/λmax⁡(∇2f)\kappa \gtrsim \rho\norm{\mat{A}}^2/\lambda_{\max}(\hess f). The ℓ1\ell_1 penalty is exact for ρ>∥ν⋆∥∞\rho > \norm{\vb{\nu}^\star}_\infty but nonsmooth.
  • Dual ascent is gradient ascent on gg, whose gradient is the constraint residual. A separable objective decomposes into independent problems (dual decomposition), but requires strict convexity and small steps.
  • The method of multipliers, xk+1=arg min⁡Lρ(⋅,νk)\vb{x}^{k+1} = \argmin L_\rho(\cdot, \vb{\nu}^k) and νk+1=νk+ρh(xk+1)\vb{\nu}^{k+1} = \vb{\nu}^k + \rho h(\vb{x}^{k+1}), is proximal point on the dual: it converges for any ρ>0\rho > 0 and satisfies KKT stationarity each iteration.
  • ADMM alternates an x\vb{x} step, a z\vb{z} step and a multiplier step. In scaled form these are two proximals and a residual sum; with x=z\vb{x} = \vb{z} it is Douglas–Rachford. It converges with convex ff, gg and any ρ\rho, and stops when primal and dual residuals fall below their tolerances.
  • ρ\rho decides speed: iteration count forms a U, flattened by normalized residual balancing and well-scaled data. ADMM is fast to moderate accuracy and slow afterward; it cannot naively be extended to three blocks.
  • Lasso, consensus, box constraints and resource allocation follow the same pattern, and OSQP and SCS are ADMM with cached factorization, scaling, over-relaxation, adaptive ρ\rho and polishing.