TL;DR
Current Large Language Model (LLM) pipelines for automatic algorithm design are highly wasteful, often rewriting entire programs from scratch for minor edits. This paper introduces a budget-efficient framework that represents algorithms as paths in a Directed Acyclic Graph (DAG) of code blocks, using the LLM to generate compact, reusable code "corrections." This approach dramatically increases algorithm yield per token and enables precise, correction-level credit assignment to guide the search.
What Problem Does This Paper Address?
Automatic Algorithm Design (AAD) has shifted toward using LLMs as stochastic search operators to discover new heuristics and optimize code. However, existing pipelines suffer from a "full-algorithm" paradigm: every LLM query generates a complete program from scratch.
This introduces two major inefficiencies:
- Redundancy: Recurring subroutines are repeatedly rewritten, which is both token-expensive and error-prone for complex code.
- Opacity: Because full algorithms are generated and evaluated as single units, it is difficult to isolate which specific code modification caused a performance gain or drop.
The authors formalize budget-efficient AAD, treating LLM token cost as a strict constraint, and design a framework to maximize algorithm fitness under a fixed computational budget.
Methods
Instead of treating algorithms as monolithic strings, the authors propose a Graph Code Representation. Algorithms are represented as source-to-sink paths in a Directed Acyclic Graph (DAG), where individual edges represent localized code blocks.
The core workflow consists of:
- Correction Generation: The system queries the LLM to propose localized "corrections" (compact operators that insert, replace, or delete code blocks) on a high-performing reference algorithm.
- Graph Augmentation: Each correction adds new sub-paths to the DAG. Because these corrections can combinatorially compose with prior edits, a single LLM query can unlock an exponential number of new candidate algorithms.
- Surrogate-Guided Evaluation: To avoid executing every path, a Random Forest regressor acts as a surrogate model to predict algorithm fitness. It ranks unevaluated paths to select the most promising candidates for actual evaluation.
- Credit Assignment: By tracking which corrections are present in a path, the framework uses Shapley values to calculate the exact marginal contribution ($\Delta_\phi$) of each individual code modification.
The authors evaluate two variants: a context-agnostic version and a context-guided version that feeds a natural-language summary of past correction performance back into the LLM.
Datasets
The framework was validated on three challenging combinatorial optimization problems:
- Traveling Salesman Problem (TSP): Evaluated using 5 standard instances from the well-known TSPLIB benchmark (
d198,d2103,fl3795,nrw1379,pcb1173). - Location Routing Problem (LRP): Evaluated over 5 randomly generated instances.
- Bus Routing Problem (BRP): A variant without predefined stop locations, evaluated over 5 randomly generated instances.
Key Insights and Ideas
- The Power of Combinatorial Composition: By shifting the unit of generation from full algorithms to modular corrections, the graph structure allows independent edits to combine automatically. This yields significantly more testable code variants per LLM token.
- The Context Paradox (Strong vs. Weak Priors): Providing the LLM with detailed feedback summaries is highly beneficial for obscure problems where the model's prior knowledge is weak (like LRP). However, for heavily studied problems like TSP, providing explicit search context actually degrades performance. The authors note that rich context can dilute the LLM's strong internal priors while consuming a large chunk of the token budget.
- Search Depth vs. Breadth: Theoretical analysis reveals that under tight token budgets, it is optimal to prioritize breadth (sampling many independent zero-shot algorithms). As the budget grows, the optimal strategy shifts toward deeper, iterative graph-based refinement.
Key Results
The graph-based search consistently outperformed full-algorithm rewrites across equal token budgets.
- TSP Performance: The vanilla graph-based method achieved 7.5%, 19.7%, and 22.3% smaller optimality gaps compared to the baseline at token budgets of $10^5$, $10^6$, and $10^7$, respectively.
- Sustained Improvement: While baseline full-rewrite methods quickly stalled due to the compounding complexity and syntax errors of long code generation, the graph-based framework demonstrated consistent, steady improvements over longer horizons (see Figure 2).
Limitations and Future Work
The primary limitation of this framework is its reliance on a cheap evaluation oracle. Because the graph representation generates a massive combinatorial yield of candidate algorithms, the framework requires that running and scoring the code is computationally inexpensive. In domains where evaluating an algorithm takes hours or requires expensive physical simulations, the high yield of candidates could become a bottleneck.
Future research directions include adaptively tuning the per-run budget dynamically and exploring mechanisms to share discovered code corrections across parallel search runs.
Summary updated