Table of Contents
Fetching ...

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.

Algorithmic Prompt-Augmentation for Efficient LLM-Based Heuristic Design for A* Search

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.
Paper Structure (18 sections, 1 equation, 6 figures, 4 tables)

This paper contains 18 sections, 1 equation, 6 figures, 4 tables.

Figures (6)

  • Figure 1: Example sequence of moves to solve an unit-load pre-marshalling problem instance by bomer2025leveraging. Top-down view of a single-bay. Unit loads can be accessed from the north direction only.
  • Figure 2: Example sequence of moves to solve a $3\times3$ sliding puzzle. Tiles are moved into the empty cell to reach the goal configuration.
  • Figure 3: The EoH framework (grey and blue) evolves code and thoughts. The prompt augmentation components additional problem description (red) and algorithmic context (green) aim to support the evolutionary procedure.
  • Figure 4: Algorithmic context for the SPP.
  • Figure 5: Best heuristic fitness in each experimental run for each model for the UPMP and SPP. Lower values indicate better performance. The fitness scale for the UPMP plot is truncated at 0.5 and at 1 for the SPP. Each boxplot reports ten runs for the UPMP and five runs for the SPP.
  • ...and 1 more figures