让大模型生成可运行的工业优化代码,关键在类型与依赖闭环
Type-Aware Retrieval-Augmented Generation with Dependency Closure for Solver-Executable Industrial Optimization Modeling
- 构建带类型的领域知识图谱,自动捕获数学依赖关系
- 生成代码前计算最小依赖闭包,确保可编译执行
- 适合需要高可靠性代码生成的工业优化场景
工业优化建模自动化需将自然语言需求准确转为可执行代码。现有大模型常因缺少声明、类型不一致或依赖不全导致代码不可编译。本文提出一种类型感知的检索增强生成方法,通过解析学术论文和求解器代码等异构源,构建带类型的领域知识库,并在知识图中编码数学依赖。给定自然语言指令时,采用混合检索并基于图传播计算最小依赖闭包,即生成可执行代码所需的最少类型化符号集合。在电池生产需求响应优化与柔性作业车间调度两个高约束工业案例上验证:第一例成功生成包含激励与负载削减约束的可执行模型,实现削峰保利润;第二例持续生成可编译模型并达到已知最优解,而基线方法全部失败。消融实验表明,类型感知的依赖闭包对避免结构幻觉、保障可执行性至关重要,解决了复杂工程优化中大模型落地的关键障碍。
原文摘要 · Abstract (English)
Automated industrial optimization modeling requires reliable translation of natural-language requirements into solver-executable code. However, large language models often generate non-compilable models due to missing declarations, type inconsistencies, and incomplete dependency contexts. We propose a type-aware retrieval-augmented generation (RAG) method that enforces modeling entity types and minimal dependency closure to ensure executability. Unlike existing RAG approaches that index unstructured text, our method constructs a domain-specific typed knowledge base by parsing heterogeneous sources, such as academic papers and solver code, into typed units and encoding their mathematical dependencies in a knowledge graph. Given a natural-language instruction, it performs hybrid retrieval and computes a minimal dependency-closed context, the smallest set of typed symbols required for solver-executable code, via dependency propagation over the graph. We validate the method on two constraint-intensive industrial cases: demand response optimization in battery production and flexible job shop scheduling. In the first case, our method generates an executable model incorporating demand-response incentives and load-reduction constraints, achieving peak shaving while preserving profitability; conventional RAG baselines fail. In the second case, it consistently produces compilable models that reach known optimal solutions, demonstrating robust cross-domain generalization; baselines fail entirely. Ablation studies confirm that enforcing type-aware dependency closure is essential for avoiding structural hallucinations and ensuring executability, addressing a critical barrier to deploying large language models in complex engineering optimization tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。