arXiv:2601.17670cs.PLcs.AI2026-01

用编译器反馈让大模型生成可读的数学规划代码

Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop

  • 通过生成-编译-评估-修正循环,自动写出可读的代数建模语言代码
  • 在多个基准上比传统提示方法更省成本且质量更高
  • 适合需要快速生成可验证优化模型的研究者和工程师

数学规划广泛应用于物流、能源和人力调度等领域,用于建模和求解工业优化问题,但使用需深厚领域知识。大语言模型可将自然语言描述转化为优化模型,但现有方法成本高,且输出通用编程代码(如Python),难以检查、验证和复用。本文提出SyntAGM系统,通过迭代生成-编译-评估-修正流程,生成可读的代数建模语言代码。该系统利用PyOPL——一种类似OPL的建模语言编译器,提供可操作的修复反馈。为获得符合问题描述的有效PyOPL模型,SyntAGM结合编译器反馈与基于LLM的对齐判别器,并融合目标语言语法的上下文暴露及少量示例检索。在多个基准测试中,SyntAGM相较现有提示基线展现出更优的成本-质量平衡。

原文摘要 · Abstract (English)

Mathematical programming is widely employed across various sectors - such as logistics, energy, and workforce planning - to model and solve industrial optimisation problems, but its use requires substantial domain expertise. Large language models offer a promising way to translate natural-language problem descriptions into optimisation models, yet existing approaches are costly and generally produce models written in general-purpose computer code (e.g. Python), which can be difficult to inspect, validate, and reuse. In this work, we introduce SyntAGM, a system that generates optimisation models in a readable algebraic modelling language through an iterative generate-compile-assess-revise loop. SyntAGM leverages PyOPL, an OPL-like modelling language compiler designed to provide actionable feedback for iterative model repair. To obtain a valid PyOPL model that matches the problem description, SyntAGM mobilises compiler feedback and an LLM-based alignment judge. In addition, it combines in-context exposure to the target language grammar, and few-shot retrieval of modelling exemplars. Across multiple benchmarks, SyntAGM achieves a more favourable cost-quality trade-off compared to established prompting baselines.

数学规划大模型代码生成代数建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。