Abstract
Heuristics are widely used for dealing with complex search and optimization problems. However, manual design of heuristics can be often very labour extensive and requires rich working experience and knowledge. This paper proposes Evolution of Heuristic (EoH), a novel evolutionary paradigm that leverages both Large Language Models (LLMs) and Evolutionary Computation (EC) methods for Automatic Heuristic Design (AHD). EoH represents the ideas of heuristics in natural language, termed thoughts. They are then translated into executable codes by LLMs. The evolution of both thoughts and codes in an evolutionary search framework makes it very effective and efficient for generating high-performance heuristics. Experiments on three widely studied combinatorial optimization benchmark problems demonstrate that EoH outperforms commonly used handcrafted heuristics and other recent AHD methods including FunSearch. Particularly, the heuristic produced by EoH with a low computational budget significantly outperforms widely-used human hand-crafted baseline algorithms for the online bin packing problem.
Introduction
Designing effective heuristics—rules of thumb used to solve complex optimization problems like scheduling or routing—is traditionally a manual, labor-intensive process requiring deep domain expertise. While Automatic Heuristic Design (AHD) aims to solve this, previous methods have significant drawbacks. Genetic Programming (GP) requires hand-crafted primitives, while recent LLM-based approaches like Google DeepMind’s FunSearch search directly in the space of code.
Searching through raw code is inefficient; it is analogous to writing a novel by randomly changing words without a plot. Furthermore, standalone LLMs often struggle to generate truly novel ideas beyond their training data through simple prompting. The authors identify a critical gap: the need for a system that mimics the human design process—reasoning about the logic (thoughts) before implementing the code.
The Evolution of Heuristic (EoH) Framework
The core of EoH is a population-based evolutionary framework where each "individual" consists of three parts: a natural language thought, the corresponding Python code, and a fitness value. This dual-representation allows the system to evolve high-level strategies alongside their technical implementations.
The process follows an iterative cycle:
- Initialization: An LLM generates an initial population of heuristics based on a problem description.
- Evolutionary Prompts: Instead of standard crossover/mutation, EoH uses five specialized prompt strategies to guide the LLM:
- Exploration (E1, E2): The LLM is shown multiple parent heuristics and asked to either create something entirely different (E1) or find a common underlying idea and build upon it (E2).
- Modification (M1, M2, M3): The LLM refines a single parent by improving its performance (M1), tuning its parameters (M2), or simplifying the code by removing redundant components (M3).
- Evaluation: The generated code is executed on benchmark problem instances to calculate its fitness.
- Selection: The best-performing heuristics are kept for the next generation.
Crucially, the LLM is always asked to describe the "thought" first before writing the code, ensuring the implementation is grounded in a coherent strategy.
Experimental Evaluation
The authors evaluated EoH on three classic combinatorial optimization problems:
- Online Bin Packing: Packing items of varying sizes into the fewest possible bins. Evaluation used Weibull-distributed instances (1k to 10k items).
- Traveling Salesman Problem (TSP): Finding the shortest route through a set of cities. Evaluation was conducted on the standard TSPLib benchmark and randomly generated instances.
- Flow Shop Scheduling Problem (FSSP): Scheduling jobs across multiple machines to minimize total time, using the well-known Taillard instances.
Results and Discussion
EoH demonstrated superior performance and efficiency across all benchmarks. In Online Bin Packing, EoH achieved an average gap to the lower bound of 1.18%, significantly better than the human-designed "Best Fit" (4.13%) and FunSearch (2.23%).
Key Insights
- The "Thought" Matters: Ablation studies showed that evolving natural language thoughts alongside code significantly boosts performance. The "thought" acts as a high-level abstraction that helps the LLM maintain logical consistency and explore the search space more effectively than code-only search.
- Efficiency via Reasoning: Unlike FunSearch, which might require millions of queries to find a breakthrough, EoH achieves superior results with just a few thousand queries (e.g., ~2,000 for Bin Packing). This is because the prompt strategies force the LLM to reason about why a heuristic works.
- Generalization: Heuristics evolved on small problem instances generalized remarkably well to much larger instances, suggesting that EoH discovers fundamental algorithmic principles rather than just overfitting to specific data.
Conclusion
EoH represents a significant step toward fully automated, high-performance algorithm design. By combining the reasoning capabilities of LLMs with the robust search of evolutionary computation, it bridges the gap between human-like conceptualization and machine-like optimization. Future work may involve human-in-the-loop integration, where experts manually inject "thoughts" to guide the evolutionary process, and training LLMs specifically on algorithmic design data to further enhance domain-specific reasoning.
Summary updated