Phase II — Unconstrained Optimization | Week 4 | 2.5 hours When local methods aren’t enough — escaping local minima systematically.
Most AMR optimization is local (sensor calibration, pose estimation — all start near the solution). But global optimization appears in two critical scenarios: (1) loop closure detection in SLAM where the initial alignment between scans may be far from correct, and (2) scan matching initialization where ICP needs a reasonable starting point. Understanding when you need global search vs when good initialization suffices is a key engineering judgment.
Local optimization finds $x^*$ with $\nabla f(x^*) = 0$ and $\nabla^2 f(x^*) \succeq 0$. But there may be many such points, and only one (or few) are the global minimum.
For convex problems: local = global (no issue). For nonconvex: GD, Newton, BFGS all find local minima.
Simplest approach: run a local optimizer from $K$ random starting points.
Properties: - Probability of finding global minimum increases with $K$ - Each restart is independent — embarrassingly parallel - Works well when basins of attraction are large
Cost: $K \times$ (cost of one local solve).
Inspired by metallurgy — allow “uphill” moves with decreasing probability:
Temperature schedule controls exploration vs exploitation: - High $T$: almost random walk (exploration) - Low $T$: almost greedy descent (exploitation)
Guarantee: Converges to global minimum in probability as $T \to 0$ slowly enough. In practice: convergence is slow.
Combination of random perturbation + local optimization:
Advantage: Each evaluation is at a local minimum → cleaner landscape. scipy.optimize.basinhopping implements this.
scipy.optimize.differential_evolution — a robust implementation| Scenario | Local suffices? | Why |
|---|---|---|
| Sensor calibration | Yes | Prior from design specs is close |
| Pose estimation | Yes | IMU prediction is good initial guess |
| ICP scan matching | Usually | Previous frame is good seed |
| Loop closure | No | Initial alignment may be far off |
| Robot placement | No | Combinatorial landscape |
| Neural network training | No | But SGD works via implicit exploration |
Rule of thumb: If your initialization is within the basin of attraction of the global minimum, use local methods. If not, you need global search.
# See: code/week04/global_optimization.py
Implement random restart with scipy.optimize.minimize(method='L-BFGS-B').
Implement simulated annealing from scratch with exponential cooling.
Rastrigin: $f(x) = 10n + \sum_i [x_i^2 - 10\cos(2\pi x_i)]$ — many local minima. Compare local method (finds nearest local min) vs global methods.
Compare minimize(), differential_evolution(), and basinhopping() on the same problem.
Robotics scenario: find initial rotation/translation for ICP. Random restart over rotation angles, L-BFGS for refinement.
Problem: Implement multi-start optimization that clusters converged solutions to identify distinct local minima. On Rastrigin in 2D: (a) find all local minima in $[-5, 5]^2$, (b) identify the basin of attraction for each, (c) estimate what fraction of starting points converge to the global minimum.
Solution: Run 1000 random starts, collect all converged points. Cluster with scipy.cluster.hierarchy or DBSCAN (tolerance 0.1). Each cluster = one local minimum. The basin fraction = cluster_size/1000. For 2D Rastrigin: 25 local minima in $[-5,5]^2$, global minimum’s basin is ~4% of the area, so ~4% of random starts find it.
Problem: Implement adaptive SA where the perturbation size adapts based on acceptance rate. Target 30-50% acceptance: if acceptance is too high, increase perturbation; if too low, decrease. Show this converges faster than fixed-perturbation SA on Rastrigin.
Solution: Track acceptance rate over a window of 100 steps. If rate > 0.5: multiply perturbation by 1.1. If rate < 0.3: multiply by 0.9. This automatically handles the transition from exploration (large perturbation) to exploitation (small perturbation). Converges 2-5× faster than fixed SA on Rastrigin.
Problem: Generate two 2D point clouds (source and target) with known transformation $(R, t)$. Add noise and outliers. Use random restart + ICP to recover the transformation. Measure: (a) how often does single-start ICP fail, (b) how many restarts are needed for 99% success, (c) does basin-hopping improve over random restart?
Solution: With rotation up to 180°: single-start ICP fails ~40% of the time (converges to wrong rotation by 180°). With 10 random restarts over $[0, 2\pi)$ rotation: ~98% success. Basin-hopping converges faster because it reuses successful basins. This demonstrates why real SLAM systems use feature-based initial alignment before ICP refinement.
basinhopping and differential_evolutionbasinhopping or multi-start.