A metaheuristic is a high-level, problem-independent search strategy that guides simpler heuristics through a large solution space to find good solutions in reasonable time, without guaranteeing that the result is the global optimum. In optimization for artificial intelligence, metaheuristics such as simulated annealing, genetic algorithms, tabu search and particle swarm optimization are used when a problem is non-convex, combinatorial, noisy or without gradients, so that exact methods are too slow or simply inapplicable.
The word combines the Greek prefix meta (beyond) with heuristic (rule of thumb). A metaheuristic is therefore a rule for steering rules: it decides when to accept worse moves, how to keep a population diverse and when to restart, while the problem-specific parts (solution encoding, neighborhood, objective function) are plugged in by the practitioner.
How a metaheuristic balances exploration and exploitation
Every metaheuristic manages the tension between exploration, which samples distant and unfamiliar regions of the search space, and exploitation, which refines the best solutions found so far. Too much exploitation traps the search in a local optimum; too much exploration turns it into an expensive random search.
The generic loop has four parts. A representation encodes a candidate (a permutation for a tour, a bit string for a subset, a real vector for continuous parameters). A variation operator produces new candidates by mutation, crossover or a neighborhood move. A selection or acceptance rule decides which candidates survive. A stopping criterion ends the run after a time budget, an evaluation budget or a period without improvement.
The control mechanisms that distinguish one family from another are summarized below, each with the parameter that tunes the balance between searching widely and searching deeply.
| Mechanism | Effect on search | Typical control parameter |
|---|---|---|
| Probabilistic acceptance | Allows uphill moves to escape local optima | Temperature and cooling rate |
| Short-term memory | Forbids recently visited moves | Tabu tenure, often 5 to 20 moves |
| Population diversity | Keeps several regions under study | Population size and mutation rate |
| Recombination | Combines building blocks of good solutions | Crossover probability |
| Restarts and perturbation | Jumps to new starting points | Perturbation strength |
Main families of metaheuristics
Metaheuristics fall into single-solution (trajectory) methods, which move one candidate step by step, and population-based methods, which evolve many candidates at once. Many are nature-inspired, but the metaphor matters far less than the underlying operators.
| Family | Search style | Typical use in AI and data |
|---|---|---|
| Simulated annealing | Single solution, probabilistic acceptance | Scheduling, placement, feature subsets |
| Tabu search | Single solution, memory-based | Vehicle routing, timetabling |
| Iterated local search | Single solution with restarts | Traveling salesman problem |
| Genetic algorithms | Population, crossover and mutation | Neural architecture search, design |
| CMA-ES | Population, adaptive covariance | Continuous black-box tuning |
| Particle swarm optimization | Population, velocity updates | Continuous parameter fitting |
| Ant colony optimization | Population, pheromone trails | Path and routing problems |
Hybrid methods are common in practice. A memetic algorithm couples a genetic algorithm with local search, and matheuristics combine metaheuristics with exact solvers such as mixed-integer linear programming for subproblems. Variable neighborhood search systematically changes the neighborhood structure when the current one stops yielding improvements.
How metaheuristics compare with exact and gradient methods
Metaheuristics trade optimality guarantees for generality and speed. Exact methods such as branch and bound prove optimality but scale poorly on NP-hard problems, while gradient methods are efficient only when the objective is differentiable and reasonably smooth.
| Approach | Needs gradients | Optimality guarantee | Scales to large problems |
|---|---|---|---|
| Metaheuristic | No | None, only empirical quality | Yes, with anytime results |
| Branch and bound | No | Yes, with optimality gap | Limited by exponential growth |
| Gradient descent | Yes | Global only for convex problems | Yes, for differentiable models |
| Bayesian optimization | No | None | Few dimensions, costly evaluations |
| Hill climbing | No | Local optimum only | Yes, but easily trapped |
The no free lunch theorems for optimization state that, averaged over all possible problems, no search algorithm outperforms any other. The practical consequence is that a metaheuristic performs well only when its operators exploit the structure of the problem, which is why problem-specific encodings and neighborhoods matter more than the choice of family.
Choosing and configuring a metaheuristic
Selection starts from the type of decision variables and the cost of one evaluation. Cheap evaluations favor population methods with many generations; expensive evaluations favor surrogate-assisted search or Bayesian optimization instead.
| Situation | Recommended choice | Reason |
|---|---|---|
| Permutation or routing problem | Tabu search or iterated local search | Strong neighborhood moves exist |
| Continuous, 10 to 100 variables | CMA-ES | Learns variable correlations automatically |
| Several conflicting objectives | NSGA-II or a related algorithm | Approximates the Pareto front |
| Very costly evaluations | Surrogate model with few samples | Saves evaluation budget |
| Hard constraints dominate | Repair operators or penalty terms | Keeps candidates feasible |
Parameter settings strongly influence results, so practitioners use automatic algorithm configuration tools or careful grid and random search over parameters such as population size and cooling schedule. Because the methods are stochastic, results must be reported over multiple independent runs, typically 20 to 50, with medians and spread rather than a single best value.
Limitations and common mistakes
The central weakness is the absence of a quality certificate: without a lower bound, nobody knows how far the best found solution is from the true optimum. Benchmarking against known optima or bounds from linear programming relaxations partly addresses this.
- Metaphor-driven novelty: many recently proposed algorithms rename existing operators with new animal metaphors and add little real innovation.
- Unfair comparisons: comparing methods with different evaluation budgets or untuned parameters produces misleading rankings.
- Premature convergence: populations lose diversity and collapse onto one region when selection pressure is too high.
- Ignoring problem structure: a generic encoding often performs far worse than a simple problem-aware heuristic.
- Overfitting to benchmarks: parameters tuned on a few instances can fail on the real distribution of instances.
In everyday language
Some problems have too many possible answers to check one by one. Planning delivery routes for fifty trucks is one example. A metaheuristic is a smart way of guessing that keeps improving its guesses.
Imagine searching for the highest hill in a foggy landscape. If you only walk uphill, you stop on the first small hill. A metaheuristic sometimes walks downhill on purpose or sends several searchers to different places. This helps it find higher hills. It does not promise the very highest one. It usually finds a very good answer quickly.
Seen in the real world
A regional parcel carrier must plan routes for 120 vans and about 6,000 deliveries each morning, with customer time windows and van capacity limits. An exact mixed-integer model of this vehicle routing problem cannot finish within the 30-minute planning window, so the operations team uses an adaptive large neighborhood search, a metaheuristic that repeatedly removes groups of stops from routes and reinserts them in better positions.
The search starts from a simple greedy plan and accepts occasional worse plans under a simulated annealing rule. After 20 minutes of computation, the resulting plan typically shortens total driving distance by 8 to 12 percent compared with the greedy start and respects all time windows. Planners cannot prove the plan is optimal, but a lower bound from a relaxed model shows the remaining gap is small enough for daily operations.