arXiv:2611.12060cs.AINov 2026

Manuscript Offprint

arXiv:2611.12060

COMPASS: Composable Policy-Amortized Structured Search for LLM-Based Optimization Modeling

Nguyen Le Minh Hoang, Van Duc Cuong, Bui Trong Duc, Huynh Thi Thanh Binh

Abstract

Large language models offer a promising technique for translating natural-language optimization problems into solver code, but their reliability remains constrained by the quality of template retrieval. While recent structured methods improve over flat prompting through hierarchical taxonomy search, their traversal rules remain fixed or LLM-driven at inference time, leaving retrieval unable to improve from past successes and failures. This motivates treating template retrieval as a policy that can be learned from modeling experience, rather than as a static inference-time rule. We propose COMPASS, a policy-amortized framework for retrieving optimization templates in LLM-based solver modeling, which represents the template library as a directed acyclic graph and formulates retrieval as a sequential decision process over template nodes. A deep Q-network learns a reusable traversal policy from template-level judgments and execution feedback, reducing reliance on fixed heuristic traversal through feedback-driven graph navigation. To support extensible retrieval, COMPASS embeds problem descriptions and template nodes in a shared semantic space, allowing newly inserted templates to be scored from their text descriptions without redefining the action space. Experiments across multiple LLM backbones and optimization-modeling benchmarks demonstrate that COMPASS consistently improves over heuristic structured retrieval, with the largest gains on complex and mixed-category problems.

1 Introduction

Large language models (LLMs) are increasingly used to translate natural-language optimization problems into mathematical formulations and executable solver code. This setting, often referred to as autoformulation, has the potential to lower the expertise barrier for building operations-research models [Astorga et al., 2025, Liu et al., 2025, Li et al., 2025]. However, optimization problems rarely follow a single canonical pattern. A single description may combine routing, assignment, scheduling, capacity, and resource-allocation structures, making correct template selection a central bottleneck for downstream code generation.

Recent methods improve reliability by injecting structured modeling knowledge into the prompting process. Autoformulation approaches decompose problems into variables, objectives, and constraints, while structured retrieval methods organize modeling knowledge into hierarchical taxonomies [Astorga et al., 2025, Liu et al., 2025, Li et al., 2025]. Yet these retrieval strategies are typically fixed at inference time. They can guide an LLM toward relevant modeling patterns, but they do not learn from which templates previously led to valid formulations, feasible solver runs, or execution failures.

*Co-first author.

†Corresponding author.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

In contrast, search-based methods can adaptively explore alternative formulations, but doing so separately for each instance incurs substantial test-time cost.

This paper is motivated by the view that optimization-template retrieval is not only a semantic matching problem, but a sequential decision process over structured modeling knowledge. Early retrieval choices determine which modeling families and executable templates remain reachable, so a good retriever should both exploit the organization of the template library and improve from past modeling feedback. We propose COMPASS, a policy-amortized framework that represents the template library as a directed acyclic graph (DAG) and learns a traversal policy from LLM-based structural judgments and solver-execution signals. By scoring problem-template compatibility in a shared semantic space, COMPASS can evaluate newly inserted templates from their textual metadata without changing the policy architecture, while beam traversal enables retrieval of complementary templates for mixed-structure problems.

Our main contributions are:

  • We recast optimization-template retrieval as a graph-structured sequential decision problem over a template DAG, where internal nodes represent modeling families and leaves represent executable templates. The DAG captures shared substructures among optimization models and allows a template to belong to multiple related modeling paths, making the retrieval structure more flexible than a strict tree taxonomy.

  • We develop a policy-amortized retrieval algorithm that learns reusable traversal decisions from LLM-based structural judgment and solver-execution feedback. The method uses semantic node scoring to evaluate candidate templates from textual metadata, enabling new templates to be inserted without redefining the policy output space.

  • We empirically validate COMPASS across multiple optimization-modeling benchmarks and LLM backbones, demonstrating consistent improvements over direct prompting, heuristic structured retrieval, and test-time search baselines, with the largest gains on structurally complex problems.