Hyoungseo Son
Convex Optimization
Contents · Convex Optimization

Part 0 · Convexity

  • Convex Sets and Functions

Part 1 · Quadratic Programs

Part 0 · Convexity

Convex Sets and Functions

A set is convex if it contains the whole line segment between any two of its points, and a function is convex if its graph never rises above its own chords. Both reduce to the same test on a segment, and both are why a physics contact solve or a policy-improvement step can be trusted to land on the one right answer instead of a lucky local one.

Convex sets

A set CRnC \subseteq \mathbb{R}^n is convex if, for every x,yCx, y \in C and every t[0,1]t \in [0, 1],

tx+(1t)yC.t x + (1 - t)\, y \in C .

The point tx+(1t)yt x + (1-t) y traces the segment from yy (at t=0t = 0) to xx (at t=1t = 1), so the condition says: pick any two points, and the line between them never leaves the set.

The unit disk B={x:x1}B = \{\, x : \lVert x \rVert \le 1 \,\} is convex. For x,yBx, y \in B and t[0,1]t \in [0,1], the triangle inequality and homogeneity give

tx+(1t)ytx+(1t)yt+(1t)=1,\lVert t x + (1-t) y \rVert \le t\,\lVert x \rVert + (1-t)\,\lVert y \rVert \le t + (1-t) = 1 ,

so the whole segment stays in BB. Numerically, take x=(1,0)x = (1, 0), y=(0,1)y = (0, 1), t=12t = \tfrac12: the midpoint is (0.5,0.5)(0.5, 0.5) with norm 0.50.7071\sqrt{0.5} \approx 0.707 \le 1. Inside, as promised.

Now break it. Let the L-shaped region be L=([0,2]×[0,1])([0,1]×[1,2])L = \big([0,2] \times [0,1]\big) \cup \big([0,1] \times [1,2]\big), a horizontal arm and a vertical arm sharing a corner. Take A=(1.7,0.5)A = (1.7, 0.5) in the horizontal arm and B=(0.5,1.7)B = (0.5, 1.7) in the vertical arm, both in LL. Their midpoint is

12A+12B=(1.1, 1.1),\tfrac12 A + \tfrac12 B = (1.1,\ 1.1),

which satisfies neither arm (y=1.1>1y = 1.1 > 1 rules out the first, x=1.1>1x = 1.1 > 1 rules out the second). One segment escapes the set, so LL is not convex. A single bad pair is a complete disproof.

Convex set explorerinteractive
AB
this region
not convex
chord AB
leaves the set

The chord AB leaves the region (red): a single pair of points is enough to prove this set is not convex.

Drag A and B. The chord is accent-colored while it stays inside; the instant a sample leaves the region it turns red. The disk can never flip; the L-shape flips as soon as a chord crosses the notch.

Convex functions

A function f:RnRf : \mathbb{R}^n \to \mathbb{R} is convex if its epigraph {(x,s):sf(x)}\{\, (x, s) : s \ge f(x) \,\} is a convex set. Equivalently, for all x,yx, y and t[0,1]t \in [0, 1],

f(tx+(1t)y)tf(x)+(1t)f(y).f\big(t x + (1-t) y\big) \le t\,f(x) + (1-t)\,f(y) .

This is Jensen's inequality. The right side is the height of the chord from (y,f(y))(y, f(y)) to (x,f(x))(x, f(x)); the inequality says the graph lies on or below every such chord.

Take f(x)=x2f(x) = x^2 with a=1a = 1, b=3b = 3, t=12t = \tfrac12. The left side is f(2)=4f(2) = 4; the right side is 121+129=5\tfrac12 \cdot 1 + \tfrac12 \cdot 9 = 5. Since 454 \le 5, the chord sits above the curve, and because f(x)=2>0f''(x) = 2 > 0 everywhere, the same holds for every pair (a,b)(a, b).

Local means global

Here is the payoff. If ff is convex over a convex feasible set, then every local minimum is a global minimum.1 Suppose xx^\star were a local minimum but some feasible yy had f(y)<f(x)f(y) < f(x^\star). By convexity the point (1t)x+ty(1-t) x^\star + t y is feasible, and

f((1t)x+ty)(1t)f(x)+tf(y)<f(x)f\big((1-t) x^\star + t y\big) \le (1-t) f(x^\star) + t\, f(y) < f(x^\star)

for all small t>0t > 0, contradicting the assumption that xx^\star was best in its neighborhood. So a descent method that gets stuck has, by definition, found the answer: no restarts, no seeds, no luck.

That guarantee is engineered into modern solvers on purpose. A rigid-body contact solve is deliberately posed as a convex program: MuJoCo drops the LCP complementarity condition so the contact forces are the unique global solution of a convex optimization (a QP, or a conic program once friction cones are included).2 Drake's SAP casts compliant contact as an unconstrained convex problem, so the same local-equals-global property makes each solve deterministic and restart-free.3 On the learning side, stable policy-optimization steps (trust-region and proximal updates) approximate the improvement as a convex subproblem in the step, so the update has a unique solution and cannot be trapped in a spurious local optimum.

Footnotes

  1. Boyd & Vandenberghe, Convex Optimization (2004).

  2. MuJoCo docs, Computation.

  3. Castro, Permenter, Han, An Unconstrained Convex Formulation of Compliant Contact (2021).