Earl learns about a man called Clarke
How the Clarke-Wright savings algorithm solves the Vehicle Routing Problem by merging out-and-back trips into shared runs, explained through Randy’s driving.
6 min read →Article
Two-Opt and Three-Opt formalise the planner's instinct that a route crossing its own path “looks wrong”, and then run straight into the local optimum.
By Richard Faint · 26 July 2026 · 6 min read
Two-Opt and Three-Opt improve routes by removing and reconnecting links, often eliminating crossings and unnecessary mileage. They are powerful local-search methods, but eventually reach a local optimum where every small change looks worse even though a better route exists elsewhere.
“I’m just trying to be a better person.” — Earl Hickey
The title is a sitcom reference. The subject is Two-Opt and Three-Opt, local search methods that remove and reconnect links in a route to strip out mileage, and the local optimum where they both eventually stall.
One of the reasons My Name Is Earl works so well is that Earl’s famous list is never as straightforward as it first appears. At the beginning of almost every episode, he believes he knows exactly what he needs to do to cross off another item. By the end of the episode, however, he has usually discovered that the original plan was incomplete. Helping one person creates an opportunity to help another, solving a problem uncovers a new one. Sometimes the order in which he tackles his list turns out to matter just as much as the list itself.
Transport optimisation follows similar logic. Once orders have been assigned to depots, impossible deliveries removed, and customers grouped into sensible territories, planners usually have a route that works. Every customer is visited, vehicle capacities are respected, and drivers can complete their work legally. From an operational perspective, the route is feasible, but that is only the beginning. Feasible does not mean efficient, and the difference between a workable plan and an excellent plan can amount to hundreds of miles every day across a national fleet.
That is where local improvement algorithms such as Two-Opt and Three-Opt become invaluable. Consider an episode such as Stole an RV. Earl begins with one objective in mind, but as events unfold he realises that several items on his list are connected. By slightly changing the order of his day, he can achieve far more with the same amount of effort, Two-Opt applies exactly the same philosophy to vehicle routing.
Imagine a delivery vehicle leaving a depot in Leeds to serve customers across West Yorkshire. The initial route may satisfy every operational constraint, yet somewhere in the middle of the journey the vehicle crosses its own path, travelling east before doubling back west and then returning east again. Human planners often notice these inefficiencies immediately because they simply “look wrong”, Two-Opt formalises that intuition. The algorithm examines pairs of connections within a route, removes two existing links, and reconnects them differently. If the revised route is shorter, it keeps the change; if not, it discards it and tries another combination.
The beauty of this approach lies in its restraint,only two connections have been altered, yet those small adjustments can eliminate unnecessary mileage, reduce fuel consumption, shorten driver hours and improve overall fleet utilisation. Repeated thousands of times, these tiny improvements accumulate into substantial operational savings.
The strength of Two-opt lies in recognising that optimisation is usually evolutionary rather than revolutionary. Good planners rarely throw away an entire day’s work because they notice one inefficient section of a route. Instead, they adjust, refine and improve. Earl behaves in precisely the same way throughout the series. In episodes such as Our “Cops” Is On!, his carefully prepared plan continually changes as new information emerges. He does not abandon the list; he simply finds a better order in which to complete it.
However, Two-Opt also exposes a challenge of optimisation. Sometimes the obvious improvements have all been made, yet the solution is still not the best possible. In optimisation terminology, the algorithm has reached a local optimum. Every neighbouring change appears to make the solution worse, so the search stops, even though a much better solution may exist elsewhere.
An easy way to picture this is to imagine climbing hills in dense fog. Your only objective is to keep walking uphill. Eventually you reach the top of the hill beneath your feet, but because you cannot see beyond the surrounding valleys you have no idea that a much higher mountain lies only a short distance away. From your limited perspective, there are no better moves available. Two-Opt suffers from exactly the same limitation. It can only evaluate improvements created by swapping two connections. If escaping the local optimum requires a more significant rearrangement, the algorithm simply cannot find it.
This is where Three-Opt earns its place.
Rather than removing two links, Three-Opt removes three, creating many more possible ways to reconnect the route. Although the underlying principle remains identical, the search becomes dramatically more flexible. Instead of asking whether two sections should exchange places, the algorithm effectively asks whether an entire portion of the journey should be reorganised.
Returning to My Name Is Earl, this resembles episodes such as Buried Treasure, where Earl discovers that solving one long-forgotten mistake unexpectedly changes the priorities of several others. A minor adjustment is no longer sufficient. The entire day’s plan has to be reconsidered before everything falls naturally into place. Three-Opt performs the same kind of deeper restructuring. It is computationally more expensive than Two-Opt because there are many more combinations to evaluate, but it frequently escapes local optima that would otherwise trap the simpler algorithm.
The continued relevance of these techniques is perhaps the most remarkable aspect of their story. Modern routing engines employ sophisticated approaches such as Simulated Annealing, Tabu Search and Large Neighbourhood Search to explore vast numbers of potential solutions. Yet once those methods discover a promising route, they almost always rely on variants of Two-Opt or Three-Opt to perform the final refinement. Even the most advanced optimisation systems still benefit from algorithms developed decades ago because the underlying principle remains sound: if a better sequence exists nearby, it is worth finding.
There is also a broader lesson for product managers and software designers. Many optimisation problems are not solved by producing a perfect answer immediately. Instead, they are solved by generating a good answer quickly and then improving it iteratively. Recommendation engines, manufacturing schedules, warehouse slotting systems and increasingly even AI reasoning systems all follow this pattern. The first solution is rarely the final solution.
Earl never succeeds because he writes the perfect list. He succeeds because he is prepared to revisit it whenever new information appears, continually refining his plan without losing sight of the objective. Two-Opt and Three-Opt embody exactly the same philosophy. Optimisation is seldom about discovering perfection in a single moment of brilliance. More often, it is about recognising that there is almost always a slightly better route hiding within the one you already have.
Try it interactively. Open the Two-Opt and Three-Opt simulator on its own page → — full-width, with a walkthrough of what each control does.