Metaheuristic

Also known as: metaheuristics

On this page 7

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.

MechanismEffect on searchTypical control parameter
Probabilistic acceptanceAllows uphill moves to escape local optimaTemperature and cooling rate
Short-term memoryForbids recently visited movesTabu tenure, often 5 to 20 moves
Population diversityKeeps several regions under studyPopulation size and mutation rate
RecombinationCombines building blocks of good solutionsCrossover probability
Restarts and perturbationJumps to new starting pointsPerturbation strength
Mechanisms that control the search balance

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.

FamilySearch styleTypical use in AI and data
Simulated annealingSingle solution, probabilistic acceptanceScheduling, placement, feature subsets
Tabu searchSingle solution, memory-basedVehicle routing, timetabling
Iterated local searchSingle solution with restartsTraveling salesman problem
Genetic algorithmsPopulation, crossover and mutationNeural architecture search, design
CMA-ESPopulation, adaptive covarianceContinuous black-box tuning
Particle swarm optimizationPopulation, velocity updatesContinuous parameter fitting
Ant colony optimizationPopulation, pheromone trailsPath and routing problems
Common metaheuristic families and their typical use

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.

ApproachNeeds gradientsOptimality guaranteeScales to large problems
MetaheuristicNoNone, only empirical qualityYes, with anytime results
Branch and boundNoYes, with optimality gapLimited by exponential growth
Gradient descentYesGlobal only for convex problemsYes, for differentiable models
Bayesian optimizationNoNoneFew dimensions, costly evaluations
Hill climbingNoLocal optimum onlyYes, but easily trapped
Metaheuristics versus other optimization approaches

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.

SituationRecommended choiceReason
Permutation or routing problemTabu search or iterated local searchStrong neighborhood moves exist
Continuous, 10 to 100 variablesCMA-ESLearns variable correlations automatically
Several conflicting objectivesNSGA-II or a related algorithmApproximates the Pareto front
Very costly evaluationsSurrogate model with few samplesSaves evaluation budget
Hard constraints dominateRepair operators or penalty termsKeeps candidates feasible
Decision guide for selecting a method

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.