A filtering optimization method, system, computer device, readable medium and vehicle
By automatically configuring CAN message filters using a weighted matrix clustering algorithm, the problem of low efficiency in manual grouping in existing technologies is solved, achieving higher-precision filtering and optimized utilization of CPU resources.
Patent Information
- Application Number
- CN202411219908.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-09-02
AI Technical Summary
When the existing CAN controller message filter receives more than 32 ID messages, it cannot effectively filter out invalid messages after being configured in group reception mode. Manual group identification is inefficient, it is difficult to achieve high-precision filtering effect, and it consumes a lot of CPU resources.
A clustering algorithm based on a weight matrix is adopted. Through data collection, initialization of the weight matrix, clustering operation and iterative update, the CAN message filter is automatically configured to replace the traditional cluster centroid, improve the distance between and within clusters, and avoid the tedious process of manual configuration.
The accuracy of the CAN message filter has been improved, effectively filtering out useless messages, reducing CPU usage, and improving the CPU utilization of the embedded system.
Smart Images

Figure CN118732588B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of CAN controller message filtering, and in particular to a filtering optimization method, system, computer equipment, readable medium and vehicle. Background Art
[0002] With the development of intelligent and networked automotive electronic products, the role of CAN (Control Area Network) bus in automobiles has become more and more significant. Usually, there are dozens to hundreds of ECUs (Electronic Control Units) in a car, and each ECU will send and receive communication messages with several different IDs at the same time. Therefore, there are usually thousands of message signals with different IDs on the car CAN bus. For one of the ECUs, it only needs to receive messages with several specified IDs, not all messages, so the CAN controller usually uses hardware-based CAN message filtering technology to filter out IDs that do not need to be received to save precious CPU computing resources.
[0003] Existing CAN controllers usually have only 8 to 32 hardware message filters. Once the number of ID messages to be received exceeds 32, the filter needs to be configured as a group receiving mode. However, the filter configured as a group receiving mode will not be able to filter out all invalid messages. For the message IDs to be received, the more similar the messages are grouped in the same group, the fewer invalid message IDs are received. The current mainstream message grouping is based on manual identification, which is inefficient and difficult to achieve good results. Summary of the invention
[0004] In order to solve the technical problems in the related technologies, the present application provides a filtering optimization method, system, computer device, readable medium and vehicle, wherein the filtering optimization method of the present application avoids the tedious manual configuration, can effectively improve the accuracy of the filter, and filter out useless CAN messages more thoroughly and effectively, can effectively improve the utilization rate of the embedded system CPU, and reduce the CPU occupancy.
[0005] In order to achieve the above objectives, the technical solutions adopted in this application include:
[0006] According to a first aspect of the present application, a filtering optimization method is provided for message filtering of a CAN controller, comprising the following steps:
[0007] Step S1, data collection: obtain CAN message samples that need to be clustered, and encode them to generate a sample set ,in, ; For the number CAN message samples, each CAN message sample Total attributes, namely, , each attribute has attribute value, that is ;
[0008] Step S2, initialize the weight matrix: determine the number of clustering classes , and from the sample set A sample is randomly selected as and divide it into the initial class , generating a The initial weight matrix ; In the formula, Represents the weight matrix of the first class in the first iteration cycle. The element calculation formula of the weight matrix is:
[0009]
[0010] In the formula, Indicates The number of samples in each class, Indicated in All samples in the class The attribute value of the attribute the number of
[0011] Using Initial Class The weight matrix is used to calculate the similarity between the remaining samples and , and the sample with the lowest similarity is taken as Initial second class and use Calculate the weight matrix of the second class, and then use the maximum distance method to determine the remaining initial other classes and their weight matrices until there is weight matrix; among them, select Samples The calculation formula is:
[0012]
[0013] In the formula, is the number of classes that have been initialized. To find the order Smallest , is the similarity measurement formula, is the Kth weight matrix, ;
[0014] Step S3, cluster the samples using the weight matrix, and assign the sample with the greatest similarity to the weight matrix to the class to which it belongs:
[0015]
[0016]
[0017] In the formula, is the subscript of the class, It means finding the class with the greatest similarity to the sample, the obtained ζ is the subscript of the class, and then putting the sample into the class with subscript ζ;
[0018] Step S4, determine whether there is a class that is empty. If there is a class that is empty, take the sample with the lowest similarity to its weight matrix in the non-empty class as a new class to replace the empty class, until the number of classes is ;
[0019] Step S5, calculate the intermediate weight matrix of each class according to the element calculation formula of the weight matrix in step S2 , and then recursively update the weight matrix for the next iteration according to the following formula:
[0020]
[0021] In the formula, is a constant coefficient, Indicates Iteration cycles;
[0022] Step S6, determine whether the end condition is met, if so, proceed to step S7, if not, proceed to step S3;
[0023] Step S7, extracting the features of each class after clustering is completed, and deploying them to the CAN controller.
[0024] Optionally, in step S2, the determined number of clusters Satisfies: Number of clusters The maximum value is the number of hardware message filters in the CAN controller.
[0025] Optionally, in step S4, if no class is empty, directly proceed to step S5.
[0026] Optionally, in step S6, the end condition is: reaching a maximum number of iterations, or the weight matrix no longer changes.
[0027] According to the second aspect of the present application, a filtering optimization system is further provided, characterized in that it is applied to the filtering optimization method as described in any technical solution in the first aspect of the present application, and the filtering optimization system includes:
[0028] A data acquisition module is used to obtain CAN message samples that need to be clustered;
[0029] The data processing module is used to encode the acquired CAN message samples to generate a sample set; and to execute the step of initializing the weight matrix; and to use the weight matrix to cluster the samples, and assign the samples with the greatest similarity to the weight matrix to the class to which they belong; and to determine whether there is an empty class. If a class is empty, the sample with the lowest similarity to its weight matrix in the non-empty class is used as a new class to replace the empty class, until the number of classes is ; and used to calculate the intermediate weight matrix for each class ; and is used to determine whether the end condition is met; and is used to extract the characteristics of each class after clustering is completed, and is deployed in the CAN message filter to realize message filtering of the CAN message filter.
[0030] According to the third aspect of the present application, a computer device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor can implement the steps of the filtering optimization method described in any one of the technical solutions in the first aspect of the present application when executing the computer program.
[0031] According to the fourth aspect of the present application, a readable medium is also provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, it can implement the steps of the filtering optimization method described in any technical solution in the first aspect of the present application.
[0032] According to a fifth aspect of the present application, a vehicle is also provided, which includes the filtering optimization system as described in the second aspect of the present application.
[0033] Beneficial effects:
[0034] 1. Through the above technical scheme, first, in the filtering optimization method of the present application, the clustering algorithm designed by the present application overcomes the shortcomings of the traditional K-modes algorithm, and can divide the CAN message into pre-set k classes, so that the divided classes can be guaranteed to have a smaller intra-class distance and a larger inter-class distance, so that the attributes of each class converge to a certain attribute value as much as possible, and then the characteristics of each class are extracted to configure the hardware filter of the CAN message. At the same time, the clustering algorithm configuration filter designed by the present application avoids the tediousness of manual configuration, can effectively improve the accuracy of the filter, can more thoroughly and effectively filter out more useless CAN messages, and can effectively improve the utilization rate of the embedded system CPU and reduce the CPU occupancy.
[0035] Second, in the filtering optimization method of the present application, the present application constructs the distribution information of the sample attributes in each class by means of a weight matrix, which replaces the traditional clustering center point. The similarity between the class and the sample is calculated by the weight matrix, which can effectively discover the difference in attribute values under the same attribute, thereby gradually reducing this attribute value difference in the clustering process. Specifically, each attribute of the sample within the class will gradually converge to a certain attribute value, reducing the distance within the class and improving the clustering effect.
[0036] Third, if the sample initial weight matrix is randomly selected, when the samples have great similarity, the clustering process will quickly converge to the local optimum and cause the problem of missing classes. In the filtering optimization method of the present application, the initialization scheme based on the maximum distance method of the present application can initialize the initial weight matrix with the minimum similarity, ensure a large inter-class distance, and thus improve the stability of the algorithm.
[0037] Fourth, in the late iteration of the clustering process, the weight matrix of some classes may disappear due to the division of samples, that is, the attribute values of the same attribute of the samples in the class have different values, resulting in no samples being divided into these classes in the next iteration cycle, causing the problem of missing classes, which will quickly fall into the problem of local optimality, and ultimately affect the inter-class distance and intra-class distance of the clustering. In the filtering optimization method of the present application, the present application checks the number of classes after each clustering operation is completed, and constructs the weight matrix of the missing class through the samples of the non-empty class to improve the algorithm's exploration ability during the iteration process and avoid falling into the local optimal situation.
[0038] 2. Other beneficial effects or advantages of the present application will be described in detail in the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] in:
[0041] Figure 1 is a schematic flow chart of the steps of a filtering optimization method provided by an exemplary embodiment of the present application;
[0042] Figure 2 It is a schematic block diagram of a filtering optimization method provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0044] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0045] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes other steps or units that are not listed, or optionally includes other steps or units that are inherent to these processes, methods, products or devices. Among them, it should also be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0046] In order to facilitate relevant technical personnel to have a clearer and more accurate understanding of the technical solution of the present application, the existing related technologies and the inventive ideas of the present application are first explained below.
[0047] Combined with the discussion in the background technology section of this application, it can be seen that at present, the mainstream message grouping is generally grouped after manual identification. This grouping method is inefficient and it is difficult to achieve good results.
[0048] Based on this, the inventors of this application first attempted to introduce cluster analysis technology into message grouping. Cluster analysis is an unsupervised learning method that divides samples into different classes based on the similarity between data, so that samples in the same class are as similar as possible, and samples in different classes are as different as possible.
[0049] The inventor of the present application first focused on the K-means algorithm. Among many cluster analysis algorithms, the K-means algorithm is one of the most widely used clustering algorithms. However, since K-means uses the Euclidean distance to calculate the distance between the cluster center and the sample, it is not suitable for clustering objects with non-numerical data.
[0050] Then, the inventors of the present application focused on the K-modes algorithm, which is an improvement on the K-means algorithm. The K-modes algorithm replaces the Euclidean distance of the K-means algorithm with the Hamming distance between non-numerical data objects, so it can be applied to the clustering of non-numerical data objects.
[0051] However, the k-modes algorithm still has many shortcomings:
[0052] First, the k-modes algorithm uses the mode of attribute values of each attribute within the class as the cluster center, and uses the Hamming distance between the sample and the cluster center to measure the similarity between the sample and the class. However, when the attribute values of the samples within the class are evenly distributed, the Hamming distance cannot represent the difference in attribute values of the same attribute of the samples within the class, and cannot provide sufficient useful information for the measurement of similarity. Second, the k-modes algorithm randomly selects k samples as the initial center, which will greatly affect the performance of the algorithm by the sample distribution and random center. Third, during the iteration process, the k-modes algorithm may have the problem of missing classes, which will affect the clustering results.
[0053] In view of this, the present application provides a new solution, namely the filtering optimization method of the present application. First, in the filtering optimization method of the present application, the cluster center of the K-modes algorithm is replaced by the weight matrix of the class to count the distribution of attribute values within the entire class, which provides more useful information for the measurement of similarity. Secondly, the weight matrix is initialized using the maximum distance method, and the individuals in the sample set that are most dissimilar to each other are divided into the initial class to generate the weight matrix, which can not only effectively improve the global exploration ability of the algorithm, but also help to eliminate outliers. Finally, after each iteration is completed, the number of classes is detected, and the missing classes are supplemented with samples with the lowest similarity to ensure that the algorithm can obtain a specified number of classes after the iteration is completed to ensure the clustering result.
[0054] The technical solution of the present application is described in detail below with reference to the accompanying drawings.
[0055] Example 1
[0056] See also Figure 1 and Figure 2 As shown, according to the first aspect of the present application, this embodiment provides a filtering optimization method for message filtering of a CAN controller, comprising the following steps:
[0057] Step S1, data collection: obtain CAN message samples that need to be clustered, and encode them to generate a sample set ,in, ; For the number CAN message samples, each CAN message sample Total attributes, namely, , each attribute has attribute value, that is ;
[0058] Step S2, initialize the weight matrix: determine the number of clustering classes , and from the sample set A sample is randomly selected as and divide it into the initial class , generating a The initial weight matrix ; In the formula, Represents the weight matrix of the first class in the first iteration cycle. The element calculation formula of the weight matrix is:
[0059]
[0060] In the formula, Indicates The number of samples in each class, Indicated in All samples in the class The attribute value of the attribute the number of
[0061] Using Initial Class The weight matrix is used to calculate the similarity between the remaining samples and , and the sample with the lowest similarity is taken as Initial second class and use Calculate the weight matrix of the second class, and then use the maximum distance method to determine the remaining initial other classes and their weight matrices until there is weight matrix; among them, select Samples The calculation formula is:
[0062]
[0063] In the formula, is the number of classes that have been initialized. To find the order Smallest , is the similarity measurement formula, is the Kth weight matrix, ;
[0064] Step S3, cluster the samples using the weight matrix, and assign the sample with the greatest similarity to the weight matrix to the class to which it belongs:
[0065]
[0066]
[0067] In the formula, is the subscript of the class, It means finding the class with the greatest similarity to the sample, the obtained ζ is the subscript of the class, and then putting the sample into the class with subscript ζ;
[0068] Step S4, determine whether there is a class that is empty. If there is a class that is empty, take the sample with the lowest similarity to its weight matrix in the non-empty class as a new class to replace the empty class, until the number of classes is ;
[0069] Step S5, calculate the intermediate weight matrix of each class according to the element calculation formula of the weight matrix in step S2 , and then recursively update the weight matrix for the next iteration according to the following formula:
[0070]
[0071] In the formula, is a constant coefficient, Indicates Iteration cycles;
[0072] Step S6, determine whether the end condition is met, if so, proceed to step S7, if not, proceed to step S3;
[0073] Step S7, extracting the features of each class after clustering is completed, and deploying them to the CAN hardware message filter.
[0074] Through the above technical scheme, first, in the filtering optimization method of the present application, the clustering algorithm designed in the present application overcomes the shortcomings of the traditional K-modes algorithm, and can divide the CAN message into pre-set k classes, so that the divided classes can be guaranteed to have a smaller intra-class distance and a larger inter-class distance, so that the attributes of each class converge to a certain attribute value as much as possible, and then the characteristics of each class are extracted to configure the hardware filter of the CAN message. At the same time, the clustering algorithm configured filter designed in the present application avoids the tediousness of manual configuration, can effectively improve the accuracy of the filter, can more thoroughly and effectively filter out more useless CAN messages, and can effectively improve the utilization rate of the embedded system CPU and reduce the CPU occupancy.
[0075] Second, in the filtering optimization method of the present application, the present application constructs the distribution information of the sample attributes in each class by means of a weight matrix, which replaces the traditional clustering center point. The similarity between the class and the sample is calculated by the weight matrix, which can effectively discover the difference in attribute values under the same attribute, thereby gradually reducing this attribute value difference in the clustering process. Specifically, each attribute of the sample within the class will gradually converge to a certain attribute value, reducing the distance within the class and improving the clustering effect.
[0076] Third, if the sample initial weight matrix is randomly selected, when the samples have great similarity, the clustering process will quickly converge to the local optimum and cause the problem of missing classes. In the filtering optimization method of the present application, the initialization scheme based on the maximum distance method of the present application can initialize the initial weight matrix with the minimum similarity, ensure a large inter-class distance, and thus improve the stability of the algorithm.
[0077] Fourth, in the late iteration of the clustering process, the weight matrix of some classes may disappear due to the division of samples, that is, the attribute values of the same attribute of the samples in the class have different values, resulting in no samples being divided into these classes in the next iteration cycle, causing the problem of missing classes, which will quickly fall into the problem of local optimality, and ultimately affect the inter-class distance and intra-class distance of the clustering. In the filtering optimization method of the present application, the present application checks the number of classes after each clustering operation is completed, and constructs the weight matrix of the missing class through the samples of the non-empty class to improve the algorithm's exploration ability during the iteration process and avoid falling into the local optimal situation.
[0078] The filtering optimization method of the present application is exemplarily described below in conjunction with an exemplary implementation.
[0079] First, step S1 is performed, i.e., data collection: obtaining CAN message samples that need to be clustered, and encoding them to form a sample set , is the sample size. , a total of attributes, each with ,have attribute value.
[0080] Assume that 4 CAN message samples that need to be clustered are obtained. After encoding, the following sample set is formed:
[0081]
[0082] In the formula, is the attribute value set for each attribute. Therefore, each sample has 5 attributes and 6 attribute values, namely =5, =6.
[0083] Next, proceed to step S2, i.e., initialize the weight matrix: first determine the number of clusters , from the sample set Randomly select a sample from and divide it into the initial class , generating a Right now The initial weight matrix . Represents the weight matrix of the first class in the first iteration cycle
[0084] Assume that the number of clusters , then randomly select a sample and assign it to the initial class , assuming that the selected sample is ,Will Divide into categories ,So In two-dimensional space, the distribution is as follows:
[0085] #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg# #timg#
[0086] again Matrix Elements The calculation formula is:
[0087]
[0088] In the formula, Indicates The number of samples in each class, Indicated in All samples in the class The attribute value of the attribute The number of
[0089] Then, the generated The weight matrix for:
[0090]
[0091] Using Classes The weight matrix is used to calculate the similarity between the remaining samples and the samples with the lowest similarity. Initial second class , then use Calculate the second weight matrix, and then use the maximum distance method to determine the remaining initial classes and weight matrices until there is weight matrix. Samples The calculation formula is:
[0092]
[0093] is the number of classes that have been initialized. To find the order Smallest , The measurement formula for similarity is: ;
[0094] Calculate the remaining samples and weight matrix Similarity:
[0095]
[0096]
[0097]
[0098] Knowable ,choose Classification into the second initial class , the production weight matrix . Because two weight matrices have been initialized, , proceed to step S3;
[0099] Then proceed to step S3, that is, use the weight matrix to cluster the samples and assign the sample with the greatest similarity to the weight matrix to the class to which it belongs:
[0100]
[0101]
[0102] In the formula, is the subscript of the class, It means to find the class with the greatest similarity to the sample, the obtained ζ is the subscript of the class, and then put the sample into the class with the subscript ζ; calculate the similarity between each sample and each weight matrix, for example, calculate the sample Similarity with each weight matrix:
[0103]
[0104]
[0105] because ,Will Put into class Then divide the remaining samples in turn, and finally have:
[0106]
[0107]
[0108] Then proceed to step S4, i.e., determine whether there is a class that is empty, i.e., whether the number of classes is less than , if it is less than , then the samples in the non-empty class with the lowest similarity to its weight matrix are divided into the empty class until there is no empty class, because the current and Neither is an empty class, so you can proceed to the next step.
[0109] Then proceed to step S5, that is, calculate the intermediate weight matrix of each class according to the element calculation formula of the weight matrix in step S2 , and then recursively update the weight matrix for the next iteration according to the following formula:
[0110]
[0111] In the formula, is a constant coefficient, Indicates Iteration cycle.
[0112] For example, according to the clustering result class of the current iteration cycle ,statistics Distribution information generation class The intermediate weight matrix Can be:
[0113]
[0114] Then according to and calculate And so on, update the remaining The weight matrix .
[0115] Then, step S6 is performed, that is, judging whether the end condition is met. If the end condition is met, the process proceeds to step S7; otherwise, the process proceeds to step S3.
[0116] Finally, step S7 can be performed, that is, extracting the features of each class after clustering is completed and deploying them to the actual CAN hardware message filter.
[0117] In one embodiment of the present application, in step S2, the determined number of clusters Satisfies: Number of clusters The maximum value is the number of hardware message filters in the CAN controller.
[0118] In this embodiment, it can be understood that the number of clusters The selection range is limited by the number of hardware message filters, so the number of clustering classes The maximum value of is the number of hardware message filters in the CAN controller. At the same time, it can be understood that the number of clusters The minimum value should be greater than or equal to 2, because when the number of clusters When it is 1, clustering will be meaningless.
[0119] In one implementation of the present application, in step S4, if no class is empty, directly proceed to step S5.
[0120] In one implementation of the present application, in step S6, the end condition is: reaching the maximum number of iterations, or the weight matrix no longer changes.
[0121] It is understandable that the end condition can be selected according to the actual situation or the clustering effect, and this application does not make any specific limitation on this.
[0122] According to the second aspect of the present application, a filtering optimization system is further provided, characterized in that it is applied to the filtering optimization method in any technical solution in the first aspect of the present application, and the filtering optimization system comprises:
[0123] A data acquisition module is used to obtain CAN message samples that need to be clustered;
[0124] The data processing module is used to encode the acquired CAN message samples to generate a sample set; and to execute the step of initializing the weight matrix; and to use the weight matrix to cluster the samples, and assign the samples with the greatest similarity to the weight matrix to the class to which they belong; and to determine whether there is an empty class. If a class is empty, the sample with the lowest similarity to its weight matrix in the non-empty class is used as a new class to replace the empty class, until the number of classes is ; and used to calculate the intermediate weight matrix for each class ; and is used to determine whether the end condition is met; and is used to extract the characteristics of each class after clustering is completed, and is deployed in the CAN message filter to realize message filtering of the CAN message filter.
[0125] The filtering optimization system of the present application can avoid the tedious manual configuration, effectively improve the accuracy of the filter, filter out useless CAN messages more thoroughly and effectively, effectively improve the utilization of the embedded system CPU, and reduce CPU occupancy.
[0126] According to the third aspect of the present application, a computer device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the filtering optimization method in any technical solution in the first aspect of the present application can be implemented.
[0127] It is understood that in this embodiment, the memory may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid state drive; in addition, the memory may also include a combination of the above-mentioned types of memory. This application does not specifically limit this.
[0128] Similarly, the processor may be a processor that implements or executes various exemplary logic steps described in conjunction with the disclosure of the present application. The processor may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. It may implement or execute various exemplary logic steps described in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0129] According to the fourth aspect of the present application, a readable medium is also provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the filtering optimization method in any technical solution in the first aspect of the present application can be implemented.
[0130] In this embodiment, the readable medium, for example, can be but not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (Random Access Memory, RAM), a read-only memory (Read-Only Memory, ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM), a register, a hard disk, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of readable medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC). In the embodiments of the present application, the readable medium may be any tangible medium that contains or stores a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0131] According to a fifth aspect of the present application, a vehicle is also provided, which includes the filtering optimization system as described in the second aspect of the present application.
[0132] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A filtering optimization method, characterized in that: The message filtering for CAN controller includes the following steps: Step S1, data collection: obtain CAN message samples that need to be clustered, and encode them to generate a sample set ,in, ; For the number CAN message samples, each CAN message sample Total attributes, namely, , each attribute has attribute values, that is, ; Step S2, initialize the weight matrix: determine the number of clustering classes , and from the sample set A sample is randomly selected as and divide it into the initial class , generating a The initial weight matrix ; In the formula, Represents the weight matrix of the first class in the first iteration cycle. The element calculation formula of the weight matrix is: In the formula, Indicates The number of samples in each class, Indicated in All samples in the class The attribute value of the attribute the number of Using Initial Class The weight matrix is used to calculate the similarity between the remaining samples and , and the sample with the lowest similarity is taken as Initial second class and use Calculate the weight matrix of the second class, and then use the maximum distance method to determine the remaining initial other classes and their weight matrices until there is weight matrix; among them, select Samples The calculation formula is: In the formula, is the number of classes that have been initialized. To find the order Smallest , is the similarity measurement formula, is the Kth weight matrix, ; Step S3, cluster the samples using the weight matrix, and assign the sample with the greatest similarity to the weight matrix to the class to which it belongs: In the formula, is the subscript of the class, It means finding the class with the greatest similarity to the sample, the obtained ζ is the subscript of the class, and then putting the sample into the class with subscript ζ; Step S4, determine whether there is a class that is empty. If there is a class that is empty, take the sample with the lowest similarity to its weight matrix in the non-empty class as a new class to replace the empty class, until the number of classes is ; Step S5, calculate the intermediate weight matrix of each class according to the element calculation formula of the weight matrix in step S2 , and then recursively update the weight matrix for the next iteration according to the following formula: In the formula, is a constant coefficient, Indicates Iteration cycles; Step S6, determine whether the end condition is met, if so, proceed to step S7, if not, proceed to step S3; Step S7, extracting the features of each class after clustering is completed, and deploying them to the CAN hardware message filter.
2. The filtering optimization method according to claim 1, characterized in that: In step S2, the number of clusters determined is Satisfies: Number of clusters The maximum value is the number of hardware message filters in the CAN controller.
3. The filtering optimization method according to claim 1, characterized in that: In step S4, if no class is empty, the process directly proceeds to step S5.
4. The filtering optimization method according to claim 1, characterized in that: In step S6, the end condition is: reaching the maximum number of iterations, or the weight matrix no longer changes.
5. A filtering optimization system, characterized in that: The filtering optimization method according to any one of claims 1 to 4, wherein the filtering optimization system comprises: A data acquisition module is used to obtain CAN message samples that need to be clustered; The data processing module is used to encode the acquired CAN message samples to generate a sample set; and to execute the step of initializing the weight matrix; and to use the weight matrix to cluster the samples, and assign the samples with the greatest similarity to the weight matrix to the class to which they belong; and to determine whether there is an empty class. If a class is empty, the sample with the lowest similarity to its weight matrix in the non-empty class is used as a new class to replace the empty class, until the number of classes is ; and used to calculate the intermediate weight matrix for each class ; and is used to determine whether the end condition is met; and is used to extract the characteristics of each class after clustering is completed, and is deployed in the CAN message filter to realize message filtering of the CAN message filter.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the filtering optimization method according to any one of claims 1 to 4 can be implemented.
7. A readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the filtering optimization method according to any one of claims 1 to 4 can be implemented.
8. A vehicle, characterized in that: Comprising the filtering optimization system as described in claim 5.
Citation Information
Patent Citations
Local self-adaptive WNN (Wavelet Neural Network) training system, device and method
CN103676649A
Message filtering method and device and electronic equipment
CN109861949A
K-means clustering method for self-learning attribute weights
CN110378402A
Clustering-based side window filter optimization method
CN111784610A
Particle filtering method based on state trajectory clustering similarity and application
CN116054780A
