Generating code from a natural language using Large Language Models (LLMs) such as ChatGPT, seems groundbreaking. Yet, with more extensive use, it's evident that this approach has its own limitations. The inherent ambiguity of natural language presents challenges for complex software designs. Accordingly, our research offers an Agile Model-Driven Development (MDD) approach that enhances code auto-generation using OpenAI's GPT-4. Our work emphasizes "Agility" as a significant contribution to the current MDD method, particularly when the model undergoes changes or needs deployment in a different programming language. Thus, we present a case-study showcasing a multi-agent simulation system of an Unmanned Vehicle Fleet. In the first and second layer of our approach, we constructed a textual representation of the case-study using Unified Model Language (UML) diagrams. In the next layer, we introduced two sets of constraints that minimize model ambiguity. Object Constraints Language (OCL) is applied to fine-tune the code constructions details, while FIPA ontology is used to shape communication semantics and protocols. Ultimately, leveraging GPT-4, our last layer auto-generates code in both Java and Python. The Java code is deployed within the JADE framework, while the Python code is deployed in PADE framework. Concluding our research, we engaged in a comprehensive evaluation of the generated code. From a behavioural standpoint, the auto-generated code aligned perfectly with the expected UML sequence diagram. Structurally, we compared the complexity of code derived from UML diagrams constrained solely by OCL to that influenced by both OCL and FIPA-ontology. Results indicate that ontology-constrained model produce inherently more intricate code, but it remains manageable and low-risk for further testing and maintenance.
翻译:使用ChatGPT等大型语言模型(LLMs)从自然语言生成代码看似具有开创性,但随着更广泛的应用,这种方法也暴露出其固有局限性。自然语言固有的歧义性给复杂软件设计带来了挑战。为此,我们的研究提出了一种利用OpenAI GPT-4增强代码自动生成的敏捷模型驱动开发方法。我们的工作强调"敏捷性"作为对当前模型驱动开发方法的重要贡献,特别是在模型发生变更或需要部署到不同编程语言时。因此,我们以无人车集群多智能体仿真系统为例进行案例研究。在方法的第一层和第二层,我们使用统一建模语言(UML)图构建了案例研究的文本化表征。在下一层,我们引入了两组约束条件以降低模型歧义性:采用对象约束语言对代码构造细节进行微调,并使用FIPA本体塑造通信语义与协议。最终,利用GPT-4在最后一层自动生成Java和Python代码:Java代码部署于JADE框架,Python代码部署于PADE框架。研究结束时,我们对生成的代码进行了全面评估:从行为视角看,自动生成的代码与预期的UML时序图完美契合;从结构视角看,我们比较了仅受对象约束语言约束的UML图与同时受对象约束语言和FIPA本体影响的代码复杂度。结果表明,经本体约束的模型会生成本质上更复杂的代码,但这类代码仍保持可控性且对后续测试维护具有低风险。