🤖 AI Summary
This work addresses the challenges of directly generating optimization solver code with large language models, which often suffers from high error rates and substantial inference costs, making it difficult to balance correctness and efficiency. To overcome these limitations, the authors propose IR2Solve, a framework that leverages a single LLM invocation to produce a structured intermediate representation (ModelIR) adhering to scalar constraint conventions. This representation is then deterministically verified and compiled into solver-executable code through a two-stage transformation process. Evaluated across six optimization benchmarks, IR2Solve maintains strong solution correctness while requiring only 1/3.3 to 1/22.9 of the token consumption compared to multi-agent or iterative approaches, significantly reducing computational overhead without compromising accuracy.
📝 Abstract
Large language models (LLMs) can translate natural-language optimization problems into solver-ready formulations, but direct code generation is brittle: schema, indexing, and semantic errors can cause compilation failures, infeasible models, or incorrect objectives, while iterative repair, search, and multi-agent workflows increase inference cost. We present IR2Solve, an intermediate-representation-first autoformulation pipeline that uses a single semantic LLM call to produce a schema-constrained ModelIR, followed by two deterministic stages: verification and IR-to-solver compilation. ModelIR explicitly represents sets, parameters, variables, objectives, and constraints using restricted Python-like expression strings. A concrete scalar-constraint convention represents finite per-index constraint families as individual entries, reducing free-index and implicit-quantification errors while simplifying downstream verification and compilation. Across six cleaned optimization benchmarks, IR2Solve achieves strong objective correctness and remains competitive with recent optimization-modeling systems. A controlled ablation on 153 IndustryOR and ComplexLP instances shows sequential gains from the structured IR interface, the scalar-constraint instruction, and deterministic verification. On a matched ten-instance cost panel, IR2Solve uses one semantic call per instance, whereas Chain-of-Experts and SAC-Opt use 8 and 39 calls per instance and consume 3.3 and 22.9 times the token volume of IR2Solve, respectively. These results show that structured intermediate representations, combined with deterministic post-generation processing, provide a practical accuracy-cost trade-off for LLM-based optimization autoformulation.