Algorithmic Prompt-Augmentation for Efficient LLM-Based Heuristic Design for A* Search
Thomas Bömer, Nico Koltermann, Max Disselnmeyer, Bastian Amberg, Anne Meyer
TL;DR
This work tackles automated design of A*-guided heuristics for constrained optimization by extending the Evolution of Heuristics (EoH) framework with Algorithmic Contextual Evolution of Heuristics (A-CEoH), and introduces a combined approach PA-CEoH. By embedding algorithmic A* context into prompts, the method guides LLMs to generate heuristics that align with A* search dynamics, achieving notable gains over handcrafted baselines in two domains: UPMP and SPP. The study demonstrates that A-CEoH improves heuristic quality for smaller models and that combining algorithmic and problem-context augmentations yields the best UPMP performance, while SPP benefits primarily from algorithmic context and still challenges larger prompts. Across domains, smaller, coding-oriented models can match or outperform larger models, and LLM-generated heuristics can surpass human-designed A* guiding heuristics, underscoring the value of algorithm-aware prompt design for constrained optimization. These results suggest promising generalization to additional problems and algorithmic frameworks beyond A*, highlighting practical potential for automated, context-sensitive heuristic discovery.
Abstract
Heuristic functions are essential to the performance of tree search algorithms such as A*, where their accuracy and efficiency directly impact search outcomes. Traditionally, such heuristics are handcrafted, requiring significant expertise. Recent advances in large language models (LLMs) and evolutionary frameworks have opened the door to automating heuristic design. In this paper, we extend the Evolution of Heuristics (EoH) framework to investigate the automated generation of guiding heuristics for A* search. We introduce a novel domain-agnostic prompt augmentation strategy that includes the A* code into the prompt to leverage in-context learning, named Algorithmic - Contextual EoH (A-CEoH). To evaluate the effectiveness of A-CeoH, we study two problem domains: the Unit-Load Pre-Marshalling Problem (UPMP), a niche problem from warehouse logistics, and the classical sliding puzzle problem (SPP). Our computational experiments show that A-CEoH can significantly improve the quality of the generated heuristics and even outperform expert-designed heuristics.
