An intelligent script engine system and optimization method for simulation software
Through multi-layer optimization and semantic analysis of the intelligent script engine system, the problems of low efficiency and poor maintainability of script engines in simulation software are solved, and efficient and reliable script execution and intelligent auxiliary functions are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING SHENZHOU AEROSPACE SOFTWARE TECH CO LTD
- Filing Date
- 2026-03-17
- Publication Date
- 2026-06-19
AI Technical Summary
Existing simulation software script engines are inefficient for computationally intensive scripts, and the script code is fragile, poorly maintainable, and lacks intelligent assistance functions.
An intelligent script engine system is adopted, including a script parsing and semantic enhancement module, an intelligent context awareness module, a multi-layer intermediate representation and optimization module, and a unified execution engine. Performance and robustness are improved through semantic analysis and multi-layer optimization techniques.
It achieves orders-of-magnitude performance improvements for computationally intensive scripts, enhances script reliability and development efficiency, provides real-time code completion and performance bottleneck analysis, and simplifies the debugging process.
Smart Images

Figure CN122240242A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and more specifically to an intelligent script engine system and optimization method for simulation software. Background Technology
[0002] In modern engineering design and scientific research, computer-aided engineering software has become an indispensable tool. To enhance the flexibility and automation capabilities of software, mainstream simulation software generally integrates script engines, allowing users to automate simulation processes, parametric studies, and customized post-processing by writing scripts (such as using Python, Lua, or specialized languages).
[0003] Currently, the mainstream technical solution to achieve this function is the "embedded interpreter" solution, which involves embedding an open-source scripting language interpreter into the simulation software through an API binding tool.
[0004] However, this approach has significant drawbacks: First, its pure interpreted execution mode is inefficient when dealing with computationally intensive scripts, becoming a performance bottleneck for simulation automation; second, the scripts are tightly coupled to the kernel through a thin API, resulting in fragile script code, poor maintainability, and obscure error messages that are difficult to understand and debug; finally, the existing engine is completely passive, unable to understand user intent, and lacks intelligent assistance functions.
[0005] Another approach, "custom scripting language," while highly compatible with the software, suffers from closed language functionality, a weak ecosystem, and limitations on advanced user applications.
[0006] Therefore, there is an urgent need for a new script engine technology to simultaneously address the issues of performance, robustness, debuggability, and intelligence. Summary of the Invention
[0007] Therefore, this invention provides an intelligent script engine system and optimization method for simulation software to solve the problems in the prior art.
[0008] To achieve the above objectives, the present invention provides the following technical solution: An intelligent script engine system for simulation software includes a script parsing and semantic enhancement module, an intelligent context awareness module, a multi-layer intermediate representation and optimization module, and a unified execution engine; The script parsing and semantic enhancement module performs lexical and syntactic analysis on the input script source code to construct an initial abstract syntax tree. It also interacts with the intelligent context awareness module to query semantic information in the current simulation context and attaches the queried semantic information as annotations to the corresponding nodes of the initial abstract syntax tree to generate an enhanced abstract syntax tree. The intelligent context awareness module maintains the global state and data environment in the simulation context, forms a dynamic simulation domain metadata knowledge base, and provides real-time semantic information query services. The multi-layer intermediate representation and optimization module receives the enhanced abstract syntax tree and converts it into a multi-layer intermediate representation, and performs optimization; the multi-layer intermediate representation includes a high-level intermediate representation corresponding to simulation semantic operations and a low-level intermediate representation corresponding to numerical computation and memory access; the optimization includes operation fusion optimization based on simulation semantics performed at the high-level intermediate representation layer and loop optimization based on affine transformation theory performed at the low-level intermediate representation layer. The unified execution engine integrates an interpreter and a just-in-time (JIT) compiler, and performs mixed-mode execution on the optimized intermediate representation code. Based on runtime analysis, it dynamically decides whether to interpret and execute code segments or trigger JIT compilation to generate and execute native machine code.
[0009] Furthermore: the script parsing and semantic enhancement module is based on attribute grammar theory. By querying the intelligent context-aware module, it adds semantic attributes to the identifier nodes of the initial abstract syntax tree and performs type consistency verification. The semantic attributes include type information, physical units, and numerical range constraints.
[0010] Furthermore, the intelligent context-aware module can provide users' integrated development environment with context-aware intelligent code completion and semantically based accurate error diagnosis services.
[0011] Furthermore: the operation fusion optimization performed by the multi-layer intermediate representation and optimization module at the high-level intermediate representation layer includes: Analyze the data dependencies between successive simulation operations and construct a data flow graph; Identify operation sequences that iterate over the same data set multiple times without data dependencies; The operation sequence is merged into a single traversal operation.
[0012] Furthermore: the multi-layer intermediate representation and optimization module performs iterative optimization based on affine transformation theory at the lower-level intermediate representation layer, including: Nested loops are modeled as polyhedral models, and the affine relationship between loop index variables and array access patterns is analyzed. Based on the analysis results, loop partitioning optimization is applied to improve cache locality, and automatic parallelization is implemented to utilize multi-core computing resources.
[0013] Furthermore: In the hybrid mode execution of the unified execution engine, the unified execution engine monitors the execution frequency and computational intensity of code segments in real time. When the predicted total cost of interpreted execution exceeds the sum of the just-in-time compilation overhead and the cost of execution after compilation, just-in-time compilation is triggered.
[0014] Furthermore, the system can optimize memory access patterns through cache-aware data layout optimization and dynamic memory allocation strategies.
[0015] Furthermore, the system also supports a transactional execution model, periodically saves checkpoints, and resumes execution from the most recent checkpoint in the event of a failure.
[0016] To achieve the above objectives, the present invention also provides an intelligent script engine optimization method for simulation software, comprising the following steps: Step S1, Script parsing and semantic enhancement: The input script source code is parsed and combined with the semantic information in the current simulation context to generate an enhanced abstract syntax tree carrying type and physical meaning; Step S2: The enhanced abstract syntax tree is converted into a multi-layer intermediate representation, and high-level optimization based on simulated semantics and low-level optimization based on computational performance are performed sequentially. The multi-layer intermediate representation includes a high-level intermediate representation and a low-level intermediate representation. The high-level optimization includes operation fusion optimization based on data dependencies, and the low-level optimization includes loop optimization based on affine transformation theory. Step S3: A hybrid execution mode is adopted, and the optimized intermediate representation code is interpreted or compiled and executed on the fly based on runtime analysis and dynamic decision-making.
[0017] The present invention has the following advantages: By using multi-layer intermediate representation and just-in-time compilation technology, the present invention dynamically optimizes computationally intensive scripts into local machine code, achieving an order-of-magnitude performance improvement and making full use of multi-core parallel and vectorized computing capabilities; it can proactively perceive the simulation context and provide real-time code completion, performance bottleneck analysis and optimization suggestions.
[0018] Other features and advantages of the present invention will be set forth in the following description. Attached Figure Description
[0019] To more intuitively illustrate the prior art and this application, exemplary drawings are provided below. It should be understood that the specific shapes and structures shown in the drawings should not generally be regarded as limiting conditions for implementing this application; for example, based on the technical concept disclosed in this application and the exemplary drawings, those skilled in the art are able to easily make conventional adjustments or further optimizations to the addition / reduction / classification, specific shapes, positional relationships, connection methods, size ratios, etc. of certain units (components).
[0020] Figure 1 This is an architecture diagram of an intelligent script engine system for simulation software provided in an embodiment of this application. Detailed Implementation
[0021] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these embodiments are merely for further explanation of the present invention and should not be construed as limiting the scope of protection of the present invention. Those skilled in the art can make some non-essential improvements and adjustments to the present invention based on the above-described content.
[0022] The intelligent script engine system of this invention adopts a layered processing architecture, extending the traditional two-stage "source code-interpreted execution" model into a multi-stage processing pipeline of "semantic parsing → intermediate representation optimization → adaptive execution". The core innovation of this architecture lies in the introduction of a semantically enhanced abstract syntax tree and a multi-layered intermediate representation system, enabling the engine to transform from a simple instruction executor into an intelligent system capable of understanding the semantics of the simulation domain and performing in-depth optimization.
[0023] Please see Figure 1 A smart script engine system for simulation software includes a script parsing and semantic enhancement module responsible for front-end processing, an intelligent context-aware module that provides domain knowledge support, a multi-layer intermediate representation and optimization module that undertakes core optimization tasks, and a unified execution engine responsible for final high-efficiency execution. These four modules exchange data and work together through interfaces to form a complete script processing ecosystem.
[0024] The script parsing and semantic enhancement module can inject semantic information from the simulation domain into the abstract syntax tree to form an enhanced abstract syntax tree. Based on attribute grammar theory, the script parsing and semantic enhancement module interacts with the intelligent context awareness module to query the semantic information in the current simulation context, and attaches the queried semantic information as annotations to the corresponding nodes of the initial abstract syntax tree to generate an enhanced abstract syntax tree (enhanced AST).
[0025] The semantic information includes type information, physical units, numerical range constraints, etc., and the enhanced abstract syntax tree is subjected to type consistency verification to ensure the correctness of the script semantics.
[0026] The specific content of the script parsing and semantic enhancement module is as follows: After completing the initial lexical and syntactic analysis, the script parsing and semantic enhancement module adds rich semantic attributes to each node by traversing the generated abstract syntax tree (AST).
[0027] Let the original AST be Where N is the set of nodes and E is the set of edges; through the semantic enhancement process, an enhanced AST is constructed as follows: Each enhancement node It can be represented as: ; Where n is the original syntax node, A represents an additional set of semantic attributes.
[0028] Semantic attributes are obtained by querying the intelligent context-aware module; For each identifier node Execute query function Where c represents the current simulation context, This is a semantic mapping function; the query results include semantic attributes such as type information, physical units, and numerical range constraints.
[0029] Furthermore, the present invention systematically designs a strongly typed domain-specific type system, which includes types (integer, floating-point, etc.) and domain types (mesh nodes, boundary conditions, material properties, etc.). The domain-specific type system ensures semantic consistency through subtype relationships and type conversion rules.
[0030] Let the type system be Where B is the set of basic types, D is the set of domain types, and R is the set of type relations.
[0031] For any operation (This represents an operation op, which receives two types respectively) and The operands, the return type is The result), through type consistency checks, ensures the legality of the operation: ; During the construction of the enhanced AST, type checking is performed in real time to detect type mismatch errors in advance, significantly improving the reliability of the script.
[0032] The intelligent context-aware module maintains the global state and data environment in the simulation context, forming a dynamic simulation domain metadata knowledge base. This module employs an ontology-based knowledge representation method, storing domain concepts in triples and supporting incremental learning. It records user script writing patterns and common operation sequences to continuously enrich domain knowledge. Simultaneously, the module provides real-time semantic information query services and further offers context-aware intelligent code completion and semantically accurate error diagnosis services to the user's integrated development environment.
[0033] The specific contents of the intelligent context awareness module are as follows: 1) Construct a metadata knowledge base The intelligent context-aware module maintains a dynamic simulation domain metadata knowledge base, employing an ontology-based knowledge representation method. The core of this simulation domain metadata knowledge base is the triple representation of domain concepts. ; Where S is the subject set (simulation objects); P is the predicate set (attributes, relations); It is a collection of objects (attribute values, associated objects).
[0034] The simulation domain metadata knowledge base is dynamically updated through an incremental learning mechanism, recording users' script writing patterns and common operation sequences to continuously enrich domain knowledge; Furthermore, the system of this invention employs a statistical learning algorithm to quantitatively analyze indicators such as operation frequency and association strength, thereby optimizing the knowledge recommendation effect.
[0035] 2) Context-aware query optimization The query processing employs a context-based optimization strategy; for query Q, based on the current simulation state... Generate the optimal query plan:
[0036] The Cost function takes into account multiple factors, including query response time, memory overhead, and result accuracy.
[0037] The multi-level intermediate representation and optimization module receives the enhanced abstract syntax tree, converts it into a multi-level intermediate representation, and performs optimization; the multi-level intermediate representation includes a high-level intermediate representation and a low-level intermediate representation. Among them, the high-level intermediate representation adopts a domain-specific instruction set to directly express simulation semantic operation primitives, such as "apply force", "solve transient field", "update mesh", etc. The low-level intermediate representation uses a static single-assignment form, focusing on the ultimate optimization of numerical calculation and low-level memory access.
[0038] The optimizations performed include: A. Optimization of operation fusion based on simulation semantics performed in the high-level intermediate presentation layer; By analyzing the data dependencies between continuous simulation operations, a data flow graph is constructed to identify operation sequences that traverse the same data set multiple times without data dependencies. These operation sequences are then merged into single traversal operations to reduce data access overhead. B. Loop optimization based on affine transformation theory performed in the lower-level intermediate representation layer; Nested loops are modeled as polyhedral models, and the affine relationship between loop index variables and array access patterns is analyzed. Based on the analysis results, loop block optimization is applied to improve cache locality, and / or automatic parallelization is implemented to utilize multi-core computing resources.
[0039] The specific contents of the multi-layer intermediate representation and optimization module are as follows: (1) High-level intermediate representation and simulation semantic optimization High-level Intermediate Representation (IR) uses a domain-specific instruction set to directly express simulation semantics; it abstracts simulation operations into a series of primitive operations. ; Each of them Corresponding to one simulated semantic unit; 1) Optimization based on data flow analysis; constructing data flow graphs To analyze the dependencies between operations; vertices Indicates operation, edge express Depends on The output of .
[0040] The data dependencies are defined as follows: Stream dependency: Write variable x, Read variable x, and there exists a value from... arrive The execution path; Anti-dependency: Read variable x, Write the variable x; Output dependencies: and Write the variable x in both cases; By analyzing these dependencies, a set of operations that can be executed in parallel can be identified.
[0041] Let the optimization objective be D with parallelism: ; 2) Operation fusion optimization; for consecutive traversal operation sequences Let each operation The time complexity is , where n is the data size.
[0042] Therefore, the original execution time is:
[0043] Execution time after fusion:
[0044] Where g(n) is the fusion overhead function.
[0045] When the condition is met At the same time, fusion optimization brings significant performance improvement; by analyzing operational characteristics, it can automatically determine whether the fusion conditions are met.
[0046] (2) Low-level intermediate representation and computation optimization The low-level intermediate representation (IR) adopts a static single assignment form, which facilitates compiler optimization; in this embodiment, the focus is on optimizing numerically computationally intensive loops.
[0047] 1) Affine cyclic transformation; for nested loops, model them as polyhedra; consider d-dimensional nested loops:
[0048] The iteration space is then defined as: ; Data access functions are represented in affine form: , where M is the access matrix and c is the offset vector.
[0049] 2) Mathematical basis of cyclic block optimization; cyclic block optimization divides the original iteration space I into a block iteration space B and an intra-block iteration space L: ; Where T is the block size.
[0050] The optimization objective is to minimize the cache miss rate; let the cache line size be C and the cache capacity be S; then the optimal block size is... The following optimization problem was solved to obtain the following: ; Through locality theory analysis, an approximate solution for the optimal block factor is derived: ; in, This indicates the amount of data accessed in each iteration.
[0051] 3) Automatic parallelization theory; automatic parallelization is achieved based on dependency distance vector theory. For dependency vectors... If there exists k such that and Then the outer k-1 loops can be parallelized.
[0052] The theoretical speedup after parallelization is estimated using Amdahl's law: ; Where P is the proportion of the parallelizable portion and N is the number of processors.
[0053] The unified execution engine integrates an interpreter and a just-in-time (JIT) compiler to perform mixed-mode execution on the optimized intermediate representation code. Based on runtime analysis, the unified execution engine dynamically decides whether to interpret and execute code segments or trigger JIT compilation.
[0054] Specifically, the unified execution engine monitors the execution frequency and computational intensity of code segments in real time. Based on a cost-benefit model, when the predicted total cost of interpreted execution exceeds the sum of the overhead of just-in-time compilation and the cost of execution after compilation, just-in-time compilation is triggered to compile hot code into highly optimized native machine code and execute it. At the same time, the unified execution engine maintains the mapping relationship between source code and machine code to support accurate error location.
[0055] The specific details of the unified execution engine are as follows: (1) Hybrid execution model The unified execution engine adopts a hybrid model that combines interpreted execution and just-in-time compilation; it maintains an execution state machine and dynamically selects the execution strategy based on code characteristics.
[0056] (2) Just-in-Time (JIT) Compilation Triggering Mechanism JIT compilation is triggered based on a multi-factor decision model. Let the compilation decision function for code segment s be: ; in, For execution frequency; To calculate the intensity (floating-point operands / memory accesses); For code complexity; It has the potential for parallelization; These are the weight coefficients for the corresponding items.
[0057] The weight coefficients are dynamically adjusted using machine learning methods to optimize decision accuracy. In this embodiment, an online learning algorithm can be used to continuously update the decision model based on historical execution data.
[0058] (3) Runtime performance analysis and optimization The unified execution engine integrates a low-overhead performance analyzer, employing sampling-based profiling techniques; the performance counter update frequency is controlled by the following formula:
[0059] in, The maximum sampling frequency, This is the sampling rate coefficient. This refers to the frequency of code execution.
[0060] Performance data is smoothed using an exponentially weighted moving average method: ; in, It is a smoothing factor that is dynamically adjusted based on code execution characteristics.
[0061] Furthermore, in this embodiment, the memory management and data locality optimization steps are as follows: (1) Intelligent data layout optimization Optimize memory access patterns through cache-aware data layout; for different data layouts such as arrays of structures and array structures, automatically select the optimal layout based on the access pattern. Define a cache miss cost model: ; Where L represents the data layout and A represents the data access set. For the frequency of accessing 'a', Let be the missing probability of accessing a under layout L.
[0062] Then, by solving To determine the optimal data layout.
[0063] (2) Dynamic memory allocation strategy Object lifecycle analysis is used to optimize memory allocation. By constructing an object dependency graph, the system predicts the optimal allocation time and memory location for objects.
[0064] Let the object's lifecycle be The memory allocation strategy is determined by minimizing the joint optimization problem of memory fragmentation and allocation overhead: ; in, This refers to the fragment weight coefficient; This is due to memory fragmentation. Total overhead for memory allocation for the object collection obj.
[0065] The system of this invention also has a fault tolerance and recovery mechanism, namely, a transactional execution model is designed to ensure the atomicity and consistency of script execution; for simulation scripts that run for a long time, checkpoints are saved periodically, and quick recovery from the most recent checkpoint is supported.
[0066] The checkpoint interval was determined through the following optimization problem: ; Where T is the checkpoint interval, C is the checkpoint creation cost, and P is the failure rate. The optimal solution is obtained by differentiation. ; The theoretical performance analysis of the system of this invention includes time complexity analysis and space complexity analysis; The time complexity analysis process is as follows: Let the execution time of the original script be... The optimized execution time is: ; in: n is the size of the script code; m represents the intermediate size; Let S be the speedup brought about by optimization; then the total speedup is: .
[0067] (2) Space complexity analysis System memory usage mainly includes: syntax tree and intermediate representation: O(n+m); runtime data: O(d), where d is the data size; optimized data structure: O(m log m); total space complexity: O(n+m log m+d); In practical system implementation, the following engineering optimization techniques can also be adopted: (1) Delayed compilation and warm-up optimization This invention employs a layered compilation strategy, prioritizing in-depth optimization of frequently accessed code. The compilation priority is calculated using the following formula: ; in, The compilation priority of code segment s; To call the frequency factor; This is the heat accumulation factor; Optimize gain for preheating; (2) Adaptive optimization threshold The system dynamically adjusts and optimizes the thresholds based on the operating environment: ; in, For system load factor, This is the load factor adjustment coefficient; Due to memory pressure; This is the memory pressure adjustment factor; The base threshold.
[0068] In this embodiment, the present invention is implemented through a systematic workflow, covering the complete process from environment configuration and module initialization to script execution and optimization, ensuring that the intelligent script engine runs efficiently and stably in the simulation software. The implementation process mainly includes four main stages: system environment configuration, core module initialization, script processing pipeline establishment, and runtime optimization. Each stage contains detailed operation steps and configuration parameters, which together constitute a complete solution.
[0069] An optimization method for an intelligent script engine in simulation software includes the following steps: S1. System environment configuration and initialization; Integrate the dynamic link library of the script engine into the host simulation software, establish a bidirectional data communication interface, configure a compilation environment that supports C++17, and deploy the LLVM intermediate representation framework and domain-specific type system library. Then, the multi-core processor architecture and memory resources are detected, the parallel computing resource pool is configured, the memory management system is initialized, and the cache line size and prefetch strategy parameters are set. Finally, the core components such as the syntax parser runtime library, type inference engine, and optimization algorithm library are loaded, and the compatibility of each component version is verified.
[0070] S2. Core module initialization; Initialize the extended parser, load the lexical analyzer and parser, establish the semantic attribute database, and start the type inference engine; Then, load the simulation domain metadata ontology, construct the type hierarchy network, start the distributed knowledge management system, and establish a multi-level query index; Reinitialize the graph data structure of the high-level intermediate representation, configure the SSA form converter of the low-level intermediate representation, and start the loop optimizer and parallelization detector. Finally, start the interpreter and just-in-time compiler, configure the performance monitoring system, and initialize the object pool and prefetching strategy of the memory management system.
[0071] S3. Script processing pipeline establishment; First, the system receives user script input through the integrated development environment, performs lexical and syntactic analysis, and constructs an initial abstract syntax tree. Next, query the context-aware module to obtain type information and physical units, attach semantic attributes to the syntax tree nodes, and perform type consistency checks; convert the enhanced abstract syntax tree into a high-level intermediate representation, analyze operation dependencies, and then convert it into a low-level intermediate representation in preparation for optimization processing; Finally, operation fusion optimization is performed at the high-level intermediate presentation layer, and loop partitioning and automatic parallelization are applied at the low-level intermediate presentation layer to generate optimized intermediate code.
[0072] S4. Runtime execution and optimization; The performance monitoring system analyzes code characteristics and selects between interpreted execution and just-in-time (JIT) compilation execution paths based on a multi-factor decision model. It initiates LLVM optimization pipelines for hot-spot code, generating highly optimized machine code while maintaining the mapping between source code and machine code. It continuously collects runtime metrics and automatically adjusts optimization parameters through machine learning algorithms, supporting dynamic re-optimization. It provides precise error localization and semantic-level diagnostic information, and supports checkpoint setting and task recovery functions.
[0073] S5. System monitoring and maintenance; Monitor execution progress and performance metrics through visualization tools, generate optimization reports and performance analysis data; record execution trajectory and optimization decisions in detail, and support offline analysis and problem diagnosis; Adjust the compilation optimization level, parallelization strategy, and memory management parameters based on operational feedback to ensure continuous system optimization.
[0074] The advantage of this invention lies in fundamentally solving the performance bottleneck of simulation scripts. By introducing multi-layer intermediate representation and just-in-time compilation technology, this invention liberates computationally intensive script parts (such as mesh traversal and parameterized loops) from the inefficient interpreted execution mode, dynamically compiling them into highly optimized native machine code, and intelligently utilizing multi-core parallelism and vectorized computation. This enables a reduction in script execution time by orders of magnitude in scenarios requiring tens of thousands of simulation calls, such as large-scale optimization design or reliability analysis, thereby elevating the efficiency and practicality of the simulation automation process to a whole new level.
[0075] The system of this invention can directly map runtime errors back to specific lines of script source code and provide intuitive descriptions such as "the force applied to 'boundary C' in line 35 is negative, which contradicts the preset direction". This changes the predicament of users being at a loss when faced with errors such as "memory access violation", transforms the debugging process from a mentally taxing guessing job to an efficient problem localization, and greatly improves development efficiency and user experience.
[0076] This invention significantly reduces the learning curve and programming threshold for users by providing real-time and accurate code completion during the editing stage and analyzing performance bottlenecks and proposing optimization suggestions during the runtime stage. This allows engineers to focus more on the simulation logic itself in their professional field, rather than the minutiae of script implementation.
[0077] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An intelligent script engine system for simulation software, characterized in that, It includes a script parsing and semantic enhancement module, an intelligent context awareness module, a multi-layer intermediate representation and optimization module, and a unified execution engine; The script parsing and semantic enhancement module performs lexical and syntactic analysis on the input script source code to construct an initial abstract syntax tree. It also interacts with the intelligent context awareness module to query semantic information in the current simulation context and attaches the queried semantic information as annotations to the corresponding nodes of the initial abstract syntax tree to generate an enhanced abstract syntax tree. The intelligent context awareness module maintains the global state and data environment in the simulation context, forms a dynamic simulation domain metadata knowledge base, and provides real-time semantic information query services. The multi-layer intermediate representation and optimization module receives the enhanced abstract syntax tree and converts it into a multi-layer intermediate representation, and performs optimization; the multi-layer intermediate representation includes a high-level intermediate representation corresponding to simulation semantic operations and a low-level intermediate representation corresponding to numerical computation and memory access; the optimization includes operation fusion optimization based on simulation semantics performed at the high-level intermediate representation layer and loop optimization based on affine transformation theory performed at the low-level intermediate representation layer. The unified execution engine integrates an interpreter and a just-in-time (JIT) compiler, and performs mixed-mode execution on the optimized intermediate representation code. Based on runtime analysis, it dynamically decides whether to interpret and execute code segments or trigger JIT compilation to generate and execute native machine code.
2. The intelligent script engine system for simulation software according to claim 1, characterized in that, The script parsing and semantic enhancement module is based on attribute grammar theory. By querying the intelligent context awareness module, it adds semantic attributes to the identifier nodes of the initial abstract syntax tree and performs type consistency verification. The semantic attributes include type information, physical units, and numerical range constraints.
3. The intelligent script engine system for simulation software according to claim 1, characterized in that, The intelligent context-aware module can provide users' integrated development environment with context-aware intelligent code completion and semantic-based accurate error diagnosis services.
4. The intelligent script engine system for simulation software according to claim 1, characterized in that, The operation fusion optimization performed by the multi-layer intermediate representation and optimization module at the high-level intermediate representation layer includes: Analyze the data dependencies between continuous simulation operations and construct a data flow graph; Identify operation sequences that iterate over the same data set multiple times without data dependencies; The operation sequence is merged into a single traversal operation.
5. The intelligent script engine system for simulation software according to claim 1, characterized in that, The multi-layer intermediate representation and optimization module performs cyclic optimization based on affine transformation theory at the lower intermediate representation layer, including: Nested loops are modeled as polyhedral models, and the affine relationship between loop index variables and array access patterns is analyzed. Based on the analysis results, loop partitioning optimization is applied to improve cache locality, and automatic parallelization is implemented to utilize multi-core computing resources.
6. The intelligent script engine system for simulation software according to claim 1, characterized in that, In the hybrid mode execution of the unified execution engine, the unified execution engine monitors the execution frequency and computational intensity of code segments in real time. When the predicted total cost of interpreted execution exceeds the sum of the overhead of just-in-time compilation and the cost of execution after compilation, just-in-time compilation is triggered.
7. The intelligent script engine system for simulation software according to claim 1, characterized in that, The system can optimize memory access patterns through cache-aware data layout optimization and dynamic memory allocation strategies.
8. The intelligent script engine system for simulation software according to claim 1, characterized in that, The system also supports a transactional execution model, periodically saves checkpoints, and resumes execution from the most recent checkpoint in the event of a failure.
9. A method for optimizing an intelligent script engine for simulation software, characterized in that, Includes the following steps: Step S1, Script parsing and semantic enhancement: The input script source code is parsed and combined with the semantic information in the current simulation context to generate an enhanced abstract syntax tree carrying type and physical meaning; Step S2: The enhanced abstract syntax tree is converted into a multi-layer intermediate representation, and high-level optimization based on simulated semantics and low-level optimization based on computational performance are performed sequentially. The multi-layer intermediate representation includes a high-level intermediate representation and a low-level intermediate representation. The high-level optimization includes operation fusion optimization based on data dependencies, and the low-level optimization includes loop optimization based on affine transformation theory. Step S3: A hybrid execution mode is adopted, and the optimized intermediate representation code is interpreted or compiled and executed on the fly based on runtime analysis and dynamic decision-making.