Lite / Engineering Complex Systems / Week 30
Searching a design landscape: grids, gradients and local minima
Rolling downhill finds a valley fast. But is it the deepest valley?
Why should I care?
When a cost comes from a simulation, there is no formula to differentiate and no corners to check. You search. How you search decides whether you find a great design in minutes, a mediocre one, or nothing before the deadline.
- Compare grid search and gradient descent by evaluations needed and reliability.
- Carry out a gradient-descent step and explain the role of the learning rate.
- Recognise local minima and use restarts or coarse grids to guard against them.
Predict
A grid search uses 20 values per parameter. How many simulations for a design with 4 parameters?
- 80
- 400
- 8,000
- 160,000
Guess first, then reveal
20⁴ = 160,000. Each extra parameter multiplies the cost by 20. This exponential growth, the curse of dimensionality, is why gradient-based and other smarter methods exist.
Discover
Gradient descent from x₀ = 1: where does it end? Move x₀ to 5. Now try η = 4 and watch it overshoot. Switch to grid search: what is the smallest k that finds the global valley near 7.4, and how many evaluations does it cost?
What the interactive shows (text version)
The explorer plots an illustrative cost against one design parameter x from 0 to 10, with a local valley near x = 2.3 (cost about 1.52), a ridge near 3.8, and the deepest valley near 7.4 (cost about 0.61). Gradient descent from x₀ = 1 ends in the shallow valley; from x₀ = 5 it reaches the deep one; with a learning rate above about 3 it overshoots. Grid search with k points evaluates the cost k times and finds the deep valley once the spacing is fine enough.
Watch (optional)
Watch for: Watch the picture of a ball rolling on a cost surface; ignore the neural-network details and focus on what the gradient tells you.
The clearest picture of rolling downhill on a cost surface, and of why a step can land you in a local valley.
“Gradient descent, how neural networks learn | Deep Learning Chapter 2” by 3Blue1Brown (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
Grid search: thorough and expensive
Evaluate the cost on a regular grid and keep the best. It needs no derivatives, handles noisy or discontinuous costs, and with fine enough spacing can't miss a wide valley. But its cost is k^d evaluations, and its resolution is the grid spacing: the true optimum can sit between grid points. Use it for one to three parameters, or as a coarse first look.
Gradient descent: fast and local
Step against the slope: x ← x − η·f′(x). Near a minimum the slope shrinks, so steps shrink. Each step needs the gradient, which you can estimate with finite differences (two evaluations per parameter). It scales to many parameters, but it only ever goes downhill, so it settles in whichever valley it starts in.
The learning rate
η sets the step size. Too small and progress is painfully slow. Too large and the step jumps over the valley floor, bouncing or diverging. For f = a(x − b)², steps converge only if η < 1/a. In practice engineers try a few η values, or shrink η when the cost stops falling.
Guarding against local minima
A local minimum beats its neighbours but not the whole landscape. Defences: a coarse grid to find promising regions, then gradient descent to polish (a hybrid); several random restarts; or global methods (simulated annealing, genetic algorithms) that sometimes accept uphill moves. Always report the method and its limits: 'best found', not 'optimal'.
Explain it another way
Intuitive
Lost in fog on a hillside, you feel which way the ground slopes and step downhill. You'll reach a valley, but maybe not the lowest one in the region.
Technical
Gradient descent x_{k+1} = x_k − η∇f(x_k). Converges linearly for smooth, strongly convex f with suitable η; only to a stationary point otherwise. Grid search cost O(k^d); finite-difference gradients cost O(d) per step.
Mathematical
For f(x) = a(x − b)²: x_{k+1} − b = (1 − 2aη)(x_k − b). The error shrinks each step if |1 − 2aη| < 1, i.e. 0 < η < 1/a. At η = 1/(2a) one step lands exactly on the minimum.
Applied
Antenna designers often start with a coarse parameter sweep in an electromagnetic simulator, then hand the best few candidates to a local optimiser to fine-tune the geometry.
Worked example 1
f(x) = 2(x − 3)², x₀ = 7, η = 0.1. Take two steps.
f′(x) = 4(x − 3). Step 1: f′(7) = 16, x₁ = 7 − 1.6 = 5.4. Step 2: f′(5.4) = 9.6, x₂ = 5.4 − 0.96 = 4.44. The error shrinks by 1 − 2·2·0.1 = 0.6 each step.
Common mix-ups
Gradient descent finds the best design.
✓ It finds a nearby stationary point, usually a local minimum. Restarts or global search are needed to be confident.A finer grid is always worth it.
✓ Its cost grows as k^d; for more than a few parameters, a fine grid is unaffordable.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
In the greenhouse Build Level 4, treat (setpoint, Kp) as design variables and energy as the cost subject to the comfort constraint. Do a 5 × 5 grid, then refine around the best point by hand-stepping downhill. Report evaluations used and best found.
Reflect
When would you choose a slow, thorough search over a fast, local one?
Write your answer on paper or in your own notes. Lite never stores what you write.