Modelica test case generation method based on interaction enhancement

By generating test cases that conform to Modelica syntax through a large language model and interactive enhancement modules, the problems of low test case generation efficiency and insufficient coverage are solved, efficient automatic generation and wide coverage are achieved, and development costs are reduced.

CN120653549APending Publication Date: 2025-09-16ZHEJIANG UNIV +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510643093.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The existing technology of Modelica test case generation has low efficiency, insufficient coverage and lacks effectiveness.

Method used

An automated test case generation method based on a large language model is adopted, combined with an interactive enhancement module, to generate test cases that conform to Modelica syntax through prompt words. The generation process is iteratively optimized through simulation verification and feedback optimization.

Benefits of technology

It achieves efficient and automated generation of Modelica test cases, improves test efficiency and coverage during modeling and simulation, reduces development costs, and accelerates the iterative optimization process of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653549A_ABST
    Figure CN120653549A_ABST
Patent Text Reader

Abstract

The invention discloses a Modelica test case generation method based on interaction enhancement. The invention relates to the technical field of artificial intelligence and system testing. The method aims at generating the test case of the Modelica component model by adopting an automatic method. According to the method, a collected Modelica data set is used as training data to carry out fine tuning on an open source pre-training model. After fine tuning, the large language model can generate a Modelica test case, the input of the Modelica test case is a test cue word in a standard format, and the output of the Modelica test case is a test case following Modelica grammar. And the generated test case is input into the automatic interaction enhancement module for model verification and feedback optimization, so that the correctness and effectiveness of the test case are ensured. The Modelica test case is generated through the artificial intelligence content generation technology, the test efficiency and coverage rate of the modeling field are improved, model iteration is accelerated, and the development cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Claims

1. A Modelica test case generation method based on interaction enhancement, characterized in that: include: Collect the Modelica model library and decompose it into several models. Perform data preprocessing on the text of several models to form a Modelica fine-tuning dataset. Fine-tune the open-source large language model using the Modelica fine-tuning dataset; Analyze the Modelica model to design prompt words in the standard format corresponding to the Modelica model test; Generate Modelica test case text using the fine-tuned large language model according to the prompt words; Process the generated Modelica test case text, remove the descriptive text at the beginning and end, and only retain the model script of the test case to obtain a test case that complies with Modelica syntax; A Modelica tool that supports Modelica model compilation and simulation testing is selected, and the test case that complies with the Modelica syntax is input into an automated interaction enhancement module based on the Modelica tool. The test case is verified and optimized to obtain a final Modelica test case, wherein the automated interaction enhancement module first performs simulation verification on the Modelica test case that complies with the Modelica syntax. If an error is found during the verification process, the error information is returned to the large language model through an interactive feedback mechanism to guide it to regenerate a test case that meets the requirements. The feedback mechanism iteratively optimizes the test case generation process until the generated test case passes all verification steps.

2. The method according to claim 1, characterized in that Collect the Modelica model library and decompose it into several models. Perform data preprocessing on the text of several models to form a Modelica fine-tuning dataset, including: Collect diverse Modelica model libraries and decompose them into several models, and extract model texts from these models; The model text is preprocessed and organized into a standard dataset format to form a Modelica fine-tuning dataset.

3. The method according to claim 1, characterized in that Use the Modelica fine-tuning dataset to fine-tune the open source large language model, including: Select an open-source large language model as the base model; The fine-tuning hyperparameters are defined, and the base model is fine-tuned using the Modelica fine-tuning dataset.

4. The method according to claim 1, wherein Analyze the Modelica model to design prompt words in the standard format corresponding to the Modelica model test, including: Add the Modelica model to be tested and its description to the test prompt; Add the input and output parameter information required by the Modelica model to the test prompt; Arrange the test prompt words into a standard format.

5. The method according to claim 1, wherein The Modelica test cases that follow the Modelica syntax are simulated and verified. If errors are found during the verification process, the error information is fed back to the large language model through an interactive feedback mechanism to guide it to regenerate test cases that meet the requirements. The feedback mechanism iteratively optimizes the test case generation process until the generated test cases pass all verification steps, including: Performing load verification on the Modelica test cases that follow the Modelica syntax to ensure that the generated test cases have complete structures, correct module declarations, and basic syntax compliance; After the loading verification, the model checking phase is carried out to check the consistency and integrity of the model; If the model is correct, the simulation run verification phase is entered, where the test case is actually run by calling the Modelica simulation engine to detect possible problems during runtime. If the simulation is successfully completed, the test case will undergo logical function verification, which is to analyze the input and output behavior and calculation logic of the test case to determine whether it meets the expected behavior and functional requirements described in the prompt word; If the model encounters an error during any verification phase, the interactive feedback optimization mechanism will be automatically triggered. This mechanism extracts the error information and returns it to the fine-tuned large language model through structured interaction, guiding it to regenerate test cases based on the specific error.

6. A Modelica test case generation device based on interactive enhancement, characterized in that: include: The first generation module is used to collect the Modelica model library and decompose the model library into several models, perform data preprocessing on the text of several models, and form a Modelica fine-tuning dataset; An optimization module, configured to fine-tune the open source large language model using the Modelica fine-tuning dataset; The second generation module is used to analyze the Modelica model and design prompt words in a standard format corresponding to the Modelica model test; A third generation module is configured to generate a Modelica test case text based on the prompt word using the fine-tuned large language model; The post-processing module is used to process the generated Modelica test case text, remove the descriptive text at the beginning and end, and only retain the model script of the test case to obtain a test case that complies with the Modelica syntax; The interactive enhancement module is used to select a Modelica tool that supports Modelica model compilation and simulation testing, input the test case that complies with the Modelica syntax into the automated interactive enhancement module based on the Modelica tool, verify and optimize the test case, and obtain the final Modelica test case, wherein the automated interactive enhancement module first simulates and verifies the Modelica test case that complies with the Modelica syntax. If an error is found during the verification process, the error information is returned to the large language model through an interactive feedback mechanism to guide it to regenerate a test case that meets the requirements. The feedback mechanism iteratively optimizes the test case generation process until the generated test case passes all verification steps.

7. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Code verification method and device, electronic equipment and storage medium

    CN118260200A