Phase II — Unconstrained Optimization | Week 4 | 2.5 hours Taming ill-posed problems with regularization — the bridge from optimization to Bayesian estimation.
Regularization is everywhere in the AMR stack. The Ceres solver’s LossFunction applies robust kernels (a form of regularization). OSQP solves regularized QPs internally. The navigation estimator uses process noise $Q$ as a Tikhonov-like regularizer on state transitions. Map building uses L2 regularization to prevent overfitting to noisy sensor data. Understanding regularization deeply means understanding why solver parameters are tuned the way they are.
Original problem may be ill-posed or underdetermined. Add a penalty:
Closed-form: $x^* = (A^TA + \lambda I)^{-1} A^Tb$
Effect: Shrinks solution toward zero. Makes $A^TA + \lambda I$ invertible even if $A$ is rank-deficient.
Bayesian interpretation: Gaussian prior $x \sim \mathcal{N}(0, \sigma^2_p I)$ gives $\lambda = \sigma^2_n / \sigma^2_p$.
Effect: Promotes sparsity — many components of $x^*$ are exactly zero.
No closed-form — requires iterative methods (proximal gradient).
Bayesian interpretation: Laplace prior $p(x_j) \propto \exp(-|x_j|/b)$.
As $\lambda$ varies from $\infty$ to $0$: - $\lambda \to \infty$: $x^* \to 0$ (pure prior) - $\lambda \to 0$: $x^*$ = unconstrained solution (pure data fit) - The path $x^*(\lambda)$ traces a smooth curve for L2, piecewise-linear for L1
The proximal operator of $f$:
Key proximal operators: | $f(x)$ | $\text{prox}_{\lambda f}(v)$ | |---------|-------------------------------| | $\|x\|_1$ | Soft-thresholding: $\text{sign}(v_j)\max(|v_j| - \lambda, 0)$ | | $\|x\|^2$ | Scaling: $v / (1 + 2\lambda)$ | | $\delta_C(x)$ (indicator) | Projection onto $C$ |
ISTA (Iterative Shrinkage-Thresholding):
where $g(x) = \|Ax - b\|^2$ (smooth part) and $\lambda\|x\|_1$ (nonsmooth part).
FISTA (Fast ISTA): add Nesterov acceleration to ISTA → $O(1/k^2)$ convergence.
Why this matters for the rest of the curriculum: - OSQP and SCS use ADMM internally, which is based on proximal operators - ADMM splits problems into subproblems solved via proximal operators - Regularization is how Ceres handles underdetermined problems - Understanding proximal operators unlocks Phase IV (constrained optimization)
# See: code/week04/regularization.py
Solve ridge regression both closed-form and iteratively (GD on regularized objective). Compare solutions.
Implement ISTA for LASSO. Show that it produces sparse solutions.
Plot solution components $x_j$ vs $\lambda$ for both L2 and L1. Show L1’s kink points where components enter/leave.
Implement k-fold cross-validation to select optimal $\lambda$. Plot validation error vs $\lambda$.
Robot calibration problem: estimate sensor parameters from noisy data. Without regularization: overfits to noise. With L2: stable solution.
HuberLoss is used on residuals. How is this related to regularization?Problem: Implement FISTA (accelerated proximal gradient) for LASSO. Compare convergence of ISTA ($O(1/k)$) vs FISTA ($O(1/k^2)$) on a problem with $A \in \mathbb{R}^{100 \times 500}$ (more variables than equations — L1 selects a sparse subset).
Solution: FISTA adds Nesterov momentum to ISTA:
y_k = x_k + ((t_{k-1} - 1)/t_k) * (x_k - x_{k-1})
x_{k+1} = prox(y_k - α∇g(y_k))
t_{k+1} = (1 + sqrt(1 + 4*t_k²)) / 2
On the 100×500 problem, FISTA reaches $10^{-6}$ accuracy in ~200 iterations vs ISTA’s ~2000. The acceleration is most visible in the final convergence phase.
Problem: Implement elastic net: $\min \|Ax-b\|^2 + \lambda_1\|x\|_1 + \lambda_2\|x\|^2$. This combines L1 sparsity with L2 stability. Show that it selects groups of correlated features (unlike pure L1 which picks one arbitrarily).
Solution: The proximal gradient step becomes: compute gradient of smooth part ($\|Ax-b\|^2 + \lambda_2\|x\|^2$), then apply soft-thresholding (L1 prox). The L2 term makes the problem strongly convex, ensuring a unique solution even with correlated features. Create data with groups of correlated features and show elastic net selects the whole group while LASSO picks one per group.
Problem: In graph SLAM, the optimization $\min \sum \|z_{ij} - h(x_i, x_j)\|^2$ can be underdetermined (gauge freedom). Show this by constructing a small SLAM problem where the Hessian $J^TJ$ is singular. Then show that adding a single anchor constraint (L2 regularization on one pose) makes it well-conditioned.
Solution: 3-pose SLAM with 2 relative measurements: $z_{01}$ and $z_{12}$. The system has rank deficiency of 3 (can translate and rotate all poses). $J^TJ$ has 3 zero eigenvalues. Adding $(x_0 - x_{\text{anchor}})^2$ with small weight fixes the gauge. This is exactly what Ceres/g2o do with “anchor nodes.”