A simulation modeling method and system based on large model driving
By constructing a graph neural network topology injection layer through multi-turn dialogue parsing and an improved Llama-3 model, combined with template constraint filling and incremental updates, the shortcomings of existing simulation modeling methods in knowledge fusion and logical understanding are solved, achieving efficient and accurate simulation modeling and iterative updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NINGBO PATT COMPUTER SOFTWARE CO LTD
- Filing Date
- 2026-04-13
- Publication Date
- 2026-05-29
AI Technical Summary
Existing simulation modeling methods based on large language models have shortcomings in knowledge fusion, logical understanding and constraint control, resulting in inaccurate simulation results and difficulty in efficient iterative updates.
A simulation modeling approach is adopted, which employs multi-turn dialogue parsing, all-MiniLM-L6-v2 vector retrieval, improved Llama-3 model to construct graph neural topology injection layer, cross-modal gating fusion, template constraint filling and incremental local update, to achieve accurate entity information extraction, graph topology space reasoning and multi-level strict format constraints.
It improves the automation level of simulation modeling and the engineering usability of the generated results, ensures accurate domain knowledge retrieval, deep topological interaction logic, strong generation syntax standardization, and local modifications do not destroy the original structure, thereby improving the stability and efficiency of iterative modifications.
Smart Images

Figure CN122113664A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the interdisciplinary field of artificial intelligence and computer simulation, and in particular to a simulation modeling method and system based on large model-driven simulation. Background Technology
[0002] Existing simulation modeling methods based on large language models still face many technical bottlenecks in practical applications. In terms of knowledge fusion, existing technologies mostly rely on single natural language prompts for end-to-end generation, failing to effectively combine structured knowledge graphs with professional prior knowledge in multi-dimensional simulation databases. This leads to the model being prone to illusions when extracting complex simulation elements, and the generated entity attributes and interaction rules lacking engineering accuracy.
[0003] In terms of logical understanding and constraint control, traditional language models process text only in a linear sequence, making it difficult to capture the spatial topological relationships and directed interaction logic between simulated entities. Furthermore, the generation process lacks hard format constraints on the target simulation platform's data standards and specific language syntax specifications, which can easily lead to label nesting errors and code interface errors, resulting in output results that cannot be directly parsed and run by the simulation engine.
[0004] Furthermore, in the engineering iteration phase, most existing systems adopt a global regeneration response mechanism. When a user requests a local modification, it is impossible to perform precise incremental updates while preserving the original correct structure. This not only wastes computing power but also destroys previously verified code logic, making it difficult to adapt to the high-frequency, fine-grained model debugging and evolution requirements in real simulation scenarios.
[0005] Therefore, how to provide a simulation modeling method and system based on large model-driven approaches is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] One objective of this invention is to propose a simulation modeling method and system based on a large model. This invention fully integrates key steps such as multi-turn dialogue parsing, all-MiniLM-L6-v2 vector retrieval, an improved Llama-3 model for constructing a graph neural topology injection layer, cross-modal gating fusion, template constraint filling, and incremental local updates. It constructs an automated simulation model generation process with accurate entity information extraction, graph topology space reasoning, strict multi-level format constraints, and dynamically controllable modification responses. This achieves intelligent conversion and efficient iteration from natural language to executable simulation code in complex interactive scenarios. This invention possesses advantages such as high accuracy in domain knowledge retrieval, deep topological interaction logic reasoning, strong standardization of generation syntax, and local modifications that do not destroy the original structure. It can significantly improve the automation level of simulation modeling and the engineering usability of the generated results, thereby effectively solving problems in existing methods such as insufficient utilization of domain knowledge, superficial understanding of entity interaction logic, error-prone generated file syntax, and model instability caused by global regeneration.
[0007] A simulation modeling method based on a large model driven by an embodiment of the present invention includes the following steps:
[0008] S1. Receive and parse the natural language simulation requirements input by the user, identify the task type, domain category, entity type and attribute parameter information. If the information is incomplete, guide the user to gradually complete it, construct and output the dialogue state information.
[0009] S2. Using all-MiniLM-L6-v2, the user-input natural language simulation requirements are segmented and pooled to calculate the numerical vector corresponding to the text. Spatial distance is calculated by traversing the structured knowledge graph and multi-dimensional simulation database. Knowledge graph nodes and historical simulation model files are recalled and output as supplementary information for domain knowledge.
[0010] S3. The improved Llama-3 model is used to process domain knowledge supplementary information and dialogue state information. A graph neural topology injection layer is constructed. When processing entity and interaction rule subtasks, entity relationship graphs are constructed in parallel for message passing and topology features are extracted. The topology features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one, and integrating them into structured intermediate results and outputting them.
[0011] S4. Parse the structured intermediate results. For the simulation scene file generation requirements, select the XML Schema rule template corresponding to the target simulation platform data standard. For the simulation model generation requirements, select the code template corresponding to the specific simulation language syntax specification. Output the XML Schema rule template and the code template.
[0012] S5. Map the structured intermediate results to the corresponding level positions of the XML Schema rule template to generate format constraints, output the scene data file, fill the entity attributes into the class initialization method of the code template, fill the event logic into the event handling function, fill the interaction rules into the inter-entity communication code, and output the scene data file and executable simulation model code.
[0013] S6. When a user requests modifications to the generated results, repeat steps S1 to S5. Based on the original structured intermediate results, only the modified parts are regenerated and mapped, and the updated scene data file and updated executable simulation model code are output.
[0014] Optionally, S1 specifically includes:
[0015] S11. Receive the natural language simulation requirements input by the user through the interactive interface, segment them according to spaces and punctuation marks, and compare the segmented word groups with the pre-built simulation professional lexicon in turn. If the comparison is consistent, mark the category label of the corresponding word group. After traversing all word groups, summarize the task type, domain category, entity type and attribute parameter information with category labels.
[0016] S12. Extract all phrases under each category label in the simulation professional thesaurus, count them for deduplication, and use the deduplication count result as the total number of elements in the corresponding category. Subtract the number of phrases under each category label from the total number of elements in the corresponding category. If the difference is greater than zero, the information is determined to be incomplete.
[0017] S13. If the information is incomplete, extract the unmatched word groups corresponding to the category labels with a difference greater than zero from the simulation professional lexicon as the missing information to be supplemented, take the successfully matched word groups as the confirmed simulation elements, and concatenate the confirmed simulation elements and the missing information to be supplemented into a question according to the subject-verb-object grammar rules. Display the question as a follow-up question through the interactive interface.
[0018] S14. Receive supplementary text input by the user in response to follow-up questions through the interactive interface, concatenate the supplementary text to the end of the natural language simulation requirements, and re-perform the segmentation, matching and subtraction calculation operations on the concatenated text. Repeat the process until the difference between the corresponding labels of each category is equal to zero.
[0019] S15. When the difference between the labels of each category is equal to zero, the concatenated text from each round is joined together with a newline character in the order of input time to form a long text string, which is then assigned to a memory array variable for storage, and the dialogue status information is output.
[0020] Optionally, S2 specifically includes:
[0021] S21. Divide the natural language simulation requirements input by the user into word sequences according to word boundaries, map each word to an index number, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, use each index number as a row number, and replace the entire row value corresponding to the row number in the zero matrix with a vector generated by normally distributed random numbers.
[0022] S22. Add the sine and cosine function values generated by the replacement row of values and the corresponding word values in the natural language simulation requirements in ascending order of position to generate a word vector sequence. Insert a zero vector at the beginning of the word vector sequence as a special classification vector.
[0023] S23. Input the word vector sequence containing special classification vectors into the twelve-layer multi-head self-attention network of the all-MiniLM-L6-v2 model. In each layer, multiply the word vector sequence by three different randomly initialized weight matrices to generate a query matrix, a key matrix, and a value matrix. Multiply the query matrix by the transpose of the key matrix and divide by the square root of the dimension. Obtain the attention weights through exponential operation and normalization. Multiply the attention weights by the value matrix to output a context-related feature vector that incorporates contextual information.
[0024] S24. Input the context association feature vector output by the twelfth layer network into the average pooling layer unique to the all-MiniLM-L6-v2 model, remove the first and last zero vectors, sum all the remaining context association feature vectors in the sequence length dimension, divide the sum by the number of remaining vectors to calculate the arithmetic mean, and use the calculated arithmetic mean as the numerical vector.
[0025] S25. Collect historical simulation requirement texts and corresponding historical simulation model codes, extract entity names from historical simulation requirement texts, extract target variable names from variable assignment statements in historical simulation model codes, use entity names and target variable names as nodes, draw lines between nodes extracted from the same text and code to generate edges, and construct a structured knowledge graph.
[0026] S26. Traverse all nodes in the structured knowledge graph and all files stored in the multi-dimensional simulation database, extract node numerical vectors and historical simulation model file numerical vectors, calculate the cosine similarity score, and output supplementary domain knowledge information.
[0027] Optionally, S26 specifically includes:
[0028] S261. Traverse all nodes in the structured knowledge graph, extract the text of the entity name and the corresponding target variable name stored in each node and combine them into node text, and convert the node text into node value vectors according to the operations in S21 to S24.
[0029] S262. Simultaneously traverse all files stored in the multi-dimensional simulation database, locate the text area of the first five lines inside each historical simulation model file, read the characters in the text area line by line and filter out the character lines containing equal signs and variable data types as variable definition text, and convert the filtered variable definition text into historical simulation model file numerical vectors according to the operations of S21 to S24.
[0030] S263. Take the numerical vector corresponding to the natural language simulation requirement as the numerator, and take the numerical vector of each node and the numerical vector of each historical simulation model file as the denominator. Calculate the inner product by multiplying the elements at corresponding positions in the numerator and denominator, and sum them. Add the squares of all elements in the numerator vector and the denominator vector respectively and take the square root to find the modulus. Divide the inner product by the product of the two moduli to obtain the cosine similarity score.
[0031] S264. Subtract all calculated cosine similarity scores from the preset similarity threshold in sequence, filter out the cosine similarity scores with a subtraction result greater than zero, extract the entity name and attribute description text from the knowledge graph node corresponding to the selected cosine similarity score, as well as the variable definition text from the historical simulation model file, and concatenate the extracted text in order to form domain knowledge supplementary information and output it.
[0032] Optionally, S3 specifically includes:
[0033] S31. Connect the domain knowledge supplementary information and the dialogue status information into a long text string using a newline character. Add instruction characters to the beginning of the long text string to guide the extraction of task type and attributes and construct prompt words. Segment the prompt words according to periods. Rearrange each segmented independent sentence according to causal logic and chronological order to generate a subtask sequence.
[0034] S32. Input the subtask sequence into the improved Llama-3 model. When a sentence containing both entity names and interaction rule descriptions is read from the subtask sequence, extract the entity names from the sentence as graph nodes, extract the action executor and action receiver from the interaction rule description as start and end points, draw directed line segments to generate directed edges, construct an all-zero adjacency matrix with graph nodes as row indices and directed edges as column indices, replace the values at the positions where there are directed line segments connected with zeros to one, and construct an entity relationship graph.
[0035] S33. Construct a graph neural topology injection layer. Input the entity relationship graph into the graph neural topology injection layer. Create an all-zero vector with a dimension equal to a set value for each graph node in the entity relationship graph as the initial feature vector. For each graph node, find the column index with a value of one in the corresponding row of the graph node in the all-zero adjacency matrix, and extract the initial feature vector of the graph node corresponding to the column index.
[0036] S34. Add the initial feature vector to the initial feature vector of the current graph node element by element and input it into the fully connected layer for linear transformation and nonlinear mapping to obtain the updated feature vector and replace the initial feature vector in the current graph node. Repeat the above table lookup, addition, linear transformation and nonlinear mapping operations until the feature vectors of all graph nodes stop changing. Extract the final set of feature vectors of all graph nodes as topological features.
[0037] S35. Read the current subtask from the ordered subtask sequence inside the improved Llama-3 model, divide it into a character sequence, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, replace the row number of each character arrangement as a normal distribution random number vector, and add the sine and cosine function values of the character position element by element to generate a word vector sequence.
[0038] S36. Input the word vector sequence into multiple self-attention layers, multiply it by the query weight matrix, key weight matrix and value weight matrix in sequence, multiply the query matrix and key matrix by transpose and divide by the square root of the dimension, obtain the attention weight through exponential operation and normalization calculation, multiply it by the value matrix and iterate, and use the multidimensional array output by the last layer as the hidden layer vector of the language model.
[0039] S37. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and use the hidden layer vectors of the language model to gradually combine all the subtasks to generate JSON format fragments, obtain structured intermediate results and output them.
[0040] Optionally, S37 specifically includes:
[0041] S371. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and perform element-wise multiplication at the corresponding position on the feature vector of each graph node in the topological features and the hidden layer vector of the language model corresponding to the subtask currently being processed by the improved Llama-3 model to generate a gating weight vector.
[0042] S372. Multiply each element in the gate weight vector by the corresponding element in the language model hidden layer vector, and add it to the original value in the corresponding position of the language model hidden layer vector. Replace the original value in the language model hidden layer vector with the new value obtained after addition, and complete the topological feature fusion back to the language model hidden layer.
[0043] S373. The improved Llama-3 model processes subtasks sequentially. For each subtask, the fused language model hidden layer vector is input to the linear mapping layer and converted into a probability distribution of vocabulary size. The maximum number of predefined words in the probability distribution are extracted as predicted words. The predicted words are used as keys in key-value pairs, and the entity names and values extracted from the subtasks are used as values in key-value pairs. The keys and values are combined into JSON format fragments according to the JSON syntax format of curly braces and colons.
[0044] S374. Connect all the JSON format fragments generated by the subtasks in the order of the subtask sequence with commas, wrap the concatenated string in outer curly braces, generate a structured intermediate result and output it.
[0045] Optionally, S4 specifically includes:
[0046] S41. Read the overview information field in the structured intermediate results, extract the target simulation platform name string contained in the overview information, compare the target simulation platform name string with the software name in the data format specification documents of multiple simulation platforms that have been collected in advance, filter out the specification documents with the same software name, divide the specification documents into independent label rows according to the angle bracket symbol, and extract the string in the angle bracket of each label row as the data label.
[0047] S42. Count the number of indentation spaces in each tag line, divide it by the preset number of spaces corresponding to a single level to calculate the quotient value, and use it as the nesting depth value. Arrange the data tags in the parent-child nesting relationship according to the line order. Extract the string to the left of the equal sign in the tag line as the attribute name and extract the string to the right of the equal sign as the attribute constraint rule. Concatenate the parent-child nesting relationship, attribute name and attribute constraint rule in the line order and write them into a newly created text file to build an XMLSchema rule template for output.
[0048] S43. Read the task information field in the structured intermediate result, extract the specific simulation language name string contained in the task information, compare the specific simulation language name string with the language declaration keywords in the first line of multiple open source simulation project files of different languages downloaded from the open source code hosting platform, filter out the open source simulation project files with consistent language declaration keywords, extract the empty class definition shells and empty function definition shells in the open source simulation project files and construct them into code templates for output.
[0049] Optionally, S5 specifically includes:
[0050] S51. The overview information, entity information and task information fields in the structured intermediate results are compared with the tag lines containing attribute names in the XMLSchema rule template. When the attribute name in the tag line matches the field name, the text content corresponding to the field is extracted and the placeholder corresponding to the attribute constraint rule in the tag line is replaced. The XML Schema rule template after all placeholders have been replaced is saved as a text file with the suffix .xml and the scene data file is output.
[0051] S52. Locate the empty class definition shell in the code template that starts with the class keyword and ends with a colon. Extract the entity attributes from the entity information field in the structured intermediate result. Concatenate the entity attributes with the initial value according to the assignment equals sign to form a variable assignment statement. Copy and paste it into the indented area inside the empty class definition shell to complete filling the entity attributes into the class initialization method of the code template.
[0052] S53. Locate the event handling function whose function name contains the character "event" in the code template, extract the event logic from the task information field in the structured intermediate result, convert the event logic into a line of code containing conditional judgment syntax and paste it between the opening and closing curly braces of the event handling function to complete filling the event logic into the event handling function;
[0053] S54. Locate the function whose name contains the character for communication in the code template, extract the interaction rules from the entity information field in the structured intermediate results, decompose the interaction rules into sender, receiver and data content, and fill them into the variable assignment statements inside the communication function respectively. Complete the filling of the interaction rules into the inter-entity communication code, save the filled code template as a text file with the corresponding language suffix, and output the executable simulation model code.
[0054] Optionally, S6 specifically includes:
[0055] S61. Receive the modified text of the scene data file and executable simulation model code output by the user through the interactive interface, and concatenate the modified text with the original dialogue state information in the memory array variable through a newline character to form a long text string.
[0056] S62. Extract the structured intermediate results generated in the memory array variable, concatenate the structured intermediate results with the long text string as the input context, and locate the target field that has undergone numerical or logical changes from the modified text.
[0057] S63. Retain the unchanged field content in the structured intermediate result, and only re-execute the string extraction and key-value pair combination operation on the target field to generate a partially updated structured intermediate result that overwrites and replaces the original structured intermediate result.
[0058] S64. After the partial update of the structured intermediate results, select the XML Schema rule template and code template again according to the string comparison and hierarchical arrangement operation. According to the placeholder replacement and code line pasting operation, only perform regeneration and mapping filling for the tag line and function code corresponding to the target field. Obtain the updated scene data file and the updated executable simulation model code and output them.
[0059] A simulation modeling system based on a large model driven by an embodiment of the present invention includes:
[0060] The requirement parsing and interactive completion module is used to receive and parse the natural language simulation requirements input by the user, identify the task type, domain category, entity type and attribute parameter information, and guide the user to progressively complete the information if the information is incomplete, construct and output the dialogue state information.
[0061] The domain knowledge retrieval module is used to perform word segmentation and pooling mapping operations on the natural language simulation requirements input by the user through all-MiniLM-L6-v2, calculate the numerical vector corresponding to the text, traverse and calculate the spatial distance in the structured knowledge graph and multi-dimensional simulation database, recall knowledge graph nodes and historical simulation model files and output them as supplementary information of domain knowledge.
[0062] The graph neural topology enhancement parsing module uses an improved Llama-3 model to process domain knowledge supplementary information and dialogue state information, constructs a graph neural topology injection layer, and constructs entity relationship graphs in parallel to perform message passing and extract topological features when processing entity and interaction rule subtasks. The topological features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one, and integrating them into structured intermediate results for output.
[0063] The template matching and selection module is used to parse structured intermediate results. For simulation scene file generation requirements, it selects the XML Schema rule template corresponding to the target simulation platform data standard. For simulation model generation requirements, it selects the code template corresponding to the specific simulation language syntax specification and outputs the XML Schema rule template and code template.
[0064] The structured mapping and filling module is used to map and fill the structured intermediate results to the corresponding level positions of the XML Schema rule template to generate format constraints, output the scene data file, fill the entity attributes into the class initialization method of the code template, fill the event logic into the event handling function, fill the interaction rules into the inter-entity communication code, and output the scene data file and executable simulation model code.
[0065] The incremental modification feedback module is used to repeatedly execute the requirement parsing and interactive completion module to the structured mapping and filling module when it receives a user's modification request for the generated results. Based on the original structured intermediate results, it regenerates and maps only the modified parts, and outputs the updated scene data file and the updated executable simulation model code.
[0066] The beneficial effects of this invention are:
[0067] This invention addresses the issues of ambiguity and missing elements in user natural language requirements by deploying an interactive dialogue parsing mechanism and constructing a simulation-specific lexicon. It employs difference comparison calculation to determine information completeness, combined with multi-round follow-up questions to guide the generation of dialogue state information, achieving precise completion and structured unification of simulation requirements. Through dialogue state information and the all-MiniLM-L6-v2 model, it performs word segmentation, pooling mapping, and cosine similarity traversal calculations on a structured knowledge graph and a multi-dimensional simulation database, accurately recalling associated historical nodes and model files, and outputting supplementary domain knowledge information to compensate for the shortcomings of private domain knowledge in large models. Utilizing an improved Llama-3 model, it constructs a graph neural topology injection layer. Addressing the issue of superficial understanding of entity interaction logic, it extracts topological features through parallel construction of entity relationship graphs and message passing, and integrates these features back into the language model's hidden layer using a cross-modal gating mechanism, generating structured intermediate results sequentially, achieving deep collaborative reasoning between spatial topology and textual semantics. Furthermore, it utilizes XML... The schema rule template and code template matching mechanism performs placeholder replacement, class initialization, and precise event function filling, outputting an executable file that conforms to the syntax specifications. During the model iteration phase, combined with an incremental modification feedback mechanism, only changed fields in the structured intermediate results are regenerated and mapped for localization. Ultimately, this achieves a closed-loop intelligent construction from natural language description to executable simulation scenarios and model code, effectively improving the depth of domain knowledge fusion, the accuracy of entity interaction reasoning, the syntactic standardization of generated code, and the stability of local iterative modifications. Attached Figure Description
[0068] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0069] Figure 1 This is a flowchart of a simulation modeling method based on a large model driven by the present invention;
[0070] Figure 2 This is a structural diagram of a simulation modeling system based on a large model driven by the present invention.
[0071] Figure 3 This is a flowchart of the structured parsing and output process of the improved Llama-3 model based on graph neural topology injection layer and cross-modal gating mechanism proposed in this invention. Detailed Implementation
[0072] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0073] refer to Figures 1-3A simulation modeling method based on a large model-driven approach includes the following steps:
[0074] S1. Receive and parse the natural language simulation requirements input by the user through the interactive interface, identify the task type, domain category, entity type and attribute parameter information, and judge the completeness of the information. If the information is incomplete, generate follow-up questions by combining the confirmed simulation elements and the missing information to be supplemented, guide the user to gradually complete the information through multiple rounds of dialogue, build and maintain complete dialogue state information, and output the dialogue state information.
[0075] S2. Using all-MiniLM-L6-v2, the user's input natural language simulation requirements are segmented and pooled to calculate the numerical vector corresponding to the text. Spatial distance is calculated by traversing the structured knowledge graph and multi-dimensional simulation database. Knowledge graph nodes and historical simulation model files with similarity scores higher than the preset threshold are recalled and output as supplementary information of domain knowledge.
[0076] S3. The improved Llama-3 model is used to process domain knowledge supplementary information and dialogue state information. A graph neural topology injection layer is constructed. When processing entity and interaction rule subtasks, entity relationship graphs are constructed in parallel for message passing to extract topological features. The topological features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one. The fragments are then integrated into a structured intermediate result containing overview information, entity information, state definition and task information and output.
[0077] S4. Parse the structured intermediate results. For the simulation scene file generation requirements, select the XML Schema rule template corresponding to the target simulation platform data standard. For the simulation model generation requirements, select the code template corresponding to the specific simulation language syntax specification. Output the XML Schema rule template and the code template.
[0078] S5. Map and fill the overview information, entity information, and task information fields in the structured intermediate results to the corresponding level positions in the XMLSchema rule template to generate format constraints, output a scene data file that conforms to the syntax specification, and at the same time use code completion to fill entity attributes into the class initialization method of the code template, fill event logic into the event handling function, fill interaction rules into the inter-entity communication code, and output a scene data file that conforms to the syntax specification and complete executable simulation model code;
[0079] S6. When a user requests modification to the generated result, S1 to S5 are repeated using the original dialogue state information and the previously generated structured intermediate result as context. The large language model regenerates and maps only the modified part based on the original structured intermediate result, obtains the updated scene data file and the updated executable simulation model code, and outputs them.
[0080] This implementation significantly improves the accuracy of simulation modeling and the standardization of code generation. Through multi-turn dialogue guidance and a progressive information completion mechanism, it achieves accurate understanding and structured transformation of fuzzy natural language requirements, effectively eliminating ambiguity and element omissions caused by manual parsing. In the knowledge processing stage, combining all-MiniLM-L6-v2 vector mapping and spatial distance traversal, it accurately recalls highly similar historical nodes and model files, compensating for the knowledge gaps of large models in specialized fields. For complex interaction logic, it utilizes an improved Llama-3 model to construct a graph neural network topology injection layer and a cross-modal gating mechanism, deeply fusing entity spatial topological features into the hidden layer. This completely solves the problem of the superficial understanding of multi-node interaction relationships in pure text models, achieving high-quality generation of structured intermediate results. Furthermore, through precise mapping and filling of rule and code dual templates, it ensures that the output scene data and model code fully comply with the target platform's syntax specifications, significantly reducing the syntax error rate. Based on the local update feedback mechanism, when faced with changes in requirements, only the modified parts are regenerated and filled, avoiding the logical collapse caused by global rewriting, significantly improving the stability and efficiency of iterative modifications, and ultimately achieving a closed-loop efficient construction from natural language to executable simulation files.
[0081] In this embodiment, S1 specifically includes:
[0082] S11. Receive the natural language simulation requirements input by the user through the interactive interface, segment them according to spaces and punctuation marks, and compare the segmented word groups with the pre-built simulation professional lexicon in turn. If the comparison is consistent, mark the category label of the corresponding word group. After traversing all word groups, summarize the task type, domain category, entity type and attribute parameter information with category labels.
[0083] S12. Extract all phrases under each category label in the simulation professional thesaurus, count them for deduplication, and use the deduplication count result as the total number of elements in the corresponding category. Subtract the number of phrases under each category label from the total number of elements in the corresponding category. If the difference is greater than zero, the information is determined to be incomplete.
[0084] S13. If the information is incomplete, extract the unmatched word groups corresponding to the category labels with a difference greater than zero from the simulation professional lexicon as the missing information to be supplemented, take the successfully matched word groups as the confirmed simulation elements, and concatenate the confirmed simulation elements and the missing information to be supplemented into a question according to the subject-verb-object grammar rules. Display the question as a follow-up question through the interactive interface.
[0085] S14. Receive supplementary text input by the user in response to follow-up questions through the interactive interface, concatenate the supplementary text to the end of the natural language simulation requirements, and re-perform the segmentation, matching and subtraction calculation operations on the concatenated text. Repeat the process until the difference between the corresponding labels of each category is equal to zero.
[0086] S15. When the difference between the labels of each category is equal to zero, the concatenated text of each round is joined into a long text string by newline characters in the order of input time, and the string is assigned to a memory array variable for storage. The dialogue status information in the memory array variable is then output.
[0087] In this embodiment, S2 specifically includes:
[0088] S21. Divide the natural language simulation requirements input by the user into word sequences according to word boundaries, map each word to an index number, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, use each index number as a row number, and replace the entire row value corresponding to the row number in the zero matrix with a vector generated by normally distributed random numbers.
[0089] S22. Add the sine and cosine function values generated by the replacement row of values and the corresponding word values in the natural language simulation requirements in ascending order of position to generate a word vector sequence. Insert a zero vector at the beginning of the word vector sequence as a special classification vector.
[0090] S23. Input the word vector sequence containing special classification vectors into the twelve-layer multi-head self-attention network of the all-MiniLM-L6-v2 model. In each layer, multiply the word vector sequence by three different randomly initialized weight matrices to generate a query matrix, a key matrix, and a value matrix. Multiply the query matrix by the transpose of the key matrix and divide by the square root of the dimension. Obtain the attention weights through exponential operation and normalization. Multiply the attention weights by the value matrix to output a context-related feature vector that incorporates contextual information.
[0091] S24. Input the context association feature vector output by the twelfth layer network into the average pooling layer unique to the all-MiniLM-L6-v2 model, remove the first and last zero vectors, sum all the remaining context association feature vectors in the sequence length dimension, divide the sum by the number of remaining vectors to calculate the arithmetic mean, and use the calculated arithmetic mean as a numerical vector with unchanged length.
[0092] S25. Collect historical simulation requirement texts and corresponding historical simulation model codes, extract entity names from historical simulation requirement texts, extract target variable names from variable assignment statements in historical simulation model codes, use entity names and target variable names as nodes, draw lines between nodes extracted from the same text and code to generate edges, and construct a structured knowledge graph.
[0093] S26. Traverse all nodes in the structured knowledge graph and all files stored in the multi-dimensional simulation database, extract node numerical vectors and historical simulation model file numerical vectors, calculate the cosine similarity score, and output supplementary domain knowledge information.
[0094] In this embodiment, S26 specifically includes:
[0095] S261. Traverse all nodes in the structured knowledge graph, extract the text of the entity name and the corresponding target variable name stored in each node and combine them into node text, and convert the node text into node value vectors according to the operations in S21 to S24.
[0096] S262. Simultaneously traverse all files stored in the multi-dimensional simulation database, locate the text area of the first five lines inside each historical simulation model file, read the characters in the text area line by line and filter out the character lines containing equal signs and variable data types as variable definition text, and convert the filtered variable definition text into historical simulation model file numerical vectors according to the operations of S21 to S24.
[0097] S263. Take the numerical vector corresponding to the natural language simulation requirement as the numerator, and take the numerical vector of each node and the numerical vector of each historical simulation model file as the denominator. Calculate the inner product by multiplying the elements at corresponding positions in the numerator and denominator, and sum them. Add the squares of all elements in the numerator vector and the denominator vector respectively and take the square root to find the modulus. Divide the inner product by the product of the two moduli to obtain the cosine similarity score.
[0098] S264. Subtract all calculated cosine similarity scores from a preset similarity threshold in sequence, filter out cosine similarity scores with a subtraction result greater than zero, extract entity names and attribute description text from the knowledge graph nodes corresponding to the filtered cosine similarity scores, as well as variable definition text from the historical simulation model files, and concatenate the extracted text in sequence to form domain knowledge supplementary information and output it. The preset similarity threshold is 0.75.
[0099] This implementation introduces the all-MiniLM-L6-v2 model as the core text representation technology, which has significant differences and advantages compared to traditional feature extraction models such as TF-IDF, Word2Vec, and BERT. Traditional TF-IDF and Word2Vec rely solely on word frequency or static co-occurrence, completely lacking context awareness, and cannot generate fixed vectors of uniform dimensions for accurate cosine calculation; although standard BERT has dynamic semantic understanding capabilities, its large number of parameters leads to huge computational resource consumption and inference latency bottlenecks when handling massive historical knowledge graph traversal and high-concurrency retrieval.
[0100] This invention utilizes the twelve-layer multi-head self-attention mechanism of the all-MiniLM-L6-v2 model to achieve accurate capture of the deep semantics of the target text while maintaining an extremely low parameter count. In particular, the average pooling operation used in S24 directly compresses variable-length sequences into fixed-length numerical vectors, completely resolving the problem of similarity calculation failure caused by inconsistent vector dimensions in traditional methods. This mechanism can accurately extract the core features of natural language requirements even under complex technical terminology interference. Combined with the rigorous cosine similarity spatial distance calculation and 0.75 threshold filtering in S263, it significantly reduces retrieval computation costs and improves traversal speed while significantly enhancing the accuracy and robustness of recalling high-value domain knowledge from massive graphs and databases, laying a solid knowledge foundation for the accurate generation of code for subsequent large-scale models.
[0101] In this embodiment, S3 specifically includes:
[0102] S31. Connect the domain knowledge supplementary information and the dialogue status information into a long text string using a newline character. Add instruction characters to the beginning of the long text string to guide the extraction of task type and attributes and construct prompt words. Segment the prompt words according to periods. Rearrange each segmented independent sentence according to causal logic and chronological order to generate a subtask sequence.
[0103] S32. Input the subtask sequence into the improved Llama-3 model. When a sentence containing both entity names and interaction rule descriptions is read from the subtask sequence, extract the entity names from the sentence as graph nodes, extract the action executor and action receiver from the interaction rule description as start and end points, draw directed line segments to generate directed edges, construct an all-zero adjacency matrix with graph nodes as row indices and directed edges as column indices, replace the values at the positions where there are directed line segments connected with zeros to one, and construct an entity relationship graph.
[0104] S33. Construct a graph neural topology injection layer. Input the entity relationship graph into the graph neural topology injection layer. Create an all-zero vector with a dimension equal to a set value for each graph node in the entity relationship graph as the initial feature vector. For each graph node, find the column index with a value of one in the corresponding row of the graph node in the all-zero adjacency matrix, and extract the initial feature vector of the graph node corresponding to the column index.
[0105] S34. Add the initial feature vector to the initial feature vector of the current graph node element by element and input it into the fully connected layer for linear transformation and nonlinear mapping to obtain the updated feature vector and replace the initial feature vector in the current graph node. Repeat the above table lookup, addition, linear transformation and nonlinear mapping operations until the feature vectors of all graph nodes stop changing. Extract the final set of feature vectors of all graph nodes as topological features.
[0106] S35. Read the current subtask from the ordered subtask sequence inside the improved Llama-3 model, divide it into a character sequence, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, replace the row number of each character arrangement as a normal distribution random number vector, and add the sine and cosine function values of the character position element by element to generate a word vector sequence.
[0107] S36. Input the word vector sequence into multiple self-attention layers, multiply it by the query weight matrix, key weight matrix and value weight matrix in sequence, multiply the query matrix and key matrix by transpose and divide by the square root of the dimension, obtain the attention weight through exponential operation and normalization calculation, multiply it by the value matrix and iterate, and use the multidimensional array output by the last layer as the hidden layer vector of the language model.
[0108] S37. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and use the hidden layer vectors of the language model to gradually combine all the subtasks to generate JSON format fragments, obtain structured intermediate results and output them.
[0109] In this embodiment, S37 specifically includes:
[0110] S371. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and perform element-wise multiplication at the corresponding position on the feature vector of each graph node in the topological features and the hidden layer vector of the language model corresponding to the subtask currently being processed by the improved Llama-3 model to generate a gating weight vector.
[0111] S372. Multiply each element in the gate weight vector by the corresponding element in the language model hidden layer vector, and add it to the original value in the corresponding position of the language model hidden layer vector. Replace the original value in the language model hidden layer vector with the new value obtained after addition, and complete the topological feature fusion back to the language model hidden layer.
[0112] S373. The improved Llama-3 model processes subtasks sequentially. For each subtask, the fused language model hidden layer vector is input to a linear mapping layer to convert it into a probability distribution of vocabulary size. The maximum number of pre-defined words in the probability distribution are extracted as predicted words. The predicted words are used as keys in key-value pairs, and the entity names and values extracted from the subtasks are used as values in key-value pairs. The keys and values are combined into JSON format fragments according to the JSON syntax format of curly braces and colons. The pre-defined number of words is four.
[0113] S374. Connect all the JSON format fragments generated by the subtasks in the order of the subtask sequence with commas. Wrap the concatenated string in curly braces containing four top-level keys: overview information, entity information, status definition, and task information. Generate a structured intermediate result and output it.
[0114] This invention achieves accurate conversion from natural language requirements to structured JSON by introducing an improved Llama-3 model combined with graph neural topology injection and cross-modal gating mechanisms. Supplementary knowledge and state information are reorganized into a sequence of subtasks. An entity relationship graph containing an adjacency matrix is constructed by extracting entities and action executors. A graph neural topology injection layer is used to perform cyclic lookups and nonlinear mappings on graph nodes, extracting convergent topological feature vectors. Addressing the issue of pure language models' superficial understanding of complex spatial interactions, a cross-modal gating mechanism is used to weight topological features element-wise and fuse residuals into the hidden layer, deeply constraining the direction of semantic generation. The model outputs key-value pair fragments sequentially and concatenates them hierarchically, effectively avoiding errors in multi-node interaction logic and field omissions, significantly improving the accuracy and robustness of structured parsing of complex simulation models.
[0115] The improved Llama-3 model of this invention is similar to the original Llama-3 model in that both retain the core architecture of the autoregressive language model, which is to segment the input text into a character sequence and map it into word vectors containing positional encoding. Then, multiple self-attention layers are input, and attention weights are calculated by multiplying them by query, key, and value weight matrices in turn to complete the iterative extraction of contextual information. Finally, both output the probability distribution of the vocabulary dimension through a linear mapping layer to predict word units.
[0116] The difference lies in that this invention breaks through the limitation of the original Llama-3 model, which relies solely on one-dimensional text sequences for self-attention computation. It introduces a graph neural topology injection layer and a cross-modal gating mechanism to construct a "graph-text" dual-modal feature fusion system. Building upon the original model's direct iterative self-attention processing of word vector sequences, this invention pre-constructs an entity relationship graph in step S32, transforming the extracted entities and interaction rules into a directed graph containing an adjacency matrix. Then, in steps S33 and S34, the graph neural topology injection layer performs iterative lookups and non-linear mappings on the graph nodes until feature convergence, extracting topological features expressing spatial relationships. Subsequently, in steps S371 and S372, the topological features are element-wise multiplied with the language model's hidden layer vectors to generate gating weights, and the topological features are precisely injected back into the hidden layer using residual connections, rather than through direct concatenation or simple addition.
[0117] Based on the above improvements, the beneficial effects of this invention are that, through topology injection and gating fusion, the improved Llama-3 model can adaptively and deeply integrate the spatial directed connections between entities into the text generation process for complex simulation interaction rules. This breaks through the limitations of the original model's superficial understanding of multi-node interaction logic and its susceptibility to illusions, and realizes spatial topological constraints in the semantic generation process. This design significantly enhances the model's analytical depth of complex entity dependencies in simulation tasks, enabling more accurate output of logically consistent JSON format fragments. Graph structure features, as prior knowledge, intervene in the generation process, improving the accuracy of structured intermediate results while effectively reducing the probability of generating invalid and redundant code, thus enhancing the system's robustness and compliance with standards when handling large-scale complex simulation modeling tasks.
[0118] In this embodiment, S4 specifically includes:
[0119] S41. Read the overview information field in the structured intermediate results, extract the target simulation platform name string contained in the overview information, compare the target simulation platform name string with the software name in the data format specification documents of multiple simulation platforms that have been collected in advance, filter out the specification documents with the same software name, divide the specification documents into independent label rows according to the angle bracket symbol, and extract the string in the angle bracket of each label row as the data label.
[0120] S42. Count the number of indentation spaces in each tag line, divide it by the preset number of spaces corresponding to a single level to calculate the quotient value, and use it as the nesting depth value. Arrange the data tags in a parent-child nesting relationship according to the line order. Extract the string to the left of the equal sign in the tag line as the attribute name, and extract the string to the right of the equal sign as the attribute constraint rule. Concatenate the parent-child nesting relationship, attribute name and attribute constraint rule in line order and write them into a newly created text file to construct an XMLSchema rule template for output. The preset number of spaces corresponding to a single level is 2.
[0121] S43. Read the task information field in the structured intermediate result, extract the specific simulation language name string contained in the task information, compare the specific simulation language name string with the language declaration keywords in the first line of multiple open source simulation project files of different languages downloaded from the open source code hosting platform, filter out the open source simulation project files with consistent language declaration keywords, extract the empty class definition shells and empty function definition shells in the open source simulation project files and construct them into code templates for output.
[0122] In this embodiment, S5 specifically includes:
[0123] S51. The overview information, entity information and task information fields in the structured intermediate results are compared with the tag lines containing attribute names in the XMLSchema rule template. When the attribute name in the tag line matches the field name, the text content corresponding to the field is extracted and the placeholder corresponding to the attribute constraint rule in the tag line is replaced. The XML Schema rule template after all placeholders have been replaced is saved as a text file with the suffix .xml, and the scene data file that conforms to the syntax is output.
[0124] S52. Locate the empty class definition shell in the code template that starts with the class keyword and ends with a colon. Extract the entity attributes from the entity information field in the structured intermediate result. Concatenate the entity attributes with the initial value according to the assignment equals sign to form a variable assignment statement. Copy and paste it into the indented area inside the empty class definition shell to complete filling the entity attributes into the class initialization method of the code template.
[0125] S53. Locate the event handling function whose function name contains the character "event" in the code template, extract the event logic from the task information field in the structured intermediate result, convert the event logic into a line of code containing conditional judgment syntax and paste it between the opening and closing curly braces of the event handling function to complete filling the event logic into the event handling function;
[0126] S54. Locate the function whose name contains the character for communication in the code template, extract the interaction rules from the entity information field in the structured intermediate results, decompose the interaction rules into sender, receiver and data content, and fill them into the variable assignment statements inside the communication function respectively. Complete the filling of the interaction rules into the inter-entity communication code, save the filled code template as a text file with the corresponding language suffix, and output the executable simulation model code.
[0127] In this embodiment, S6 specifically includes:
[0128] S61. Receive the modified text of the scene data file and executable simulation model code output by the user through the interactive interface, and concatenate the modified text with the original dialogue state information in the memory array variable through a newline character to form a long text string.
[0129] S62. Extract the structured intermediate results generated in the memory array variable, concatenate the structured intermediate results with the long text string as the input context, and locate the target field that has undergone numerical or logical changes from the modified text.
[0130] S63. Retain the unchanged field content in the structured intermediate result, and only re-execute the string extraction and key-value pair combination operation on the target field to generate a partially updated structured intermediate result that overwrites and replaces the original structured intermediate result.
[0131] S64. After the partial update of the structured intermediate results, select the XML Schema rule template and code template again according to the string comparison and hierarchical arrangement operation. According to the placeholder replacement and code line pasting operation, only perform regeneration and mapping filling for the tag line and function code corresponding to the target field. Obtain the updated scene data file and the updated executable simulation model code and output them.
[0132] A simulation modeling system based on a large model-driven approach, comprising:
[0133] The requirement parsing and interactive completion module is used to receive and parse the natural language simulation requirements input by the user, identify the task type, domain category, entity type and attribute parameter information, and guide the user to progressively complete the information if the information is incomplete, construct and output the dialogue state information.
[0134] The domain knowledge retrieval module is used to perform word segmentation and pooling mapping operations on the natural language simulation requirements input by the user through all-MiniLM-L6-v2, calculate the numerical vector corresponding to the text, traverse and calculate the spatial distance in the structured knowledge graph and multi-dimensional simulation database, recall knowledge graph nodes and historical simulation model files and output them as supplementary information of domain knowledge.
[0135] The graph neural topology enhancement parsing module uses an improved Llama-3 model to process domain knowledge supplementary information and dialogue state information, constructs a graph neural topology injection layer, and constructs entity relationship graphs in parallel to perform message passing and extract topological features when processing entity and interaction rule subtasks. The topological features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one, and integrating them into structured intermediate results for output.
[0136] The template matching and selection module is used to parse structured intermediate results. For simulation scene file generation requirements, it selects the XML Schema rule template corresponding to the target simulation platform data standard. For simulation model generation requirements, it selects the code template corresponding to the specific simulation language syntax specification and outputs the XML Schema rule template and code template.
[0137] The structured mapping and filling module is used to map and fill the structured intermediate results to the corresponding level positions of the XML Schema rule template to generate format constraints, output the scene data file, fill the entity attributes into the class initialization method of the code template, fill the event logic into the event handling function, fill the interaction rules into the inter-entity communication code, and output the scene data file and executable simulation model code.
[0138] The incremental modification feedback module is used to repeatedly execute the requirement parsing and interactive completion module to the structured mapping and filling module when it receives a user's modification request for the generated results. Based on the original structured intermediate results, it regenerates and maps only the modified parts, and outputs the updated scene data file and the updated executable simulation model code.
[0139] Example 1: To verify the feasibility of this invention in practice, it was applied to a microgrid simulation planning platform in a highly digitized intelligent manufacturing park in a certain province. The park covers approximately four square kilometers and includes three large-scale distributed photovoltaic power stations, two megawatt-level energy storage stations, and a complex load cluster encompassing precision machining and semiconductor manufacturing. Daily simulation modeling tasks are primarily undertaken by the park's power dispatch R&D center. This center frequently constructs microgrid operation simulation scenarios and underlying control logic models based on seasonal sunlight intensity, enterprise production scheduling plans, and sudden power outage maintenance needs. Traditional simulation construction processes heavily rely on senior engineers. R&D personnel must first read dozens of pages of dispatch requirement documents, manually draw the topology connections of hundreds of photovoltaic panels, transformers, and load nodes in the simulation software, and write power balance and charging / discharging control code line by line. This method not only consumes a very long time for each modeling iteration but also easily leads to code errors such as undefined variables or logical deadlocks when facing complex multi-node interactions. The generated files often require four or five rounds of software error checking and manual modification before they can barely run.
[0140] In the actual deployment of this invention, researchers only need to input natural language descriptions through the platform's interactive interface. For example, they can request the construction of a photovoltaic-storage collaborative simulation scenario containing a specific number of photovoltaic arrays and energy storage nodes, and specify the power allocation interaction rules during load surges. After receiving the request, the system first quickly identifies entity types such as photovoltaics, energy storage, and load, as well as power parameters, using a built-in simulation lexicon. When transformer capacity parameters are missing, the system automatically asks engineers for supplementary information using a subject-verb-object syntax to ensure the completeness of the request elements. Subsequently, the system calls the all-MiniLM-L6-v2 model to convert the natural language request into a numerical vector, and performs high-precision traversal matching in the background structured knowledge graph and multi-dimensional simulation database to quickly recall variable definitions and classic control logic from similar photovoltaic-storage collaborative projects in the past as supplementary domain knowledge. During the core parsing phase, the improved Llama-3 model begins operation. When a subtask involving photovoltaic and energy storage interaction rules is encountered, the model automatically constructs an entity relationship graph, extracts directed interaction topological features between nodes using a graph neural network topology injection layer, and deeply integrates these spatial topological features back into the hidden layer of the language model through a cross-modal gating mechanism. This allows for a precise understanding of complex energy flow relationships and the sequential generation of structured intermediate results. Finally, the system automatically matches XML Schema rule templates and code templates conforming to the target simulation platform standard, accurately fills entity attributes into class initialization methods, fills event logic into event handling functions, and fills interaction rules into communication code, directly outputting a syntax-free scene data file and executable simulation model code. When engineers request modifications only to the energy storage charging and discharging thresholds, the system does not globally rewrite but precisely locates specific fields in the structured intermediate results for local updates and mapping, greatly preserving the stability of the original code. Table 1 below shows detailed performance comparison data between the method of this invention, traditional manual modeling, and conventional large model direct generation methods in microgrid simulation modeling tasks during a three-month intensive testing period:
[0141] Table 1. Multi-dimensional performance comparison data in the simulation modeling task of microgrids in smart manufacturing parks.
[0142]
[0143] As can be seen from the comparative data in Table 1 above, the simulation modeling method based on large model-driven proposed in this invention exhibits overwhelming technical advantages in complex power simulation scenarios. Regarding the completeness of requirement understanding, conventional large models, lacking domain constraints, only achieve a requirement element completion rate of around 70%, often omitting crucial rated power parameters. In contrast, this invention, through dictionary comparison and a progressive questioning mechanism, stabilizes the completion rate at over 95%, almost reaching the level of human review. In terms of the most critical aspect—topological logic accuracy—conventional large models often lose their way when faced with complex interactions such as multi-transformer fault isolation, with logic accuracy dropping below 65%. However, this invention, by introducing a graph neural network topology injection layer, effectively captures the directed relationships between power grid nodes, maintaining a topological logic accuracy consistently above 91%, completely resolving the weakness of pure text models in spatial reasoning.
[0144] In terms of code deployment usability, the advantages of this invention are further amplified. While traditional manually written code is logically rigorous, due to human error, the first-pass yield is less than 40%, and each file contains an average of a dozen syntax errors, requiring significant time for debugging. Conventional large models, although fast to generate, are not constrained by syntax templates, resulting in hundreds of lines of invalid and redundant code, riddled with dozens of serious interface call errors, making them unparsable by simulation engines. In contrast, the method of this invention, through strict template mapping and structured completion, achieves a first-pass yield of over 83% in four typical scenarios, compresses syntax errors to around two, and produces almost no redundant code, directly bridging the final gap from natural language to executable files.
[0145] Regarding the time consumption metric, which is of utmost concern to engineers, traditional manual methods often require nearly four and a half hours to build a simulation model of an isolated system operating in extreme weather conditions, and even local modifications take more than an hour. While conventional large models can be generated in just over ten seconds per iteration, the unusable generated files mean that subsequent manual modifications and corrections can be even more time-consuming than purely manual modeling. The method of this invention, relying on powerful knowledge retrieval and automatic filling capabilities, significantly reduces the initial modeling time to less than five minutes. More importantly, with the support of an incremental modification feedback mechanism, the time for local logic adjustments is reduced to approximately two minutes. This leap in efficiency from hours to minutes not only completely unleashes the creativity of simulation engineers but also enables microgrid systems to quickly respond to the virtual verification needs of various unexpected operating conditions, demonstrating extremely high engineering practical value and broad industry application prospects.
[0146] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A simulation modeling method based on large model-driven approach, characterized in that, Includes the following steps: S1. Receive and parse the natural language simulation requirements input by the user, identify the task type, domain category, entity type and attribute parameter information. If the information is incomplete, guide the user to gradually complete it, construct and output the dialogue state information. S2. Using all-MiniLM-L6-v2, the user-input natural language simulation requirements are segmented and pooled to calculate the numerical vector corresponding to the text. Spatial distance is calculated by traversing the structured knowledge graph and multi-dimensional simulation database. Knowledge graph nodes and historical simulation model files are recalled and output as supplementary information for domain knowledge. S3. The improved Llama-3 model is used to process domain knowledge supplementary information and dialogue state information. A graph neural topology injection layer is constructed. When processing entity and interaction rule subtasks, entity relationship graphs are constructed in parallel for message passing and topology features are extracted. The topology features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one, and integrating them into structured intermediate results and outputting them. S4. Parse the structured intermediate results. For the simulation scene file generation requirements, select the XML Schema rule template corresponding to the target simulation platform data standard. For the simulation model generation requirements, select the code template corresponding to the specific simulation language syntax specification. Output the XML Schema rule template and the code template. S5. Map the structured intermediate results to the corresponding level positions of the XML Schema rule template to generate format constraints, output the scene data file, fill the entity attributes into the class initialization method of the code template, fill the event logic into the event handling function, fill the interaction rules into the inter-entity communication code, and output the scene data file and executable simulation model code. S6. When a user requests modifications to the generated results, repeat steps S1 to S5. Based on the original structured intermediate results, only the modified parts are regenerated and mapped, and the updated scene data file and updated executable simulation model code are output.
2. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S1 specifically includes: S11. Receive the natural language simulation requirements input by the user through the interactive interface, segment them according to spaces and punctuation marks, and compare the segmented word groups with the pre-built simulation professional lexicon in turn. If the comparison is consistent, mark the category label of the corresponding word group. After traversing all word groups, summarize the task type, domain category, entity type and attribute parameter information with category labels. S12. Extract all phrases under each category label in the simulation professional thesaurus, count them for deduplication, and use the deduplication count result as the total number of elements in the corresponding category. Subtract the number of phrases under each category label from the total number of elements in the corresponding category. If the difference is greater than zero, the information is determined to be incomplete. S13. If the information is incomplete, extract the unmatched word groups corresponding to the category labels with a difference greater than zero from the simulation professional lexicon as the missing information to be supplemented, take the successfully matched word groups as the confirmed simulation elements, and concatenate the confirmed simulation elements and the missing information to be supplemented into a question according to the subject-verb-object grammar rules. Display the question as a follow-up question through the interactive interface. S14. Receive supplementary text input by the user in response to follow-up questions through the interactive interface, concatenate the supplementary text to the end of the natural language simulation requirements, and re-perform the segmentation, matching and subtraction calculation operations on the concatenated text. Repeat the process until the difference between the corresponding labels of each category is equal to zero. S15. When the difference between the labels of each category is equal to zero, the concatenated text from each round is joined together with a newline character in the order of input time to form a long text string, which is then assigned to a memory array variable for storage, and the dialogue status information is output.
3. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S2 specifically includes: S21. Divide the natural language simulation requirements input by the user into word sequences according to word boundaries, map each word to an index number, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, use each index number as a row number, and replace the entire row value corresponding to the row number in the zero matrix with a vector generated by normally distributed random numbers. S22. Add the sine and cosine function values generated by the replacement row of values and the corresponding word values in the natural language simulation requirements in ascending order of position to generate a word vector sequence. Insert a zero vector at the beginning of the word vector sequence as a special classification vector. S23. Input the word vector sequence containing special classification vectors into the twelve-layer multi-head self-attention network of the all-MiniLM-L6-v2 model. In each layer, multiply the word vector sequence by three different randomly initialized weight matrices to generate a query matrix, a key matrix, and a value matrix. Multiply the query matrix by the transpose of the key matrix and divide by the square root of the dimension. Obtain the attention weights through exponential operation and normalization. Multiply the attention weights by the value matrix to output a context-related feature vector that incorporates contextual information. S24. Input the context association feature vector output by the twelfth layer network into the average pooling layer unique to the all-MiniLM-L6-v2 model, remove the first and last zero vectors, sum all the remaining context association feature vectors in the sequence length dimension, divide the sum by the number of remaining vectors to calculate the arithmetic mean, and use the calculated arithmetic mean as the numerical vector. S25. Collect historical simulation requirement texts and corresponding historical simulation model codes, extract entity names from historical simulation requirement texts, extract target variable names from variable assignment statements in historical simulation model codes, use entity names and target variable names as nodes, draw lines between nodes extracted from the same text and code to generate edges, and construct a structured knowledge graph. S26. Traverse all nodes in the structured knowledge graph and all files stored in the multi-dimensional simulation database, extract node numerical vectors and historical simulation model file numerical vectors, calculate the cosine similarity score, and output supplementary domain knowledge information.
4. The simulation modeling method based on large model-driven simulation according to claim 3, characterized in that, S26 specifically includes: S261. Traverse all nodes in the structured knowledge graph, extract the text of the entity name and the corresponding target variable name stored in each node and combine them into node text, and convert the node text into node value vectors according to the operations in S21 to S24. S262. Simultaneously traverse all files stored in the multi-dimensional simulation database, locate the text area of the first five lines inside each historical simulation model file, read the characters in the text area line by line and filter out the character lines containing equal signs and variable data types as variable definition text, and convert the filtered variable definition text into historical simulation model file numerical vectors according to the operations of S21 to S24. S263. Take the numerical vector corresponding to the natural language simulation requirement as the numerator, and take the numerical vector of each node and the numerical vector of each historical simulation model file as the denominator. Calculate the inner product by multiplying the elements at corresponding positions in the numerator and denominator, and sum them. Add the squares of all elements in the numerator vector and the denominator vector respectively and take the square root to find the modulus. Divide the inner product by the product of the two moduli to obtain the cosine similarity score. S264. Subtract all calculated cosine similarity scores from the preset similarity threshold in sequence, filter out the cosine similarity scores with a subtraction result greater than zero, extract the entity name and attribute description text from the knowledge graph node corresponding to the selected cosine similarity score, as well as the variable definition text from the historical simulation model file, and concatenate the extracted text in order to form domain knowledge supplementary information and output it.
5. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S3 specifically includes: S31. Connect the domain knowledge supplementary information and the dialogue status information into a long text string using a newline character. Add instruction characters to the beginning of the long text string to guide the extraction of task type and attributes and construct prompt words. Segment the prompt words according to periods. Rearrange each segmented independent sentence according to causal logic and chronological order to generate a subtask sequence. S32. Input the subtask sequence into the improved Llama-3 model. When a sentence containing both entity names and interaction rule descriptions is read from the subtask sequence, extract the entity names from the sentence as graph nodes, extract the action executor and action receiver from the interaction rule description as start and end points, draw directed line segments to generate directed edges, construct an all-zero adjacency matrix with graph nodes as row indices and directed edges as column indices, replace the values at the positions where there are directed line segments connected with zeros to one, and construct an entity relationship graph. S33. Construct a graph neural topology injection layer. Input the entity relationship graph into the graph neural topology injection layer. Create an all-zero vector with a dimension equal to a set value for each graph node in the entity relationship graph as the initial feature vector. For each graph node, find the column index with a value of one in the corresponding row of the graph node in the all-zero adjacency matrix, and extract the initial feature vector of the graph node corresponding to the column index. S34. Add the initial feature vector to the initial feature vector of the current graph node element by element and input it into the fully connected layer for linear transformation and nonlinear mapping to obtain the updated feature vector and replace the initial feature vector in the current graph node. Repeat the above table lookup, addition, linear transformation and nonlinear mapping operations until the feature vectors of all graph nodes stop changing. Extract the final set of feature vectors of all graph nodes as topological features. S35. Read the current subtask from the ordered subtask sequence inside the improved Llama-3 model, divide it into a character sequence, create a zero matrix with the number of rows equal to the total number of characters and the number of columns equal to the set feature dimension, replace the row number of each character arrangement as a normal distribution random number vector, and add the sine and cosine function values of the character position element by element to generate a word vector sequence. S36. Input the word vector sequence into multiple self-attention layers, multiply it by the query weight matrix, key weight matrix and value weight matrix in sequence, multiply the query matrix and key matrix by transpose and divide by the square root of the dimension, obtain the attention weight through exponential operation and normalization calculation, multiply it by the value matrix and iterate, and use the multidimensional array output by the last layer as the hidden layer vector of the language model. S37. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and use the hidden layer vectors of the language model to gradually combine all the subtasks to generate JSON format fragments, obtain structured intermediate results and output them.
6. The simulation modeling method based on large model-driven simulation according to claim 5, characterized in that, Specifically, S37 includes: S371. Input the extracted topological features into the cross-modal gating mechanism inside the improved Llama-3 model, and perform element-wise multiplication at the corresponding position on the feature vector of each graph node in the topological features and the hidden layer vector of the language model corresponding to the subtask currently being processed by the improved Llama-3 model to generate a gating weight vector. S372. Multiply each element in the gate weight vector by the corresponding element in the language model hidden layer vector, and add it to the original value in the corresponding position of the language model hidden layer vector. Replace the original value in the language model hidden layer vector with the new value obtained after addition, and complete the topological feature fusion back to the language model hidden layer. S373. The improved Llama-3 model processes subtasks sequentially. For each subtask, the fused language model hidden layer vector is input to the linear mapping layer and converted into a probability distribution of vocabulary size. The maximum number of predefined words in the probability distribution are extracted as predicted words. The predicted words are used as keys in key-value pairs, and the entity names and values extracted from the subtasks are used as values in key-value pairs. The keys and values are combined into JSON format fragments according to the JSON syntax format of curly braces and colons. S374. Connect all the JSON format fragments generated by the subtasks in the order of the subtask sequence with commas, wrap the concatenated string in outer curly braces, generate a structured intermediate result and output it.
7. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S4 specifically includes: S41. Read the overview information field in the structured intermediate results, extract the target simulation platform name string contained in the overview information, compare the target simulation platform name string with the software name in the data format specification documents of multiple simulation platforms that have been collected in advance, filter out the specification documents with the same software name, divide the specification documents into independent label rows according to the angle bracket symbol, and extract the string in the angle bracket of each label row as the data label. S42. Count the number of indentation spaces in each tag line, divide it by the preset number of spaces corresponding to a single level to calculate the quotient value, and use it as the nesting depth value. Arrange the data tags in the parent-child nesting relationship according to the line order. Extract the string to the left of the equal sign in the tag line as the attribute name and extract the string to the right of the equal sign as the attribute constraint rule. Concatenate the parent-child nesting relationship, attribute name and attribute constraint rule in the line order and write them into a newly created text file to build an XMLSchema rule template for output. S43. Read the task information field in the structured intermediate result, extract the specific simulation language name string contained in the task information, compare the specific simulation language name string with the language declaration keywords in the first line of multiple open source simulation project files of different languages downloaded from the open source code hosting platform, filter out the open source simulation project files with consistent language declaration keywords, extract the empty class definition shells and empty function definition shells in the open source simulation project files and construct them into code templates for output.
8. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S5 specifically includes: S51. Compare the overview information, entity information and task information fields in the structured intermediate results with the tag lines containing attribute names in the XML Schema rule template. When the attribute name in the tag line matches the field name, extract the text content corresponding to the field and replace the placeholder corresponding to the attribute constraint rule in the tag line. After replacing all the placeholders, save the XML Schema rule template as a text file with the .xml extension and output the scene data file. S52. Locate the empty class definition shell in the code template that starts with the class keyword and ends with a colon. Extract the entity attributes from the entity information field in the structured intermediate result. Concatenate the entity attributes with the initial value according to the assignment equals sign to form a variable assignment statement. Copy and paste it into the indented area inside the empty class definition shell to complete filling the entity attributes into the class initialization method of the code template. S53. Locate the event handling function whose function name contains the character "event" in the code template, extract the event logic from the task information field in the structured intermediate result, convert the event logic into a line of code containing conditional judgment syntax and paste it between the opening and closing curly braces of the event handling function to complete filling the event logic into the event handling function; S54. Locate the function whose name contains the character for communication in the code template, extract the interaction rules from the entity information field in the structured intermediate results, decompose the interaction rules into sender, receiver and data content, and fill them into the variable assignment statements inside the communication function respectively. Complete the filling of the interaction rules into the inter-entity communication code, save the filled code template as a text file with the corresponding language suffix, and output the executable simulation model code.
9. The simulation modeling method based on large model-driven simulation according to claim 1, characterized in that, S6 specifically includes: S61. Receive the modified text of the scene data file and executable simulation model code output by the user through the interactive interface, and concatenate the modified text with the original dialogue state information in the memory array variable through a newline character to form a long text string. S62. Extract the structured intermediate results generated in the memory array variable, concatenate the structured intermediate results with the long text string as the input context, and locate the target field that has undergone numerical or logical changes from the modified text. S63. Retain the unchanged field content in the structured intermediate result, and only re-execute the string extraction and key-value pair combination operation on the target field to generate a partially updated structured intermediate result that overwrites and replaces the original structured intermediate result. S64. After the partial update of the structured intermediate results, select the XMLSchema rule template and code template again according to the string comparison and hierarchical arrangement operation. According to the placeholder replacement and code line pasting operation, only perform regeneration and mapping filling for the tag line and function code corresponding to the target field. Obtain the updated scene data file and the updated executable simulation model code and output them.
10. A simulation modeling system based on a large model, executing the simulation modeling method based on a large model as described in any one of claims 1 to 9, characterized in that, include: The requirement parsing and interactive completion module is used to receive and parse the natural language simulation requirements input by the user, identify the task type, domain category, entity type and attribute parameter information, and guide the user to progressively complete the information if the information is incomplete, construct and output the dialogue state information. The domain knowledge retrieval module is used to perform word segmentation and pooling mapping operations on the natural language simulation requirements input by the user through all-MiniLM-L6-v2, calculate the numerical vector corresponding to the text, traverse and calculate the spatial distance in the structured knowledge graph and multi-dimensional simulation database, recall knowledge graph nodes and historical simulation model files and output them as supplementary information of domain knowledge. The graph neural topology enhancement parsing module uses an improved Llama-3 model to process domain knowledge supplementary information and dialogue state information, constructs a graph neural topology injection layer, and constructs entity relationship graphs in parallel to perform message passing and extract topological features when processing entity and interaction rule subtasks. The topological features are fused back into the language model hidden layer through a cross-modal gating mechanism. The subtask sequence is executed in sequence, generating corresponding JSON format fragments one by one, and integrating them into structured intermediate results for output. The template matching and selection module is used to parse structured intermediate results. For simulation scene file generation requirements, it selects the XML Schema rule template corresponding to the target simulation platform data standard. For simulation model generation requirements, it selects the code template corresponding to the specific simulation language syntax specification and outputs the XML Schema rule template and code template. The structured mapping and filling module is used to map and fill the structured intermediate results to the corresponding level positions of the XML Schema rule template to generate format constraints, output the scene data file, fill the entity attributes into the class initialization method of the code template, fill the event logic into the event handling function, fill the interaction rules into the inter-entity communication code, and output the scene data file and executable simulation model code. The incremental modification feedback module is used to repeatedly execute the requirement parsing and interactive completion module to the structured mapping and filling module when it receives a user's modification request for the generated results. Based on the original structured intermediate results, it regenerates and maps only the modified parts, and outputs the updated scene data file and the updated executable simulation model code.