用大模型自动生成建筑控制模型代码,显著缩短开发时间。
Automating Modelica Module Generation Using Large Language Models: A Case Study on Building Control Description Language
- 设计结构化流程,结合提示工程与人工校验生成Modelica代码。
- 控制模块生成成功率83%,失败代码需1-8小时人工修复。
- 适合建筑能源系统建模者,尤其关注效率提升的工程师。
动态能源系统与控制需要先进建模框架来设计和测试监控及容错策略。Modelica是一种广泛使用的基于方程的语言,但开发控制模块耗时且需专业技能。本文以建筑Modelica库中的控制描述语言模块生成为例,研究大语言模型(LLMs)的自动化能力。我们构建了包含标准化提示模板、库感知定位、OpenModelica自动编译及人机协同评估的流程。实验涵盖四个基础逻辑任务(And、Or、Not、Switch)和五个控制模块(冷水机启停、旁通阀控制、冷却塔风机转速、系统请求、泄压挡板控制)。结果表明,GPT-4o在零样本模式下无法生成可执行代码,而Claude Sonnet 4通过精心设计提示,对基础逻辑块实现最高成功率;控制模块成功率达83%,失败输出需中等程度人工修复(约1至8小时)。检索增强生成常导致模块选择错误(如将And误为Or),而确定性硬规则搜索策略避免此类问题。人工评估优于AI评估,因当前大模型无法判断仿真结果或行为正确性。尽管存在局限,该流程使单模块平均开发时间从10至20小时降至4至6小时,节省40%至60%时间。结果凸显大模型辅助生成的潜力与瓶颈,指向预仿真验证、更强定位和闭环评估等未来方向。
原文摘要 · Abstract (English)
Dynamic energy systems and controls require advanced modeling frameworks to design and test supervisory and fault tolerant strategies. Modelica is a widely used equation based language, but developing control modules is labor intensive and requires specialized expertise. This paper examines the use of large language models (LLMs) to automate the generation of Control Description Language modules in the Building Modelica Library as a case study. We developed a structured workflow that combines standardized prompt scaffolds, library aware grounding, automated compilation with OpenModelica, and human in the loop evaluation. Experiments were carried out on four basic logic tasks (And, Or, Not, and Switch) and five control modules (chiller enable/disable, bypass valve control, cooling tower fan speed, plant requests, and relief damper control). The results showed that GPT 4o failed to produce executable Modelica code in zero shot mode, while Claude Sonnet 4 achieved up to full success for basic logic blocks with carefully engineered prompts. For control modules, success rates reached 83 percent, and failed outputs required medium level human repair (estimated one to eight hours). Retrieval augmented generation often produced mismatches in module selection (for example, And retrieved as Or), while a deterministic hard rule search strategy avoided these errors. Human evaluation also outperformed AI evaluation, since current LLMs cannot assess simulation results or validate behavioral correctness. Despite these limitations, the LLM assisted workflow reduced the average development time from 10 to 20 hours down to 4 to 6 hours per module, corresponding to 40 to 60 percent time savings. These results highlight both the potential and current limitations of LLM assisted Modelica generation, and point to future research in pre simulation validation, stronger grounding, and closed loop evaluation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。