Method for locating fault of CAE software based on field perception and hierarchical fusion

CN122985648APending Publication Date: 2026-10-27DALIAN UNIV OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202611478130.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-22
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0008]本发明的目的在于提供一种基于领域感知与层次融合的CAE软件故障定位方法,用于解决现有方法难以捕获CAE软件复杂故障模式及多源异构特征难以有效融合的问题

Benefits of technology

[0079](1)本发明针对数值计算、网格处理、有限元建模、并行通信和求解器五类CAE核心计算过程,引入CAE领域专用变异操作,并构建计算复杂度特征和CAE语义相似度特征,与频谱、代码复杂度和文本相似度信息相结合,增强对CAE软件领域故障模式的描述能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985648A_ABST
    Figure CN122985648A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of software testing, and particularly relates to a CAE software fault positioning method based on field perception and hierarchical fusion, comprising the following steps: obtaining source code, test cases, test execution information and historical fault file information of computer aided engineering (CAE) software; constructing field perception fault positioning features for CAE computing processes; performing dimension balance mapping on six groups of fault positioning features respectively, and converting different source features to a unified hidden space; performing local fusion on each group of features by using an intra-group attention mechanism; performing hierarchical branch fusion on dynamic execution features and static structure features; performing global attention fusion on dynamic execution branches and static structure branches; training a hierarchical attention fusion multi-layer perception machine model; and calculating fault probabilities of candidate program files and generating fault positioning results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of software testing technology, and in particular relates to a CAE software fault location method based on domain awareness and hierarchical fusion. Background Technology

[0002] With the rapid development of Computer-Aided Engineering (CAE) technology, CAE software has been widely used in aerospace, automotive manufacturing, and electronic engineering fields, leading to a continuous increase in its code size and computational complexity. CAE software typically involves a large amount of numerical computation, iterative solutions, and cross-module data interaction. The impact of faults may gradually propagate during program execution, increasing the difficulty of fault analysis and code localization. Therefore, how to quickly and accurately locate faulty program entities in CAE software has become an important issue in the field of software testing.

[0003] To reduce the cost of manual troubleshooting, researchers have proposed an automated fault location technique. This technique analyzes test execution results, program coverage information, mutation test results, software history information, and source code characteristics to calculate the fault suspicion level of program files or executable statements. Candidate program entities are then ranked according to their suspicion level, thereby narrowing down the scope of manual inspection and improving the efficiency of software fault diagnosis. Currently, relevant methods include spectrum-based, mutation-based, history-based, program model-based, and learning-based fault location methods.

[0004] Existing invention patents, such as a fault location method based on deep neural networks (application number 201710494488.1), a hybrid software error location method and system based on RankNet (application number 202010350329.6), and a software fault location method based on network spectrum (application number 202111573144.2), respectively locate faults by learning test coverage information through deep neural networks, fusing code text features and numerical features, and combining spectrum and software structure information. These methods can improve the identification ability of faulty program entities in general-purpose software, but they mainly focus on analyzing the execution, structure, and text information of general-purpose software, lacking a specific description of the computational characteristics of CAE software.

[0005] CAE software exhibits distinct domain-specific computational characteristics. Its operation involves multiple functional modules, including numerical computation, mesh processing, finite element modeling, parallel communication, and solvers, and includes numerous iterative solutions and time-step progression processes. Faults may accumulate gradually during the computation process, exhibiting characteristics of low-frequency triggering, cross-file propagation, and cross-module propagation. Existing fault location methods, which utilize general program characteristics, are insufficient to fully describe the aforementioned CAE domain-specific computational behavior and related fault modes, thus limiting the ability to identify and locate CAE software faults.

[0006] Meanwhile, learning-based fault localization methods typically require the comprehensive use of multiple features, including spectral density, mutation testing, code complexity, and text similarity. Different types of features exhibit significant differences in dimensionality, numerical range, data distribution, semantics, and sparsity. Directly concatenating different types of features can lead to high-dimensional features dominating the model training process, hindering the full utilization of lower-dimensional features closely related to the CAE domain. Furthermore, irrelevant information from features from different sources can interfere with the model. Therefore, existing feature fusion methods struggle to fully leverage multi-source, heterogeneous fault localization information.

[0007] As can be seen from the existing technologies described above, current software fault location methods struggle to simultaneously address the issues of insufficient fault feature descriptions and effective fusion of multi-source heterogeneous features in the CAE domain. Therefore, a method is needed that can combine computational features from the CAE domain and effectively fuse multi-source heterogeneous fault location information to improve the accuracy of CAE software fault location. Summary of the Invention

[0008] The purpose of this invention is to provide a CAE software fault localization method based on domain awareness and hierarchical fusion, which addresses the problems of existing methods failing to capture complex fault modes in CAE software and effectively fusing multi-source heterogeneous features. This invention constructs domain-aware fault localization features for the main computational processes of CAE, and then uses a hierarchical attention fusion model to fuse multi-source features step-by-step, calculating the fault probability of candidate program files to achieve CAE software fault localization.

[0009] To achieve the above objectives, the technical solution of the present invention is as follows:

[0010] A CAE software fault localization method based on domain awareness and hierarchical fusion, the specific steps of which are as follows:

[0011] Step 1: Obtain the source code, test cases, test execution information, and historical fault file information of the Computer-Aided Engineering (CAE) software.

[0012] Obtain the source code and test cases corresponding to the historical fault versions and the version with the fault to be located in the CAE software, and use the source code from each fault version as candidate program files. The source code information includes the source code content and file path, and further extract function, variable, call relationship and comment information from the source code, which will be used to construct code complexity features, computational complexity features, text similarity features and CAE semantic similarity features.

[0013] Run the test cases corresponding to each faulty version separately. Based on the test execution results, divide the test cases into pass tests and fail tests, and record the test name, test code, test execution result, failure information, and program coverage information of each candidate program file as test execution information, which will be used to build spectral features, text similarity features, and CAE semantic similarity features in the future.

[0014] During the model training phase, historical fault file information is obtained, including known fault program files in historical fault versions, and supervision labels for candidate program files are generated accordingly for subsequent model training; during the fault localization phase, the fault version to be localized is used for subsequent fault localization.

[0015] Step 2: Construct domain-aware fault location features for CAE computing processes.

[0016] For five types of CAE computation processes—numerical computation, mesh processing, finite element modeling, parallel communication, and solvers—based on the general fault location features of spectrum, code complexity, and text similarity, CAE domain-specific construction is carried out for mutation analysis, computational complexity analysis, and semantic similarity analysis, forming six sets of fault location features: spectrum features, mutation features, text similarity features, CAE semantic similarity features, code complexity features, and computational complexity features.

[0017] The spectral characteristics are then subjected to pass and fail tests, respectively. For candidate program files... Statistical coverage information, including the number of times coverage was achieved through testing. Number of failed test coverage Number of times the test was not covered and number of failed tests not covered Different methods of calculating suspicion were used to calculate the suspicion of candidate program files based on the aforementioned coverage statistics. The multiple suspicion values ​​obtained together constituted the multidimensional program spectrum features. .

[0018] The mutation feature involves performing program mutation operations on candidate program files and running the mutated program. The mutation suspicion level is then constructed by comparing the test execution results before and after mutation. The program mutation operations include general mutation operations and CAE-specific mutation operations.

[0019] For each mutated program, test cases are run and test execution results and failure information are recorded, thus constructing three test result representations: In the first representation, test results are distinguished as pass and fail; in the second representation, passable tests are still recorded as pass, while failed tests are further distinguished based on their exception type; in the third representation, passable tests are still recorded as pass, while failed tests are further distinguished based on the exception type and corresponding exception information. Multiple mutation suspicion calculation methods are employed, calculated based on the three test result representations respectively, to obtain multidimensional mutation features. The mutation features corresponding to the three test result representations are represented as follows: The three together constitute the variant feature group. .

[0020] The text similarity features acquire three types of query information from failed tests: test name, test code, and failure information. They also aggregate five types of text fields from the candidate program file range: fully qualified test name or path, reference type or class, called method or function, referenced variable, and comments. Term frequency-inverse document frequency (TF-IDF) is used to represent the query information and code text fields, and the similarity between each query information field and each code text field is calculated to form a multi-dimensional text similarity feature. .

[0021] The CAE semantic similarity features extract domain semantic information from candidate program files according to five types of CAE calculation processes: numerical computation semantics, including matrix operations, vector operations, floating-point expressions, floating-point precision, and numerical anomaly information; mesh processing semantics, including mesh type, mesh cells, cell size, boundary markers, and mesh quality information; finite element modeling semantics, including finite element type, function space, degrees of freedom, boundary conditions, and load information; parallel communication semantics, including message passing interface calls, process numbers, process mappings, communication topology, and synchronization operation information; and solver semantics, including solver type, preconditioner, parameter settings, residuals, tolerances, iteration counts, and convergence status information. The similarity between these five types of domain semantic information and the test name, test code, and failure information of failed tests is calculated to form multi-dimensional CAE semantic similarity features. .

[0022] The code complexity features are constructed by performing static source code analysis on candidate program files, and considering three aspects: code size and structure statistics, control structure complexity, and Halstead complexity. .

[0023] The computational complexity characteristics described above take into account the different program behaviors at each computational stage of CAE software. They involve statistically analyzing the computational operations of candidate program files in five computational processes: numerical computation, mesh processing, finite element modeling, parallel communication, and solver operations, thus forming a multi-dimensional computational complexity characteristic. .

[0024] The six sets of fault location features The unified representation is:

[0025] (1)

[0026] in, Indicates spectral characteristics, Indicates the characteristics of variation. Representing text similarity features, Represents the semantic similarity features of CAE. Indicates code complexity characteristics. This represents the computational complexity characteristic. For the ... Feature groups ,in, Indicates the first The number of sub-features or sub-feature blocks contained in a feature group. .

[0027] Step 3: Perform dimensional balance mapping on the six sets of fault location features respectively, and transform the features from different sources into a unified hidden space.

[0028] Since the six sets of fault location features differ in terms of dimension, numerical range, data distribution, and sparsity, an independent fully connected mapping layer is set for each feature group.

[0029] For the The first feature group Sub-features or sub-feature blocks The mapping result is:

[0030] (2)

[0031] in, Indicates the first The mapped first feature group One hidden feature, and They represent the first The first feature group The mapping weight matrix and bias of each sub-feature or sub-feature block The activation function is represented by the Modified Linear Unit (ReLU) function, which is preferred. After mapping, input features of different dimensions are transformed to the same dimension. The hidden space. For the variant features , and Each of the three test results was transformed using independent mapping parameters to preserve the variation information.

[0032] Step 4: Use the intra-group attention mechanism to locally fuse the features of each group.

[0033] Regarding the first The mapped first feature group Each hidden feature represents Calculate the key vector and value vector respectively:

[0034] (3)

[0035] in, Indicates the first The mapped first feature group The key vector of each hidden feature. Indicates the first The mapped first feature group A vector of values ​​for each hidden feature. and They represent the first The key mapping matrix and value mapping matrix corresponding to each feature group.

[0036] According to the Learnable query vectors corresponding to each feature set Calculate the first Attention weights for individual features or feature blocks:

[0037] (4)

[0038] in, Indicates the first In the feature group, the first Attention weights corresponding to each sub-feature or sub-feature block Indicates the first In the feature group, the first The key vectors corresponding to the hidden features This represents the summation index in the attention weight normalization calculation. This represents the natural exponential function. Indicates the first The number of sub-features or sub-feature blocks contained in a feature group. This represents the dimension of the attention space.

[0039] The group features are weighted and fused based on the attention weights of sub-features or sub-feature blocks to obtain the first... Feature representations corresponding to each feature group:

[0040] (5)

[0041] in, Indicates the first The feature representation corresponding to each feature group and These represent the weight matrix and bias of the attention fusion layer within the group, respectively.

[0042] The spectral feature representations are obtained using formulas (3) to (5). , representation of variation characteristics Text similarity feature representation CAE semantic similarity feature representation Code complexity feature representation and computational complexity feature representation .

[0043] Step 5: Perform hierarchical branching fusion of dynamic execution features and static structural features.

[0044] Representing spectral features Representation of variation characteristics Perform attention fusion to obtain a dynamic execution branch representation:

[0045] (6)

[0046] in, This indicates a dynamic execution branch representation. This indicates the attention fusion operation for dynamically executed branches.

[0047] For static structural features, text similarity features are represented CAE semantic similarity feature representation Attention fusion is performed to obtain semantic sub-branch representations of the text:

[0048] (7)

[0049] in, This represents the semantic sub-branch representation of the text. This represents the attention fusion operation for semantic sub-branches of the text.

[0050] Representing code complexity characteristics Representation of computational complexity features Perform attention fusion to obtain a sub-branch representation of complexity:

[0051] (8)

[0052] in, This represents the complexity of sub-branch representations. This represents the attention fusion operation for sub-branches with varying complexity.

[0053] Further representation of text semantic sub-branches and complexity sub-branch representation Attention fusion is performed to obtain a static structural branch representation:

[0054] (9)

[0055] in, This represents a static structure branch representation. This represents the attention fusion operation for static structure branches.

[0056] All the above attention fusion operations use the attention calculation methods shown in formulas (3) to (5). Specifically, in formula (6), the spectral feature representation and the mutation feature representation are used as two input features. The key vector and value vector are calculated according to formula (3) respectively. The attention weights of the two input features are calculated according to formula (4), and weighted fusion is performed according to formula (5) to obtain the dynamic execution branch representation. In formula (7), the text similarity feature representation and the CAE semantic similarity feature representation are used as two input features, and the text semantic sub-branch representation is obtained in the same way. In formula (8), the code complexity feature representation and the computational complexity feature representation are used as two input features, and the complexity sub-branch representation is obtained in the same way. In formula (9), the text semantic sub-branch representation and the complexity sub-branch representation are used as two input features, and the static structure branch representation is obtained in the same way. Each of the above attention fusion operations uses independent model parameters. Thus, the dynamic execution branch representation is obtained. and static structure branch representation This is used for subsequent global attention fusion.

[0057] Step 6: Perform global attention fusion on dynamic execution branches and static structure branches.

[0058] Using attention mechanisms to represent dynamic execution branches and static structure branch representation Perform global fusion. For Calculate the key vector and value vector respectively:

[0059] (10)

[0060] in, Indicates the first The key vectors corresponding to each branch Indicates the first The value vector corresponding to each branch. and These represent the key mapping matrix and value mapping matrix of the global attention fusion module, respectively. Indicates the first The feature representation of each branch.

[0061] Based on globally learnable query vectors Calculate the attention weights for dynamic execution branches and static structure branches. :

[0062] (11)

[0063] in, This represents a globally learnable query vector. Indicates the first Each branch corresponds to a global attention weight. The two branches are weighted and fused based on these attention weights, and the final fault feature representation is obtained through a fully connected layer. :

[0064] (12)

[0065] in, This represents the global fusion feature representation obtained by weighting and fusing the value vectors of dynamic execution branches and static structure branches according to attention weights. and These represent the weight matrix and bias of the global fusion layer, respectively. This represents the final fault characteristics corresponding to the candidate program file.

[0066] Step 7: Train the hierarchical attention fusion multilayer perceptron model.

[0067] Historical fault versions with known fault locations are used as training data, and whether a candidate program file is a fault file is used as a supervision label.

[0068] A hierarchical attention fusion multilayer perceptron model, denoted as HAF-MLP, is constructed. HAF-MLP includes step 3 (dimensionality balancing mapping), step 4 (intra-group attention fusion), step 5 (hierarchical branch fusion), and step 6 (global attention fusion), with a final output layer defining the probabilities of belonging to faulty files and those belonging to non-faulty files. The HAF-MLP model is trained using the cross-entropy loss function. For files containing... A dataset of training samples, cross-entropy loss Represented as:

[0069] (13)

[0070] in, Indicates the first The true label of each candidate program file; when When a faulty file is displayed, This indicates a non-faulty file; and These represent the model's predicted first and second halves of the series. The probability that a candidate program file is a faulty file and the probability that it is a non-faulty file.

[0071] The parameters of the dimension balancing mapping layer, intra-group attention layer, branch-level attention layer, global attention layer, and output layer are updated iteratively by optimizing the algorithm.

[0072] Step 8: Calculate the failure probability of the candidate program files and generate the failure location results.

[0073] The six sets of fault location features from each candidate program file in the version to be located are input into the trained HAF-MLP model to calculate the final fault feature representation corresponding to the candidate program file. The classification probability is calculated using the Softmax function. :

[0074] (14)

[0075] in, and These represent the weight matrix and bias of the output layer, respectively. This indicates the probability that a candidate program file is a faulty file. This indicates the probability that a candidate program file is a non-faulty file.

[0076] Will The candidate program files are evaluated based on their suspected fault levels, and all candidate program files are sorted from highest to lowest according to their suspected fault levels to generate file-level fault location results.

[0077] When statement-level fault location results are needed, the fault suspicion level of each candidate program file is mapped to the executable statement in the corresponding file. That is, the executable statement in the same file inherits the fault suspicion level of that file. Then, all executable statements are sorted from high to low according to the fault suspicion level to generate statement-level fault location results.

[0078] The beneficial effects of this invention are:

[0079] (1) This invention targets five core CAE computation processes: numerical computation, mesh processing, finite element modeling, parallel communication and solver. It introduces CAE-specific mutation operations and constructs computational complexity features and CAE semantic similarity features. Combined with spectrum, code complexity and text similarity information, it enhances the ability to describe failure modes in the CAE software field.

[0080] (2) In view of the problem that different fault location features have differences in dimension, distribution, semantics and sparsity, the present invention adopts a hierarchical structure of dimension balance mapping, intra-group attention fusion, dynamic and static branch-level attention fusion and global attention fusion to improve the fusion capability of multi-source heterogeneous fault location features.

[0081] (3) This invention comprehensively utilizes program dynamic execution information, source code structure information and CAE domain information to calculate the fault probability of candidate program files and generate a fault suspicion ranking, which can realize file-level and statement-level fault location respectively, and improve the accuracy of CAE software fault location. Attached Figure Description

[0082] Figure 1 This is a schematic diagram of the CAE software fault location method based on the fusion of domain awareness features and hierarchical attention according to the present invention.

[0083] Figure 2 This is a schematic diagram of the hierarchical attention fusion multilayer perceptron model (HAF-MLP) in this invention. Detailed Implementation

[0084] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings and technical solutions.

[0085] This embodiment uses the open-source finite element CAE software MFEM as an example to illustrate the method of the present invention, but the present invention is not limited to the following embodiment.

[0086] This embodiment runs on a Linux server, and the server configuration is shown in Table 1.

[0087] Table 1 Linux Server Configuration Information

[0088] This embodiment uses real-world fault data from MFEM for fault localization. MFEM is developed in C++, with a code size of approximately 188 KLOC, containing 1336 test cases and 34 verified real-world fault versions. For each fault version, file-level fault localization is first performed, and statement-level fault localization results are generated based on the file-level fault suspicion level.

[0089] like Figure 1As shown, a CAE software fault localization method based on domain awareness and hierarchical fusion is described, with the following specific steps:

[0090] Step 1: Load the faulty version of the CAE software and execute the test cases.

[0091] Specifically, for faulty versions of MFEM, the corresponding source code and test cases are detected, and the source code files in the version are used as candidate program files. The corresponding test cases are run, and the test cases are divided into pass tests and fail tests according to the test execution results. The test name, test code, pass or fail result, failure information, and coverage information of each candidate program file are recorded for each test case.

[0092] Model training employs leave-one-out-of-fault cross-validation. For the 34 fault versions included in MFEM, one fault version is selected as the version to be located each time, and the remaining 33 fault versions are used for model training. The known fault program files in the training versions are recorded as model training labels.

[0093] The above process yields candidate program files, source code information, test execution results, program coverage information, and historical fault file information, which are used to construct six sets of fault location features for subsequent candidate program files.

[0094] Step 2: Construct six sets of fault location features for candidate program files.

[0095] For five types of CAE computation processes—numerical computation, mesh processing, finite element modeling, parallel communication, and solvers—based on the general fault location features of spectrum, code complexity, and text similarity, CAE domain-specific construction is carried out for mutation analysis, computational complexity analysis, and semantic similarity analysis, forming six sets of fault location features: spectrum features, mutation features, text similarity features, CAE semantic similarity features, code complexity features, and computational complexity features, as shown in Table 2.

[0096] Table 2. Fault Location Characteristics in Domain Awareness

[0097]

[0098] The spectral characteristics are then subjected to pass and fail tests, respectively. For candidate program files... Count the number of times the test coverage is passed. Number of failed test coverage Number of times the test was not covered and number of failed tests not covered Using 38 methods for calculating suspicion in existing program spectrum fault location methods, the suspicion of candidate program files is calculated based on the aforementioned coverage statistics. The resulting 38 suspicion values ​​together constitute 38-dimensional program spectrum features.

[0099] The mutation feature involves performing a program mutation operation on the candidate program file and running the mutated program. The mutation suspicion level is constructed by comparing the test execution results before and after mutation. The program mutation operation includes general mutation operations and CAE-specific mutation operations. This invention sets up 12 CAE-specific mutation operators for five types of CAE calculation processes: numerical computation, mesh processing, finite element modeling, parallel communication, and solvers, as shown in Table 3.

[0100] Table 3. CAE-specific mutation operators

[0101]

[0102] For each mutation program, mutation features are constructed based on three types of test results: the first type is test pass or failure; the second type is the anomaly type; and the third type is the anomaly type and anomaly information. Thirty-four Metallaxis mutation suspicion calculation methods based on different spectral formulas are used, along with the MUSE mutation suspicion calculation method, resulting in a total of 35 mutation suspicion calculation methods. After calculation for each of the three types of test results, 35 × 3 = 105 dimensions of mutation features are obtained. The mutation features corresponding to the three types of test results are represented as follows: The three together constitute the variant feature group. .

[0103] The text similarity feature extracts three types of query information from failed tests: test name, test code, and failure information. It also aggregates five types of text fields from the candidate program file range: fully qualified test name or path, referenced type or class, called method or function, referenced variable, and comments. Term frequency-inverse document frequency (TF-IDF) is used to represent the query information and code text fields, and the similarity between each query information and each code text field is calculated. The three types of query information and the five types of code text fields combine to form a 3×5=15-dimensional text similarity feature.

[0104] The CAE semantic similarity features are derived from candidate program files according to five categories of CAE computation processes: numerical computation semantics, including matrix operations, vector operations, floating-point expressions, floating-point precision, and numerical anomaly information; mesh processing semantics, including mesh type, mesh cells, cell size, boundary markers, and mesh quality information; finite element modeling semantics, including finite element type, function space, degrees of freedom, boundary conditions, and load information; parallel communication semantics, including message passing interface calls, process numbers, process mappings, communication topology, and synchronization operation information; and solver semantics, including solver type, preconditioners, parameter settings, residuals, tolerances, iteration counts, and convergence status information. The similarity between these five categories of domain semantic information and the test name, test code, and failure information of failed tests is calculated, resulting in a 5×3=15-dimensional CAE semantic similarity feature.

[0105] The code complexity features are constructed by performing static source code analysis on candidate program files, and constructing 21-dimensional code complexity features from three aspects: code size and structure statistics, control structure complexity, and Halstead complexity, as shown in Table 4.

[0106] Table 4 Code Complexity Characteristics

[0107]

[0108] The computational complexity features, taking into account the different program behaviors at each computational stage of CAE software, statistically analyze the computational operations of candidate program files in five computational processes: numerical computation, mesh processing, finite element modeling, parallel communication, and solver, forming a 13-dimensional computational complexity feature, as shown in Table 5. Among these, the Message Passing Interface (MPI) is used to describe the communication operations between parallel processes.

[0109] Table 5. CAE Computational Complexity Characteristics

[0110]

[0111] First, based on the coverage results of candidate program files in the passing and failing tests, 38-dimensional spectral features are calculated. Then, mutation testing is performed on the MFEM source code. This embodiment uses 12 general mutation operations provided by MuCPP, including binary arithmetic operation replacement, unary arithmetic operation replacement, increment / decrement arithmetic operation replacement, unary arithmetic operation insertion, increment / decrement operation insertion, increment / decrement operation deletion, relational operation replacement, conditional operation replacement, conditional operation insertion, conditional operation deletion, logical operation replacement, and compound assignment operation replacement. Twelve CAE-specific mutation operations are also used as shown in Table 3. For the three types of test results, 34 Metallaxis mutation suspicion calculation methods and 1 MUSE mutation suspicion calculation method are used respectively, forming 105-dimensional mutation features.

[0112] As shown in Table 4, 21-dimensional code complexity features were extracted, and as shown in Table 5, 13-dimensional CAE computational complexity features were extracted. The test names, test codes, and failure information of failed tests were obtained, and TF-IDF similarity calculations were performed with the fully qualified names or paths, reference types or classes, called methods or functions, referenced variables, and program comments of the candidate program files, respectively, forming 15-dimensional text similarity features. Furthermore, five categories of CAE domain semantic information—numerical computation, mesh processing, finite element modeling, parallel communication, and solvers—were extracted, and similarity calculations were performed with the test names, test codes, and failure information of failed tests, respectively, forming 15-dimensional CAE semantic similarity features.

[0113] Therefore, each candidate program file is formed Dimensional original fault location characteristics.

[0114] Step 3: Perform dimensional balance mapping on the six sets of fault location features.

[0115] The 207-dimensional original features were divided into six feature groups based on spectrum, mutation, text similarity, CAE semantic similarity, code complexity, and computational complexity. Each feature group was then input into its corresponding fully connected mapping layer according to formula (2), and the ReLU function was used to transform the original features of different dimensions into a unified hidden space. For the mutation features... , and Each feature is transformed using independent mapping parameters.

[0116] Step 4: Perform hierarchical attention feature fusion.

[0117] First, intra-group attention fusion is performed on the six groups of fault location features according to formulas (3) to (5) to obtain six group-level feature representations: spectrum, variation, text similarity, CAE semantic similarity, code complexity, and computational complexity.

[0118] Subsequently, branch-level attention fusion is performed according to formulas (6) to (9). Specifically, according to formula (6), the spectral feature representation and the mutation feature representation are fused to obtain the dynamic execution branch representation; according to formula (7), the text similarity feature representation and the CAE semantic similarity feature representation are fused to obtain the text semantic sub-branch representation; according to formula (8), the code complexity feature representation and the computational complexity feature representation are fused to obtain the complexity sub-branch representation; and according to formula (9), the text semantic sub-branch representation and the complexity sub-branch representation are fused to obtain the static structure branch representation.

[0119] Finally, according to formulas (10) to (12), global attention fusion is performed on the dynamic execution branch representation and the static structure branch representation to obtain the final fault feature representation of the candidate program file.

[0120] Step 5: Train the HAF-MLP fault location model.

[0121] The known faulty program files in the training faulty version are marked as faulty files, the remaining candidate program files are marked as non-faulty files, and the HAF-MLP model is trained using the cross-entropy loss shown in formula (13).

[0122] This embodiment uses the Adam optimizer, with an initial learning rate set to... The batch size was set to 256, and the number of training epochs was set to 50. To reduce model overfitting, Dropout with a ratio of 0.3 was applied between network layers, and... L2 weight decay.

[0123] Step 6: Calculate the fault probability of each candidate program file in the fault to be located.

[0124] For the faulty versions left to be located in step 1, six sets of fault location features are constructed according to step 2, and the dimensionality balancing mapping and hierarchical attention feature fusion described in steps 3 and 4 are executed sequentially. According to formula (14), the probability that the candidate program file belongs to the faulty file is output by the Softmax function. and the probability of belonging to a non-faulty file .Will The degree of suspicion of failure in the current candidate program file.

[0125] Step 7: Generate a CAE software fault location list.

[0126] Calculate the fault suspicion level of all candidate program files in the version to be located, and sort them from highest to lowest suspicion level. First, output a file-level fault location list; when statement-level results are needed, map the file fault suspicion level to the executable statements in the corresponding files, and then generate a statement-level list.

[0127] Step 8: Statistical analysis of fault location results.

[0128] In this embodiment, the following is adopted: The mean fault entity ranking (MAR) and the first mean fault ranking (MFR) are used to evaluate the fault location results.

[0129] in, This indicates that the actual faulty program entity is located before the fault location list. The number of fault versions at each position; MAR represents the average ranking of the actual faulty program entity in each fault version; MFR represents the average ranking of the highest-ranking actual faulty program entity in each fault version. The larger the value, the better the fault location effect; the smaller the MAR and MFR values, the higher the position of the faulty program entity in the sorting list.

[0130] After completing the leave-one-out-of-fault version experiment on 34 real fault versions of MFEM, in statement-level fault localization, , , and Faults were located at levels 0, 2, 4, and 7 respectively, with a MAR of 247.16 and an MFR of 242.32. In file-level fault location... , , and Faults were located at 4, 10, 12 and 14 respectively, with MAR of 53.23 and MFR of 34.64.

[0131] This invention constructs domain-aware fault location features for the CAE calculation process and uses intra-group, branch-level, and global-level attention mechanisms to fuse multi-source heterogeneous features, thereby calculating and ranking the fault probabilities of candidate program files and completing automatic fault location for CAE software.

Claims

1. A CAE software fault localization method based on domain awareness and hierarchical fusion, characterized in that, The specific steps are as follows: Step 1: Obtain the source code, test cases, test execution information, and historical fault file information of the Computer-Aided Engineering (CAE) software; Step 2: Construct domain-aware fault location features for the CAE computing process; For five types of CAE computation processes—numerical computation, mesh processing, finite element modeling, parallel communication, and solvers—based on the general fault location features of spectrum, code complexity, and text similarity, CAE domain-specific construction is carried out for mutation analysis, computational complexity analysis, and semantic similarity analysis, forming six sets of fault location features: spectrum features, mutation features, text similarity features, CAE semantic similarity features, code complexity features, and computational complexity features. Step 3: Perform dimensionality balancing mapping on the six sets of fault location features respectively, and transform features from different sources into a unified hidden space; Step 4: Utilize intra-group attention mechanism to locally fuse features from each group; Step 5: Perform hierarchical branching fusion of dynamic execution features and static structural features; Step 6: Perform global attention fusion on dynamic execution branches and static structure branches; Step 7: Train the hierarchical attention fusion multilayer perceptron model; Historical fault versions with known fault locations are used as training data, and whether the candidate program file is a fault file is used as a supervision label. A hierarchical attention fusion multilayer perceptron model, denoted as HAF-MLP, is constructed. The HAF-MLP includes the dimension balancing mapping in step 3, the intra-group attention fusion in step 4, the hierarchical branch fusion in step 5, and the global attention fusion in step 6. Finally, an output layer is set up to output the probability of belonging to a faulty file and the probability of belonging to a non-faulty file. Step 8: Calculate the failure probability of the candidate program files and generate the failure location results.

2. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 1 is as follows: Obtain the source code and test cases corresponding to the historical fault versions and the fault versions to be located in the CAE software, and use the source code in each fault version as candidate program files. The source code information includes the source code content and file path, and further extracts function, variable, call relationship and comment information from the source code, which is used to construct code complexity features, computational complexity features, text similarity features and CAE semantic similarity features; Run the test cases corresponding to each faulty version separately. Based on the test execution results, divide the test cases into pass tests and fail tests, and record the test name, test code, test execution result, failure information, and program coverage information for each candidate program file as test execution information, which will be used to build spectral features, text similarity features, and CAE semantic similarity features in the future. During the model training phase, historical fault file information is obtained, including known fault program files in historical fault versions, and supervision labels for candidate program files are generated accordingly for subsequent model training. During the fault location phase, the version of the fault to be located will be used for subsequent fault location.

3. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 2 is as follows: The spectral characteristics were subjected to pass and fail tests, respectively; for candidate program files... Statistical coverage information, including the number of times coverage was achieved through testing. Number of failed test coverage Number of times the test was not covered and number of failed tests not covered Different methods of calculating suspicion were used to calculate the suspicion of candidate program files based on the aforementioned coverage statistics. The resulting multiple suspicion values ​​together constituted the multidimensional program spectrum features. ; The mutation feature involves performing program mutation operations on candidate program files and running the mutated program. The mutation suspicion level is constructed by comparing the test execution results before and after mutation. The program mutation operations include general mutation operations and CAE domain mutation operations. For each mutated program, test cases are run and test execution results and failure information are recorded, thus constructing three test result representations: In the first representation, test results are distinguished as pass and fail; in the second representation, passable tests are still recorded as pass, while failed tests are further distinguished based on their exception type; in the third representation, passable tests are still recorded as pass, while failed tests are further distinguished based on the exception type and corresponding exception information. Multiple mutation suspicion calculation methods are used, and calculations are performed based on the three test result representations to obtain multidimensional mutation features; the mutation features corresponding to the three test result representations are respectively expressed as... The three together constitute the variant feature group. ; The text similarity feature obtains three types of query information from failed tests: test name, test code, and failure information. It also aggregates five types of text fields from the candidate program file range: fully qualified test name or path, reference type or class, called method or function, referenced variable, and comments. The query information and code text fields are represented using term frequency-inverse document frequency, and the similarity between each query information and each code text field is calculated to form a multi-dimensional text similarity feature. ; The CAE semantic similarity features extract domain semantic information from candidate program files according to five types of CAE calculation processes: numerical calculation semantics includes matrix operations, vector operations, floating-point expressions, floating-point precision, and numerical anomaly information; mesh processing semantics includes mesh type, mesh cell, cell size, boundary markers, and mesh quality information. Finite element modeling semantics includes finite element type, function space, degrees of freedom, boundary conditions, and load information; parallel communication semantics includes message passing interface calls, process numbering, process mapping, communication topology, and synchronization operation information; solver semantics includes solver type, preconditioner, parameter settings, residuals, tolerances, number of iterations, and convergence state information. The similarity between these five domain semantic information and the test names, test codes, and failure information of failed tests is calculated to form a multi-dimensional CAE semantic similarity feature. ; The code complexity features are constructed by performing static source code analysis on candidate program files, and considering three aspects: code size and structure statistics, control structure complexity, and Halstead complexity. ; The computational complexity characteristics described above take into account the different program behaviors at each computational stage of CAE software. They involve statistically analyzing the computational operations of candidate program files in five computational processes: numerical computation, mesh processing, finite element modeling, parallel communication, and solver operations, thus forming a multi-dimensional computational complexity characteristic. ; The six sets of fault location features The unified representation is: (1) For the Feature groups ,in, Indicates the first The number of sub-features or sub-feature blocks contained in a feature group. .

4. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 3 is as follows: Set up an independent fully connected mapping layer for each feature group; For the The first feature group Sub-features or sub-feature blocks The mapping result is: (2) in, Indicates the first The mapped first feature group One hidden feature, and They represent the first The first feature group The mapping weight matrix and bias of each sub-feature or sub-feature block This represents the activation function; after mapping, input features of different dimensions are transformed to the same dimension. The hidden space; for the variant features , and Each of the three test results was transformed using independent mapping parameters to preserve the variation information.

5. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 4 is as follows: Regarding the first The mapped first feature group Each hidden feature represents Calculate the key vector and value vector respectively: (3) in, Indicates the first The mapped first feature group The key vector of each hidden feature. Indicates the first The mapped first feature group A vector of values ​​for each hidden feature. and They represent the first Key mapping matrix and value mapping matrix corresponding to each feature group; According to the Learnable query vectors corresponding to each feature set Calculate the first Attention weights for individual features or feature blocks: (4) in, Indicates the first In the feature group, the first Attention weights corresponding to each sub-feature or sub-feature block Indicates the first In the feature group, the th The key vectors corresponding to the hidden features This represents the summation index in the attention weight normalization calculation. This represents the natural exponential function. Indicates the first The number of sub-features or sub-feature blocks contained in a feature group. Indicates the dimension of attention space; The group features are weighted and fused based on the attention weights of sub-features or sub-feature blocks to obtain the first... Feature representations corresponding to each feature group: (5) in, Indicates the first The feature representation corresponding to each feature group and These represent the weight matrix and bias of the attention fusion layer within the group, respectively; The spectral feature representations are obtained using formulas (3) to (5). , representation of variation characteristics Text similarity feature representation CAE semantic similarity feature representation Code complexity feature representation and computational complexity feature representation .

6. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 5 is as follows: Representing spectral features Representation of variation characteristics Perform attention fusion to obtain a dynamic execution branch representation: (6) in, This indicates a dynamic execution branch representation. This indicates an attention fusion operation for dynamically executing branches; For static structural features, text similarity features are represented CAE semantic similarity feature representation Attention fusion is performed to obtain semantic sub-branch representations of the text: (7) in, This represents the semantic sub-branch representation of the text. This represents the attention fusion operation for semantic sub-branches of the text; Representing code complexity characteristics Representation of computational complexity features Perform attention fusion to obtain a sub-branch representation of complexity: (8) in, The complexity of the sub-branch representation is represented. Attention fusion operation representing the complexity sub-branch; Further representation of text semantic sub-branches and complexity sub-branch representation Attention fusion is performed to obtain a static structural branch representation: (9) in, This represents a static structure branch representation. This represents the attention fusion operation for static structure branches.

7. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 6, characterized in that, Each attention fusion operation adopts the attention calculation method shown in formulas (3) to (5); specifically, in formula (6), the spectral feature representation and the variant feature representation are used as two input features, the key vector and value vector are calculated according to formula (3) respectively, the attention weights of the two input features are calculated according to formula (4), and weighted fusion is performed according to formula (5) to obtain the dynamic execution branch representation; In formula (7), the text similarity feature representation and the CAE semantic similarity feature representation are used as two input features, and the text semantic sub-branch representation is obtained in the same way; in formula (8), the code complexity feature representation and the computational complexity feature representation are used as two input features, and the complexity sub-branch representation is obtained in the same way; in formula (9), the text semantic sub-branch representation and the complexity sub-branch representation are used as two input features, and the static structure branch representation is obtained in the same way; each attention fusion operation uses independent model parameters; thus, the dynamic execution branch representation is obtained. and static structure branch representation This is used for subsequent global attention fusion.

8. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 6 is as follows: Using attention mechanism to represent dynamic execution branches and static structure branch representation Perform global fusion; for Calculate the key vector and value vector respectively: (10) in, Indicates the first The key vectors corresponding to each branch Indicates the first The value vector corresponding to each branch. and These represent the key mapping matrix and value mapping matrix of the global attention fusion module, respectively. Indicates the first Feature representation of each branch; Based on globally learnable query vectors Calculate the attention weights for dynamic execution branches and static structure branches. : (11) in, This represents a globally learnable query vector. Indicates the first The global attention weights for each branch are used; the two branches are weighted and fused based on the attention weights, and the final fault feature representation is obtained through a fully connected layer. : (12) in, This represents the global fusion feature representation obtained by weighting and fusing the value vectors of dynamic execution branches and static structure branches according to attention weights. and These represent the weight matrix and bias of the global fusion layer, respectively. This represents the final fault characteristics corresponding to the candidate program file.

9. The CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, In step 7: The HAF-MLP model is trained using the cross-entropy loss function; for models containing A dataset of training samples, cross-entropy loss Represented as: (13) in, Indicates the first The true label of each candidate program file; when When a faulty file is displayed, This indicates a non-faulty file; and These represent the model's predicted first and second halves of the series. The probability that a candidate program file is a faulty file and the probability that it is a non-faulty file; The parameters of the dimension balancing mapping layer, intra-group attention layer, branch-level attention layer, global attention layer, and output layer are updated iteratively by optimizing the algorithm.

10. A CAE software fault location method based on domain awareness and hierarchical fusion according to claim 1, characterized in that, Step 8 is as follows: The six sets of fault location features from each candidate program file in the version to be located are input into the trained HAF-MLP model to calculate the final fault feature representation corresponding to the candidate program file. The classification probability is calculated using the Softmax function. : (14) in, and These represent the weight matrix and bias of the output layer, respectively. This indicates the probability that a candidate program file is a faulty file. This indicates the probability that a candidate program file is a non-faulty file. Will The candidate program files are evaluated based on their suspected fault levels, and all candidate program files are sorted from highest to lowest according to their suspected fault levels to generate file-level fault location results. When statement-level fault location results are needed, the fault suspicion level of each candidate program file is mapped to the executable statement in the corresponding file. That is, the executable statement in the same file inherits the fault suspicion level of that file. Then, all executable statements are sorted from high to low according to the fault suspicion level to generate statement-level fault location results.

Citation Information

Patent Citations

  • Deep neural network-based fault positioning method

    CN107330519A

  • RankNet-based hybrid software error positioning method and system

    CN111581086A

  • A Software Fault Localization Method Based on Network Spectrum

    CN114253853B