Table of Contents
Fetching ...

Canonical Intermediate Representation for LLM-based optimization problem formulation and code generation

Zhongyuan Lyu, Shuoyu Hu, Lujie Liu, Hongxia Yang, Ming LI

TL;DR

This work tackles the problem of converting natural-language optimization problem descriptions into accurate mathematical models and code, tackling both rule compositeness and modeling-paradigm sensitivity. It introduces the Canonical Intermediate Representation ($CIR$), a semantic layer that encodes operational intents as constraint archetypes and paradigms, decoupling rule logic from mathematical instantiation. Built atop CIR, the Rule-to-Constraint ($R2C$) framework is a training-free, multi-agent pipeline that extracts structured problem information, retrieves CIR implementations, clusters by paradigm, and instantiates a complete model and solver code via retrieval-augmented reasoning; a formal soundness guarantee ensures translated models respect the original rules. The authors validate R2C on ORCOpt-Bench, achieving state-of-the-art $AR=47.2\%$ and competitive results on established benchmarks, with reflection further boosting performance to new bests in some cases. This approach promises scalable, explainable, and generalizable LLM-based optimization formulation across diverse domains by grounding NL descriptions in a structured semantic layer and a transparent, traceable generation process.

Abstract

Automatically formulating optimization models from natural language descriptions is a growing focus in operations research, yet current LLM-based approaches struggle with the composite constraints and appropriate modeling paradigms required by complex operational rules. To address this, we introduce the Canonical Intermediate Representation (CIR): a schema that LLMs explicitly generate between problem descriptions and optimization models. CIR encodes the semantics of operational rules through constraint archetypes and candidate modeling paradigms, thereby decoupling rule logic from its mathematical instantiation. Upon a newly generated CIR knowledge base, we develop the rule-to-constraint (R2C) framework, a multi-agent pipeline that parses problem texts, synthesizes CIR implementations by retrieving domain knowledge, and instantiates optimization models. To systematically evaluate rule-to-constraint reasoning, we test R2C on our newly constructed benchmark featuring rich operational rules, and benchmarks from prior work. Extensive experiments show that R2C achieves state-of-the-art accuracy on the proposed benchmark (47.2% Accuracy Rate). On established benchmarks from the literature, R2C delivers highly competitive results, approaching the performance of proprietary models (e.g., GPT-5). Moreover, with a reflection mechanism, R2C achieves further gains and sets new best-reported results on some benchmarks.

Canonical Intermediate Representation for LLM-based optimization problem formulation and code generation

TL;DR

This work tackles the problem of converting natural-language optimization problem descriptions into accurate mathematical models and code, tackling both rule compositeness and modeling-paradigm sensitivity. It introduces the Canonical Intermediate Representation (), a semantic layer that encodes operational intents as constraint archetypes and paradigms, decoupling rule logic from mathematical instantiation. Built atop CIR, the Rule-to-Constraint () framework is a training-free, multi-agent pipeline that extracts structured problem information, retrieves CIR implementations, clusters by paradigm, and instantiates a complete model and solver code via retrieval-augmented reasoning; a formal soundness guarantee ensures translated models respect the original rules. The authors validate R2C on ORCOpt-Bench, achieving state-of-the-art and competitive results on established benchmarks, with reflection further boosting performance to new bests in some cases. This approach promises scalable, explainable, and generalizable LLM-based optimization formulation across diverse domains by grounding NL descriptions in a structured semantic layer and a transparent, traceable generation process.

Abstract

Automatically formulating optimization models from natural language descriptions is a growing focus in operations research, yet current LLM-based approaches struggle with the composite constraints and appropriate modeling paradigms required by complex operational rules. To address this, we introduce the Canonical Intermediate Representation (CIR): a schema that LLMs explicitly generate between problem descriptions and optimization models. CIR encodes the semantics of operational rules through constraint archetypes and candidate modeling paradigms, thereby decoupling rule logic from its mathematical instantiation. Upon a newly generated CIR knowledge base, we develop the rule-to-constraint (R2C) framework, a multi-agent pipeline that parses problem texts, synthesizes CIR implementations by retrieving domain knowledge, and instantiates optimization models. To systematically evaluate rule-to-constraint reasoning, we test R2C on our newly constructed benchmark featuring rich operational rules, and benchmarks from prior work. Extensive experiments show that R2C achieves state-of-the-art accuracy on the proposed benchmark (47.2% Accuracy Rate). On established benchmarks from the literature, R2C delivers highly competitive results, approaching the performance of proprietary models (e.g., GPT-5). Moreover, with a reflection mechanism, R2C achieves further gains and sets new best-reported results on some benchmarks.
Paper Structure (50 sections, 2 theorems, 13 equations, 4 figures, 8 tables)

This paper contains 50 sections, 2 theorems, 13 equations, 4 figures, 8 tables.

Key Result

Proposition 3.1

Under the design of the CIR knowledge base, every feasible solution of the translated model $M(d)$ satisfies all original operational rules in $\mathcal{R}(d)$. Formally,

Figures (4)

  • Figure 1: Examples of LLM-based Automated Optimization Formulation with Complex Operational Rules. The figure presents a comparative analysis of Direct LLM Translation, Human Expert Reasoning, and our R2C Framework in addressing two core challenges: the Composite Rule challenge (left), where a single rule decomposes into multiple constraints; and the Paradigm-Sensitive challenge (right), where the mathematical formulation is governed by the chosen modeling paradigm.
  • Figure 2: The R2C agent framework architecture.
  • Figure 3: Distribution of problems across domains and constraint category counts in ORCOpt-Bench.
  • Figure 4: Distribution of constraint types per problem in ORCOpt-Bench. The figure shows the statistical distribution of the number of constraint types contained in each problem in the dataset.

Theorems & Definitions (3)

  • Proposition 3.1: CIR Soundness Guarantee
  • Proposition 1.1: Full CIR Soundness Guarantee
  • proof