Local search is a family of optimization methods that start from one complete candidate solution and repeatedly replace it with a better solution from its neighborhood, stopping when no neighbor improves the objective. In the Optimization topic of artificial intelligence, a local search algorithm is the standard tool for large combinatorial problems such as scheduling, routing and satisfiability, where exhaustive search is impossible and a good answer found quickly is worth more than a proven optimum found too late.
The approach trades guarantees for scalability. Local search usually cannot prove that its result is globally optimal, but it needs little memory, works on problems with millions of variables and can be stopped at any time with a usable answer, which makes it an anytime algorithm.
How local search moves through the search space
Local search works by defining a neighborhood function that maps each solution to a set of nearby solutions, then walking through that landscape one move at a time. A move is a small, cheap modification: swapping two cities in a tour, flipping one Boolean variable or reassigning one job to another machine. The algorithm evaluates neighbors with the objective function and accepts a move according to its acceptance rule.
The process has four components that together determine its behavior. Changing any one of them produces a different named method, which is why local search is better understood as a design template than as a single algorithm.
| Component | Role | Typical choice |
|---|---|---|
| Solution representation | Encodes a candidate | Permutation, bit vector, assignment |
| Neighborhood | Defines reachable solutions | 2-opt, bit flip, swap, insert |
| Acceptance rule | Decides whether to move | First improvement, best improvement |
| Stopping criterion | Ends the search | Local optimum, time limit, iteration cap |
Efficient implementations rely on incremental evaluation: instead of recomputing the full objective, they compute only the change caused by a move, often in constant time. This delta evaluation is the main reason local search scales to very large instances.
Local optima and the shape of the landscape
A local optimum is a solution that no single move can improve, and every pure descent method eventually stops at one. Whether that point is close to the global optimum depends on the fitness landscape, meaning the objective values arranged by the neighborhood structure. Smooth landscapes with few, wide basins are easy; rugged landscapes with many shallow basins trap simple methods quickly.
The neighborhood defines what counts as local. A larger neighborhood produces fewer local optima, because more moves are available, but each step costs more time to evaluate. The 3-opt neighborhood for the traveling salesman problem, for example, contains roughly cubic numbers of moves in the tour length, compared with quadratic numbers for 2-opt.
Plateaus are a second obstacle. On a plateau, many neighbors share the same objective value, so the search has no gradient to follow and may wander without progress. Satisfiability solvers handle this with sideways moves and random noise.
Main variants of local search
Variants of local search differ mainly in how they escape local optima. Pure hill climbing does not escape at all, while metaheuristics add memory, randomness or restarts to continue exploring after the first stall.
| Variant | Escape mechanism | Typical use |
|---|---|---|
| Hill climbing | None; stops at first local optimum | Fast baseline, polishing step |
| Random-restart search | Restarts from new random points | Cheap diversification |
| Simulated annealing | Accepts worse moves with decreasing probability | Rugged continuous or discrete landscapes |
| Tabu search | Forbids recently reversed moves | Scheduling, routing, assignment |
| Iterated local search | Perturbs the optimum, then descends again | Traveling salesman, flow shop |
| Variable neighborhood search | Switches between neighborhood sizes | Location and clustering problems |
Stochastic local search for satisfiability, such as WalkSAT, mixes greedy flips with random flips at a fixed noise probability, typically between 0.2 and 0.6. Population methods such as genetic algorithms often embed local search as an improvement step, a combination known as memetic algorithms.
Local search compared with other optimization approaches
Local search sits between exact methods and constructive heuristics. Exact solvers based on branch and bound or mixed-integer linear programming prove optimality but may need exponential time, while greedy construction builds one answer quickly and never revises it. Local search revises a complete answer and therefore usually reaches better quality than construction at far lower cost than exact solving.
| Approach | Works on | Optimality proof | Scales to |
|---|---|---|---|
| Local search | Complete solutions | No | Millions of variables |
| Branch and bound | Partial solutions in a tree | Yes, if it finishes | Moderate instances |
| Greedy construction | Partial solutions built once | No | Very large instances |
| Gradient descent | Continuous parameters | Only for convex problems | Very large models |
Gradient descent is formally a continuous local search in which the neighborhood is an infinitesimal step along the negative gradient. The distinction matters in practice: discrete local search needs explicit move operators, whereas gradient methods derive the direction analytically.
Designing and tuning a local search
Good local search design starts with a representation that keeps solutions feasible or measures infeasibility as a penalty in the objective. Practitioners then choose neighborhoods that make meaningful structural changes while remaining cheap to evaluate, and they test the method on instances with known optimal values before trusting it on production data.
| Situation | Recommended choice | Reason |
|---|---|---|
| Hard constraints are tight | Penalty function with adaptive weights | Lets the search cross infeasible regions |
| Neighborhood is very large | First improvement with random order | Avoids scanning every neighbor |
| Search stalls early | Add perturbation or tabu memory | Escapes shallow basins |
| Results vary between runs | Report best and median of many seeds | Gives an honest quality estimate |
- Start from a good initial solution, often a greedy construction, to save iterations.
- Use delta evaluation for every move operator before tuning any parameter.
- Tune temperature schedules, tabu tenure and noise on a separate set of instances.
Limitations and common mistakes
The central limitation of local search is the absence of a quality guarantee: without a lower bound from relaxation or duality, a user cannot tell how far the result is from optimal. Performance also depends heavily on problem-specific neighborhoods, so a method that excels on routing may fail on timetabling.
- Comparing methods on a single run hides the large variance of stochastic search.
- Overly small neighborhoods produce many poor local optima and premature stops.
- Recomputing the full objective for each move makes the search orders of magnitude slower.
- Ignoring constraint handling lets the search report infeasible solutions as good ones.
Put simply
Local search is a way to improve an answer by making small changes, one at a time. You start with any reasonable answer. You try a small change. If the change helps, you keep it. If not, you try another one.
Think of a hiker in fog who wants to reach the lowest valley. The hiker cannot see the whole map. So the hiker always steps downhill. This often works well. But the hiker may stop in a small dip that is not the lowest point. Smarter versions sometimes step uphill on purpose, or start again elsewhere, to find a deeper valley.
In practice
A regional parcel carrier plans routes for 120 vans and about 4,000 daily stops. An exact solver cannot finish before the morning departure, so the planning team builds a first plan with a greedy insertion rule and then runs local search for ten minutes. The moves relocate single stops between vans, swap pairs of stops and apply 2-opt inside each route, with tabu memory to avoid cycling.
On historical days, the greedy plan alone needs about 9 percent more driving distance than the best known plans. After local search, the gap falls to roughly 2 percent, and every route still respects time windows and van capacity. The team runs eight random seeds in parallel and keeps the best plan, which gives consistent quality within the fixed planning window.