Latent Heuristic Search: Continuous Optimization for Automated Algorithm Design

Cheikh Ahmed, Mahdi Mostajabdaveh, Zirui Zhou · 2026

Read Latent Heuristic Search: Continuous Optimization for Automated Algorithm Design by Cheikh Ahmed, Mahdi Mostajabdaveh, Zirui Zhou (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-17137.txt.

Introduction

Ahmed, Mostajabdaveh and Zhou move automated heuristic design from discrete program search into a continuous latent space. An encoder maps programs to embeddings, a surrogate predicts performance, and gradient ascent in a flow-regularized space yields new candidates that a frozen language model turns back into code. On routing, knapsack and packing problems the method matches leading evolutionary baselines.

Catalog record

CREATORCheikh Ahmed, Mahdi Mostajabdaveh, Zirui Zhou
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE83611
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.17137

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Latent Heuristic Search: Continuous Optimization for Automated Algorithm Design Cheikh Ahmed, Mahdi Mostajabdaveh, Zirui Zhou Abstract The integration of Large Language Models (LLMs) into evolutionary frameworks has established a new paradigm for automated heuristic discovery. Despite their promise, these methods typically search in the discrete space of program syntax, relying on stochastic sampling to navigate a highly non-convex optimization landscape. This work proposes a continuous heuristic discovery framework that shifts optimization to a learned latent manifold. We employ an encoder to map discrete programs into continuous embeddings and train a differentiable surrogate model to predict performance, enabling gradient-based search. To regularize the optimization trajectory, an invertible normalizing flow maps these embeddings to a structured Gaussian prior, where we perform gradient ascent. The resulting optimized latent vectors are projected through a learned mapper into soft prompts, which condition a frozen LLM to synthesize novel executable heuristics. We evaluate the proposed method on the Traveling Salesman Problem (TSP), the Capacitated Vehicle Routing Problem (CVRP), the Knapsack Problem (KSP), and Online Bin Packing (OBP). Empirical results demonstrate that continuous latent-space optimization achieves performance competitive with state-of-the-art discrete evolutionary baselines while offering a complementary methodological alternative for automated algorithm design. The implementation code is available at https://github.com/cheikh025/LHS . 1 Introduction Heuristic algorithms are central to combinatorial optimization, enabling high-quality solutions for problems such as the Traveling Salesman Problem (TSP) [ 10 ] , the Capacitated Vehicle Routing Problem (CVRP) [ 21 ] , and online bin packing (OBP) [ 7 ] under practical time constraints. Despite their importance, designing strong heuristics remains largely expert-driven, requiring iterative refinement, deep domain knowledge, and extensive empirical testing. Recent work has shown that large language models (LLMs) can support algorithm discovery when embedded in a rigorous search-and-evaluate loop. FunSearch couples LLM-based code generation with evolutionary sampling and execution-based evaluation, demonstrating improvements on mathematical construction tasks and on classic heuristic settings such as online bin packing [ 19 ] . Building on this idea, Evolution of Heuristics (EoH) introduces a framework that co-evolves high-level natural-language “thoughts” describing heuristic strategies alongside executable code, with the aim of improving search efficiency and diversity [ 12 ] . ReEvo further frames LLMs as hyper-heuristics and uses reflective feedback to guide evolutionary search, providing an explicit mechanism for steering generation toward more effective heuristic behaviors [ 22 ] . Complementary lines of work explore alternative search operators and exploration strategies, including MCTS-based exploration [ 23 ] , diversity-driven evolutionary search with Harmony Search [ 2 ] , and more general evolutionary coding agents for scientific and algorithmic discovery [ 16 ] . Collectively, these works highlight a key lesson: LLMs become substantially more reliable for heuristic design when paired with systematic exploration and objective evaluation, rather than one-shot generation. However, many LLM-based automated heuristic design methods still operate primarily in the discrete space of programs , relying on mutations, recombination, and repeated LLM sampling over code tokens. This often yields a challenging optimization landscape and can require many expensive evaluations to discover consistent improvements. In parallel, research on latent program representations suggests that program search can be made more structured by learning continuous embeddings of code and performing optimization directly in that learned space. Approaches such as LEAPS learn embeddings and decoders that enable search over latent variables rather than explicit syntactic edits [ 20 ] , and subsequent work explores latent program space search as a mechanism for generalization and adaptation [ 14 ] . Closely related, program synthesis has been explicitly framed as continuous optimization under specifications given by input/output examples or test-based error signals: NPO [ 11 ] trains a neural program autoencoder to embed programs into a continuous space and then applies derivative-free optimization (e.g., CMA-ES) over latents, decoding candidates back to programs for execution-based scoring. In contrast, GENESYS [ 15 ] avoids a learned autoencoder by directly parameterizing token choices with continuous variables and similarly optimizes these parameters with CMA-ES augmented by restart policies. These results motivate the hypothesis that automated heuristic design may benefit from shifting the primary search process from code token space to a continuous representation space that captures semantic variation among heuristics; however, our setting differs from I/O consistency synthesis in that we search for high-performing heuristic programs under execution-based benchmarking, rather than programs that satisfy a given set of I/O examples. In this work, we propose a framework for discovering improved heuristic algorithms by optimizing in a learned latent space of heuristic programs . Our approach represents candidate programs as continuous embeddings and learns a surrogate ranking model that predicts heuristic performance from these representations. To regularize the optimization procedure and preserve decodability, we fit an invertible normalizing flow that maps program embeddings to a structured prior space, enabling gradient-based search in a well-conditioned space while remaining close to the manifold of plausible heuristics. To translate optimized latent codes into executable algorithms, we introduce a decoding pathway in which candidate embeddings are mapped to soft prompts that condition an LLM-based code generator. The resulting code is validated for syntactic correctness and executed under the benchmark protocol to obtain its performance score. In contrast to token-level evolutionary search, our approach leverages a continuous, learnable search geometry over heuristic designs while retaining strict execution-based evaluation. 2 Problem Formulation Let \mathcal{P} denote the set of syntactically valid programs, written in a fixed programming language, that implement heuristics for a target combinatorial optimization problem (e.g., TSP, OBP). For any p\in\mathcal{P} , we evaluate performance by executing p on a benchmark set of instances D_{\mathrm{bench}}=\{x_{j}\}_{j=1}^{M} under a standardized protocol (e.g., fixed time limits, feasibility checks, and scoring rules), which yields instance-level objective values \mathrm{Cost}(p;x_{j})\in\mathbb{R} . To unify notation across minimization and maximization tasks, we define y(p)\;:=\;\frac{1}{M}\sum_{j=1}^{M}\mathrm{Cost}(p;x_{j}),\qquad s(p)\;:=\;\alpha\,y(p),\quad\alpha\in\{+1,-1\}, (1) where \alpha=+1 for maximization tasks and \alpha=-1 for minimization tasks. The mapping p\mapsto s(p) is treated as a black box and is non-differentiable with respect to program tokens. Using this evaluator, we maintain a dataset of scored programs \mathcal{D}=\{(p_{i},s_{i})\}_{i=1}^{N} , where s_{i}:=s(p_{i}) . The goal is to discover an improved heuristic program by solving p^{\star}\in\arg\max_{p\in\mathcal{P}}\;s(p), (2) using search in a learned continuous representation space rather than discrete, token-level edits in program space. 3 Method We propose a framework for heuristic discovery via continuous optimization in a learned latent program space. Figure 3 provides an overview of the proposed pipeline. Specifically, we (i) encode programs into continuous representations, (ii) train a differentiable surrogate that predicts program performance from these representations, and (iii) perform gradient-based optimization to identify improved latent candidates, which are subsequently decoded into executable programs by a large language model (LLM) and evaluated under the benchmark protocol. 3.1 Latent Heuristic Search To discover high-performing heuristics, we shift the search process from the discrete, non-differentiable space of code to a continuous latent manifold. This transition enables the use of continuous optimization techniques, such as gradient-based updates, in the learned representation space, The complete discovery procedure is summarized in Algorithm 1 . Each heuristic program p\in\mathcal{P} is mapped to a latent vector using a code encoder: z\;=\;E(p),\qquad z\in\mathbb{R}^{d}. (3) Our objective is to find programs with maximal benchmark performance score s(p) (Section 2 ). Since s(p) is obtained by executing p under the benchmark protocol, it is treated as a black-box

Read the complete text