liveBook · Manning

Locally optimal solution

As explained in Advanced Algorithms and Data Structures

A local minimum is a point whose function value is no greater than those of sufficiently nearby points, without necessarily being the smallest value over the entire domain.

Suppose you are moving vertices to draw a graph with fewer crossing edges. Each arrangement has a cost, and a nearby move might improve it. But reaching an arrangement that no nearby move improves does not prove you have found the best drawing overall. section 16.2.1

A locally optimal solution has a cost no greater than sufficiently nearby solutions; a global optimum has the lowest cost across the whole problem space. A local minimum can be a region rather than a single point. What counts as “nearby” depends on the moves allowed by the optimization algorithm. section 16.2.1 section 16.2.3

Figure 16.9 Local and global minima in a 1-D function

The one-dimensional cost curve makes the distinction visible: a dip can be lower than its surroundings without being the lowest dip on the curve. section 16.2.1

The shape of the cost function determines how easily a search gets stuck. On a smooth, bowl-shaped surface, downhill movement leads toward one minimum. A step function may instead have flat plateaus and multiple local minima: small moves can show no improvement even when a better solution exists elsewhere. Counting edge crossings creates this kind of difficult cost function for graph drawing. section 16.2.2 section 16.6

When a search stalls, choose a strategy that matches the cost landscape:

  • Use local search to test nearby changes and keep an improvement. For a graph drawing, move a vertex in different directions and recount intersections; this cannot by itself escape every local minimum. section 16.2.3
  • Restart from different random initial positions, run downhill again, and compare the resulting costs. This is useful when a practical cost function still has several local minima. section 16.5.1
  • Allow some long-range transitions in simulated annealing. Restricting every move to the immediate neighborhood can remove its ability to escape local minima; unrestricted random sampling, however, may require many attempts to find a downhill move. section 17.1.4

Initial positions matter in k-means

K-means starts with random centroids, repeatedly assigns points to their closest centroid, and recenters each cluster. A poor initialization can slow convergence or produce a poor result when iterations are capped. Run it several times with different initial centroids, then compare the clusterings rather than trusting one run. section 12.2

Locally optimal is therefore a useful stopping condition, not a guarantee of global quality. The trade-off is search effort: nearby moves concentrate work around the current solution, while restarts or far-reaching moves explore alternatives. This matters especially as graph-drawing search grows to two position parameters per vertex. section 17.1.4 section 16.2.3

How Advanced Algorithms and Data Structures covers it

How deep it goes
Defines the local–global distinction and examines plateaus, cost-function shapes, and search workarounds without proving global convergence.
Examples
Illustrates the concept with edge-crossing costs, a marble on plateaus and slopes, and randomly initialized k-means centroids.
What it assumes
Assumes basic familiarity with costs and candidate solutions while introducing local and global minima through a graph-drawing problem and visual analogy.
What you can do after
Diagnose/debug with it when nearby improvements stop, then assess whether restarts or longer-range moves are worth trying.
How it connects
Connects cost functions and graph drawing to gradient descent, hill descent, simulated annealing, random restarts, and k-means.

Also explained in

Compare how 9 books explain locally optimal solution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.