A combined test method for UAV flight control parameters based on Kmeans and SVM
By combining Kmeans++ and SVM models to test UAV flight control parameters, and using a small amount of data for clustering and priority sorting, the problem of low efficiency in UAV flight control parameter testing is solved, and efficient fault detection is achieved.
Patent Information
- Application Number
- CN202310076438.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-20
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2043-01-20
AI Technical Summary
The testing efficiency of UAV flight control parameters is low, and existing technologies are insufficient to efficiently detect the interaction effects between parameters in complex testing spaces.
A test method for combining UAV flight control parameters based on Kmeans and SVM is adopted. A model is built using Kmeans++ and support vector machine (SVM) to cluster and predict the test data. Combined with a greedy algorithm for priority sorting, a small amount of test data is used for rapid fault detection.
Using only 20% of the test data, the efficiency of fault detection was significantly improved, enabling the detection of more faults faster and greatly enhancing the detection efficiency.
Smart Images

Figure CN116088477B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a combined testing method for flight control parameters of an unmanned aerial vehicle based on Kmeans and SVM. Background Art
[0002] In recent years, weapon systems have entered a period of rapid development, and the system's hardware and software have become increasingly complex. As far as software is concerned, the complexity of its structure and functions has increased significantly, and its processing capabilities have been significantly enhanced. The number of input parameters that a function in the software can process simultaneously has also increased, reaching dozens or even hundreds. These input parameters are coupled and interdependent with each other, and the relationship is very complex. Some minor input errors or accidental factors may cause huge property losses and serious personal injuries, resulting in inestimable consequences. Testing is an important means to reduce losses, reduce injuries, and ensure quality and reliability.
[0003] In theory, full factor testing can ensure comprehensiveness by performing full factor testing on all data in the test space. However, the possible test data in the test space is too numerous to be applied in actual testing. Combinatorial testing is a scientific and effective black box testing method that can effectively detect the impact of the interaction between parameters in the system under test using less test data. Combinatorial testing can achieve the effect of full factor testing using less test data. Therefore, combinatorial testing is often used instead of full factor testing in practice.
[0004] In actual systems under test, the number of parameters and the number of parameter values are often large, ranging from a dozen to dozens, and the interaction between parameters is complex. It is difficult to guarantee test coverage by only covering two or three parameter value combinations, that is, the coverage strength is 2 or 3. If more powerful test data is generated, the scale of the test data will be very large, reaching tens of thousands or even more. Sometimes it takes a long time to execute a test data, in the order of seconds, so it is difficult to complete the complete testing of these test data. Summary of the invention
[0005] The purpose of the present invention is to propose a combined testing method for UAV flight control parameters based on Kmeans and SVM to address the problem of low testing efficiency of UAV flight control parameters in the prior art.
[0006] The technical solution adopted by the present invention to solve the above technical problems is:
[0007] A method for combining flight control parameters of unmanned aerial vehicles based on Kmeans and SVM includes the following steps:
[0008] Step 1: The UAV flight control computer receives typical test values selected by the front-end sensor, i.e., the test data set;
[0009] Step 2: Select 20% of the data in the test data set as the preliminary small sample test data, and use the selected preliminary small sample test data to stimulate the flight control computer to obtain the response result of the flight control computer, and use the preliminary small sample test data and the corresponding response result as training data to train the Kmeans and SVM models respectively. Kmeans clusters the preliminary small sample test data into two categories, namely, the faulty class and the non-faulty class.
[0010] Step 3: Use Kmeans and SVM to predict the test data in the test data set respectively, and prioritize the test data according to the prediction results, sort them according to the priority after fusion, and adjust the priority of the test data with the same priority by the distance entropy value; finally output the test data with priority;
[0011] Step 4: The prioritized test data is used as stimulus for the flight control computer for final testing.
[0012] Furthermore, each test data in the test data set is obtained based on a greedy algorithm, and the specific steps are:
[0013] Step 1: Based on the parameter value combination of strength 2 and according to the correlation between the parameters, the parameter value combination of strength 3 and strength 4 is used to obtain a parameter value set;
[0014] Step 1 and 2: According to the number of times each value of the parameter appears in the value set, the value coverage of the parameter is obtained;
[0015] Step 13: Select the value with the largest uncovered degree for each parameter to form a test data;
[0016] Step 14: Use the value combination in the value set to replace the value combination corresponding to the test data in step 3. If the replacement can improve the coverage of this test data, then keep the replaced test data, otherwise do not replace it and end;
[0017] Step 5: Remove the covered values in the replaced test data from the value set, and then determine whether the value set is empty. If the value set is empty, end; if the value set is not empty, execute step 2.
[0018] Furthermore, the Kmeans is Kmeans++, and the specific steps of Kmeans++ predicting the test data in the test data set are:
[0019] Step 1: Assume that the set of n test data is Randomly select a fault test data As the first cluster center C1;
[0020] Step 2: Calculate any test data The minimum distance from the currently determined cluster center C1 And according to Get the probability S of becoming the next cluster center im ;
[0021] Step 3: Repeat steps 1 and 2 to get the probability set S i1 ,S i2 ,…,S in , and then generate a random number R in the interval [0,1] i , using R i Subtract the probability set S in sequence i1 ,S i2 ,…,S in For each probability in , take the test data corresponding to the first time the difference is less than or equal to 0 as the next cluster center;
[0022] Step 4: Repeat steps 2 and 3, and use the last cluster center as the fault cluster center. Then, reselect a test data that will not cause the fault, repeat steps 2 and 3, and use the last cluster center as the non-fault center.
[0023] Step 5: Calculate the set The distance between each test data and the fault cluster center and the non-fault center is Each test in is regarded as a point, and each point is divided into the cluster center closest to it to form a corresponding subset;
[0024] Step 6: Take the mean m of each subset ik Update the fault cluster center and non-fault center, calculate the error sum of squares, and repeat steps 5 and 6 until the fault cluster center and non-fault center converge.
[0025] The sum of squared errors is expressed as:
[0026]
[0027] Among them, N c represents the number of clusters, C k represents the test data set belonging to the kth cluster, p ik represents each i test data in the test data set of the kth cluster, N k Represents C k The number of ik represents the mean of each subset.
[0028] Furthermore, the It is expressed as:
[0029]
[0030] Furthermore, the S im It is expressed as:
[0031]
[0032] Wherein, m represents any value from 1 to n.
[0033] Furthermore, the training of the SVM model in step 2 is performed by multi-core weighted training, and the weighted kernel function is expressed as:
[0034]
[0035] Wherein, x and y represent two test data, and γ=0.5.
[0036] Furthermore, the priority fusion is expressed as:
[0037] P(T)=Kmeans(T)+SVM(T)
[0038] Among them, Kmeans(T) and SVM(T) represent the Kmeans prediction results and SVM prediction results of the test data T.
[0039] P(T) represents the priority of the test data T, which is the sum of the prediction results of the two models. If T will not cause a fault, Kmeans(T) = 0, SVM(T) = 0. Otherwise, it will cause a fault. Finally, there are three priorities for the test data T, namely 0, 1, and 2.
[0040] Furthermore, the priority is adjusted by the distance entropy value as follows:
[0041] The distance between test data is defined as follows:
[0042] Assume that the system to be tested has k parameters, and assume that the k parameters are v1, v2, ..., v k possible values,
[0043] T1=(t 11 ,t 12 ,...,t 1k ) and T2=(t 21 ,t 22 ,...,t 2k ) are two test data of the system to be tested. Using the normalization method, the distance between the two test data is defined as:
[0044]
[0045] The distance entropy is calculated by citing information entropy. The distance entropy is expressed as:
[0046] S D = -D(T1,T2)logD(T1,T2)
[0047] In the priority sorting results of the test data, for the test data with the same priority, the priority is adjusted according to the size of the distance entropy. If the distance entropy is the same, local adjustment is made according to the probability entropy. The probability entropy is expressed as:
[0048]
[0049] Where f represents the number of defects predicted in the test data, P j represents the probability of the jth predicted defect.
[0050] Furthermore, in step 4, step 2 and step 3 are repeated 30 times.
[0051] Furthermore, in step 6, step 5 and step 6 are repeated 50 times.
[0052] The beneficial effects of the present invention are:
[0053] This application first uses a small amount of UAV flight control parameter data for testing, and the obtained test results are used as labels for the test data; secondly, Kmeans++ and support vector machine (SVM) are used to build a model of the system to be tested; again, these two models are used to predict the combined test data, and the prediction results are integrated; finally, priority is sorted according to the prediction results. In the case of only giving priority to testing 20% of the combined test data, the combined test data that is finally sorted can detect more faults faster, greatly improving the detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 Diagram of the test data prioritization method for the combination of Kmeans++ and SVM;
[0055] Figure 2 Construct a flowchart for the test dataset. DETAILED DESCRIPTION
[0056] It should be particularly noted that, in the absence of conflict, the various embodiments disclosed in this application can be combined with each other.
[0057] Specific implementation method 1: A UAV flight control parameter combination test method based on Kmeans and SVM described in this implementation method includes the following steps:
[0058] Step 1: The UAV flight control computer receives typical test values selected by the front-end sensor, i.e., the test data set;
[0059] Step 2: Select 20% of the data in the test data set as the preliminary small sample test data, and use the selected preliminary small sample test data to stimulate the flight control computer to obtain the response result of the flight control computer, and use the preliminary small sample test data and the corresponding response result as training data to train the Kmeans and SVM models respectively. Kmeans clusters the preliminary small sample test data into two categories, namely, the faulty class and the non-faulty class.
[0060] Step 3: Use Kmeans and SVM to predict the test data in the test data set respectively, and prioritize the test data according to the prediction results, sort them according to the priority after fusion, and adjust the priority of the test data with the same priority by the distance entropy value; finally output the test data with priority;
[0061] Step 4: The prioritized test data is used as stimulus for the flight control computer for final testing.
[0062] Because the historical information of many software is difficult to obtain, or because the software version upgrade makes the historical version of the reference meaningless, it is necessary to prioritize the combined test data, and then select part of the test data from the front to the back according to the ranking as the actual execution test data. Specifically, the overall idea of this application is:
[0063] like Figure 1 As shown in the figure, first, construct a test data set for combined testing; second, select 20% of the test data from the test data set for testing first, and use the obtained test results as the labels of these 20% test data; then use Kmeans++ and SVM to train these labeled test data respectively. Kmeans++ clusters these test data into two categories, faulty and non-faulty. SVM establishes the input and output model of the system to be tested through training; third, use Kmeans++ and SVM models to predict all test data, and prioritize the test data according to the prediction results, sort them according to the priority size after fusion, and adjust the priority of the test data with the same priority through the distance entropy value; finally, output the test data with priority.
[0064] The technical solution of the present application uses only 20% of the test data for testing first, so that all the test data after priority sorting can detect faults as quickly as possible. The important links will be described in detail below.
[0065] 1. Combination test data set construction
[0066] The test data set is implemented based on the greedy algorithm, and the construction process is as follows Figure 2 shown.
[0067] (1) Initialize the parameter value set that needs to be covered, based on the parameter value combination with a strength of 2, and increase or decrease the parameter value combination according to the correlation between the parameters of the object to be tested.
[0068] (2) Calculate the uncovered degree of each parameter value, which is the number of times each parameter value appears in the parameter value set. The more times it appears, the earlier it is covered to improve the coverage capability of the test data.
[0069] (3) A test data is generated according to the coverage, and each parameter is selected with the value with the largest coverage to form a test data.
[0070] (4) A greedy algorithm is used to improve the coverage of test data. The corresponding value combinations in the test data are replaced with the value combinations in the parameter value set. If the replacement can improve the coverage of the test data, the previous test data is replaced. Otherwise, it is not replaced.
[0071] (5) Output a test data, then update the parameter value set, and remove the values covered by the test data from the parameter value set. If the parameter value set is empty, the generation process ends, otherwise jump to step (2).
[0072] 2. K-means++ clustering
[0073] As a partitioning clustering method, the K-means algorithm has the characteristics of simple principle and fast convergence, but its clustering effect depends on the initial cluster center. Therefore, considering the computational efficiency and clustering effect, the K-means++ algorithm is introduced to cluster the real data of each evaluation index into 2 categories, with faults and without faults. The membership level of each category is determined according to the numerical value of the cluster center, and the minimum and maximum values of each data set are used as the activation threshold.
[0074] The K-means++ algorithm is based on the traditional K-means algorithm and optimizes the initial cluster center selection method with "the farthest distance from the current cluster center" as the core. The specific implementation steps are as follows:
[0075] (1) Assume that the set of n test data is Randomly select a fault test data As the first cluster center C1.
[0076] (2) Use formula (1) to calculate any test data The minimum distance from the currently determined cluster center C1, and the probability S of becoming the next cluster center m :
[0077]
[0078] (3) Generate a random number R in the interval [0,1] i , using R i Subtract S in sequence i1 ,S i2 ,…,S in , the test data corresponding to the first time the difference is less than or equal to 0 is taken as the next cluster center.
[0079] (4) Repeat steps (2) and (3) 30 times to select the best fault cluster center. Reselect a test data that will not cause the fault, perform the above process, and select the best non-fault center.
[0080] (5) Calculation set The distance from each test data to each cluster center is calculated, and each point is divided into the cluster center closest to it to form a corresponding subset.
[0081] (6) Using the mean m of each subset ik Update each cluster center, and use the squared error calculated by formula (2) to represent the change of the cluster center.
[0082]
[0083] Where: N c is the number of clusters, C k is the test data set belonging to the kth cluster, N k Repeat steps (5) and (6) 50 times until the changes of cluster centers converge.
[0084] 3.SVM multi-core weighted training
[0085] The support vector machine builds a model of the system to be tested by training 20% of the test data. When building the model, it is necessary to select a suitable kernel function. In order to accurately build the model of the system to be tested, several common kernel functions are weighted as the kernel function of SVM to fully utilize the advantages of each kernel function. Polynomial kernel function κ(x,y)=((x·y)+1) d , the Gaussian kernel function is κ(x,y)=exp(-γ||xy|| 2 ). The weighted kernel function is shown in formula (3).
[0086]
[0087] This kernel function can be used to fully establish a combinatorial test model that approximates the system under test.
[0088] x, y are two vectors in the kernel function κ(x, y). In this technology, when the support vector machine solves the kernel function, x, y are two test data, and γ=0.5.
[0089] 4. Fusion prediction
[0090] The two models are used to predict all the test data, as shown in formula (4).
[0091] P(T)=Kmeans(T)+SVM(T) (4)
[0092] P(T) represents the priority of the test data T, which is the sum of the prediction results of the two models. If T causes a fault, Kmeans(T) = 1, SVM(T) = 1; if T does not cause a fault, Kmeans(T) = 0, SVM(T) = 0. Finally, the priority of the test data T has only three cases: 0, 1, and 2. This is the priority of the test data.
[0093] 5. Distance entropy adjustment
[0094] There are only three priorities for test data, and many test data have the same priority. In order to refine the test data with the same priority, the distance information entropy and predicted defect probability between test data are used to make local adjustments to the test data with the same priority. The distance between test data is defined as follows:
[0095] Assume that the system to be tested has k parameters, and these parameters are v1, v2, ..., v k possible values,
[0096] T1=(t 11 ,t 12 ,...,t 1k ) and T2=(t 21 ,t 22 ,...,t 2k ) are two test data of the system to be tested. Using the normalization method, the distance between the two test data is defined as:
[0097]
[0098] The distance between the test data indicates the difference between the contexts. The concept of information entropy is used to calculate the distance entropy, which is defined as follows:
[0099] S D = -D(T1,T2)logD(T1,T2) (6)
[0100] In the test data priority sorting results, for the test data with the same priority, the priority is adjusted according to the size of the distance entropy. If the distance entropy is the same, local adjustment is made according to the probability entropy. The probability entropy is defined as follows:
[0101]
[0102] Where f is the number of defects predicted in the test data, P j is the probability of the jth predicted defect.
[0103] At present, this method has been applied to the on-site testing of a certain type of missile integrated control machine, and can achieve rapid testing and rapid fault location of the system under test.
[0104] At present, this application has been applied to the testing of UAV flight control computers. When the flight control computer is working, it receives data transmitted by the front-end sensor. There are 30 parameters in total. After selecting the typical test value for each parameter, there are more than 100,000 test data in total. Using this technology, 5,000 test data are selected in the early stage for testing first to stimulate the flight control computer. The Kmeans++ and SVM models are trained according to the response results of the flight control computer. The obtained model is used to prioritize more than 100,000 test data. The sorted test data is used as the stimulus of the flight control computer for the final test. With less than 5% (5000 / 100,000) of the preliminary test data, the fault detection speed is increased by more than 70%.
[0105] It should be noted that the specific implementation is only an explanation and description of the technical solution of the present invention, and cannot be used to limit the scope of protection of the rights. Any partial changes made according to the claims and description of the present invention should still fall within the scope of protection of the present invention.
Claims
1. A combined test method for UAV flight control parameters based on Kmeans and SVM, characterized in that The following steps are involved: Step 1: The UAV flight control computer receives typical test values selected by the front-end sensor, i.e., the test data set; Step 2: Select 20% of the data in the test data set as the preliminary small sample test data, and use the selected preliminary small sample test data to stimulate the flight control computer to obtain the response result of the flight control computer, and use the preliminary small sample test data and the corresponding response result as training data to train the Kmeans and SVM models respectively. Kmeans clusters the preliminary small sample test data into two categories, namely, the faulty class and the non-faulty class. Step 3: Use Kmeans and SVM to predict the test data in the test data set respectively, and prioritize the test data according to the prediction results, sort them according to the priority after fusion, and adjust the priority of the test data with the same priority by the distance entropy value; finally output the test data with priority; Step 4: The prioritized test data is used as stimulus for the flight control computer for final testing; Each test data in the test data set is obtained based on a greedy algorithm, and the specific steps are: Step 1: Based on the parameter value combination of strength 2 and according to the correlation between the parameters, the parameter value combination of strength 3 and strength 4 is used to obtain a parameter value set; Step 1 and 2: According to the number of times each value of the parameter appears in the value set, the value coverage of the parameter is obtained; Step 13: Select the value with the largest uncovered degree for each parameter to form a test data; Step 14: Use the value combination in the value set to replace the value combination corresponding to the test data in step 3. If the replacement can improve the coverage of this test data, then keep the replaced test data, otherwise do not replace it and end; Step 15: Remove the covered values in the replaced test data from the value set, and then determine whether the value set is empty. If the value set is empty, end; if the value set is not empty, execute step 2.
2. A combined test method for UAV flight control parameters based on Kmeans and SVM according to claim 1, characterized in that The Kmeans is Kmeans++, and the specific steps of Kmeans++ for predicting the test data in the test data set are: Step 1: Assume that the set of n test data is Randomly select a fault test data As the first cluster center C1; Step 2: Calculate any test data The minimum distance from the currently determined cluster center C1 And according to Get the probability S of becoming the next cluster center im ; Step 3: Repeat steps 1 and 2 to get the probability set S i1 ,S i2 ,…,S in , and then generate a random number R in the interval [0,1] i , using R i Subtract the probability set S in sequence i1 ,S i2 ,…,S in For each probability in , take the test data corresponding to the first time the difference is less than or equal to 0 as the next cluster center; Step 4: Repeat steps 2 and 3, and use the last cluster center as the fault cluster center. Then, reselect a test data that will not cause the fault, repeat steps 2 and 3, and use the last cluster center as the non-fault center. Step 5: Calculate the set The distance between each test data and the fault cluster center and the non-fault center is Each test in is regarded as a point, and each point is divided into the cluster center closest to it to form a corresponding subset; Step 6: Take the mean m of each subset ik Update the fault cluster center and non-fault center, calculate the error sum of squares, and repeat steps 5 and 6 until the fault cluster center and non-fault center converge. The sum of squared errors is expressed as: Among them, N c represents the number of clusters, C k represents the test data set belonging to the kth cluster, p ik represents each i test data in the test data set of the kth cluster, N k Represents C k The number of ik represents the mean of each subset.
3. A combined test method for UAV flight control parameters based on Kmeans and SVM according to claim 2, characterized in that Said It is expressed as:
4. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 3 is characterized in that The S im It is expressed as: Wherein, m represents any value from 1 to n.
5. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 2 is characterized in that The training of the SVM model in step 2 is performed by multi-core weighted training, and the weighted kernel function is expressed as: Wherein, x and y represent two test data, γ is a constant, γ=0.
5.
6. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 5 is characterized in that The priority fusion is expressed as: P(T)=Kmeans(T)+SVM(T) Among them, Kmeans(T) and SVM(T) represent the Kmeans prediction results and SVM prediction results of the test data T, P(T) represents the priority of the test data T, which is the sum of the prediction results of the two models. If T will not cause a fault, Kmeans(T) = 0, SVM(T) = 0, otherwise it will cause a fault. Finally, there are three priorities of the test data T, namely 0, 1, and 2.
7. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 6 is characterized in that The priority adjustment by distance entropy value is specifically as follows: The distance between test data is defined as follows: Assume that the system to be tested has k parameters, and assume that the k parameters are v1, v2, ..., v k possible values, T1=(t 11 ,t 12 ,...,t 1k ) and T2=(t 21 ,t 22 ,...,t 2k ) are two test data of the system to be tested. Using the normalization method, the distance between the two test data is defined as: The distance entropy is calculated by citing information entropy. The distance entropy is expressed as: S D =-D(T1,T2)logD(T1,T2) In the priority sorting results of the test data, for the test data with the same priority, the priority is adjusted according to the size of the distance entropy. If the distance entropy is the same, local adjustment is made according to the probability entropy. The probability entropy is expressed as: Where f represents the number of defects predicted in the test data, P j represents the probability of the jth predicted defect.
8. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 2 is characterized in that In step 4, step 2 and step 3 are repeated 30 times.
9. The UAV flight control parameter combination test method based on Kmeans and SVM according to claim 2 is characterized in that In step 6, step 5 and step 6 are repeated 50 times.
