Rule inference method based on improved rete algorithm

By improving the Rete algorithm and using the database and decision tree model to sort and optimize rule conditions, the problems of reducing shared nodes and the influence of redundant conditions in the rule network are solved, and the efficiency of rule reasoning is improved.

CN115392466BActive Publication Date: 2025-10-10BEIJING UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211009172.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-22
Publication Date
2025-10-10
Estimated Expiration
2042-08-22

AI Technical Summary

Technical Problem

When constructing a rule network, the existing Rete rule inference algorithm has unreasonable condition sorting, which leads to a reduction in the number of shared nodes, an increase in memory usage, and a reduction in inference efficiency. In particular, invalid matches are serious when encountering strong restrictive conditions.

Method used

By mixing the database and decision tree model, the rule conditions are reordered and optimized, a rule decision tree is constructed, the Rete rule network structure is optimized, redundant conditions are filtered, and the node sharing rate is improved.

Benefits of technology

It effectively improves the node sharing rate and reasoning efficiency of the Rete rule network, simplifies the network structure, and improves the efficiency of rule matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115392466B_ABST
    Figure CN115392466B_ABST
Patent Text Reader

Abstract

The application discloses a rule reasoning method based on an improved Rete algorithm, improves the Rete rule matching algorithm in a mixed mode of database technology and a decision tree model, and proposes the rule reasoning method based on the improved Rete algorithm. In the process of constructing a rule network of the Rete algorithm, unreasonable rule condition sorting can cause the reduction of the number of shared nodes, thereby reducing the reasoning efficiency, and when the rule conclusion is influenced by many factors, the sorting position of a strong restrictive condition can also affect the final reasoning efficiency. Therefore, the application proposes the rule reasoning method based on the improved Rete algorithm, which can simplify the rule reasoning process and improve the rule reasoning efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent manufacturing, and specifically relates to a rule-based reasoning method based on an improved Rete algorithm. This method addresses the rule matching portion of rule-based reasoning technology, improves the node sharing rate of the Rete rule network and simplifies the Rete rule network by improving the Rete rule matching algorithm, effectively improving the efficiency of rule reasoning. Background Art

[0002] Rule-based reasoning is a process that expresses the empirical knowledge of experts in a particular field in a computer-readable form of rules. Computers can use these rules to autonomously solve new problems. The problem-solving process involves repeatedly searching for appropriate rules from a rule base and executing them. The Rete rule-based reasoning algorithm saves a large number of matching states during execution, significantly reducing recalculation. Therefore, most rule engines are based on the Rete algorithm. However, when constructing the Rete algorithm's rule network, the order of the conditions in the rules determines the number of shared nodes and, consequently, the order in which each condition is connected. Improper condition ordering can reduce the number of shared nodes, increase the memory usage of the inference system, and thus reduce inference efficiency. Furthermore, when encountering rules with multiple factors influencing the conclusion, the order of strongly restrictive conditions can also affect the final inference efficiency. Placing strongly restrictive conditions at the end of the order can result in a large number of invalid matches.

[0003] In order to improve the node sharing rate of the Rete rule network and optimize the rule network structure so as to effectively improve the rule reasoning efficiency, the present invention proposes a rule reasoning method based on the improved Rete algorithm. Summary of the Invention

[0004] The purpose of the present invention is to provide a rule reasoning method based on an improved Rete algorithm, which improves the Rete rule matching algorithm by hybrid means of database and decision tree model, so as to improve the node sharing rate of the Rete rule network and optimize the network structure, thereby improving the efficiency of rule reasoning.

[0005] A rule reasoning method based on an improved Rete algorithm includes the following steps:

[0006] Step 1: Reorder the rule conditions through the database.

[0007] Step 1.1: Create a corresponding condition library for each rule library in the database. Extract the prerequisites for each rule in the rule library and store them in the condition library. Calculate the frequency of occurrence of each condition in the condition library and sort them from high to low frequency.

[0008] Step 1.2: Reorder the premise conditions in each rule in the rule base. According to the order of each condition in the condition base, reorder the premise conditions in each rule in the rule base. The conditions with higher order in the condition base need to be placed in the front position in the rule.

[0009] Step 2: Construct a rule decision tree model by calculating information entropy.

[0010] Step 2.1: After the condition sorting operation in step 1, the rules in the rule base are divided into two parts: premise conditions and categories.

[0011] Step 2.2: The original formula for calculating information entropy is as follows:

[0012]

[0013] where p(x i ) represents the probability of the random event X being x i .

[0014] First, calculate the category information entropy, which represents the sum of the uncertainty of various conclusion categories in all rule samples. The subsequent condition information entropy and the splitting information of the condition are calculated from this formula.

[0015] Step 2.3: Calculate the condition information entropy. The greater the information entropy of a condition attribute, the more inconsistent the sample conclusion categories in this attribute.

[0016] Step 2.4: Calculate the information gain, which is the reduction in information uncertainty. Information gain = category information entropy - condition information entropy.

[0017] Step 2.5: Calculate the splitting information of the condition.

[0018] Step 2.6: Calculate the information gain rate, which is the ratio of information gain to splitting information. Information gain rate = information gain / splitting information.

[0019] Step 2.7: Select the condition with the highest information gain rate as the most restrictive condition.

[0020] Step 2.8: Repeat steps 2.2 to 2.7 to calculate the restrictiveness of other conditions.

[0021] Step 2.9: Construct a rule decision tree based on the restrictiveness of each condition.

[0022] Step 3: Determine the restrictive conditions through the decision tree model to optimize the structure of the Rete rule network.

[0023] According to the rule decision tree established in step 2, the prerequisites of the rules in the database are optimized, the redundant conditions in the prerequisites are filtered out, the Rete rule network is simplified, and the efficiency of rule reasoning is improved.

[0024] The beneficial effects of the present invention are: in order to solve the problems that when constructing the Rete rule network in rule reasoning, the unreasonable sorting of prerequisites leads to a reduction in the number of shared nodes and the redundant conditions in the prerequisites affect the reasoning efficiency, the Rete algorithm is improved by hybridizing the database and the decision tree model, and a rule reasoning method based on the improved Rete algorithm is proposed to achieve the purpose of improving the node sharing rate of the Rete rule network and optimizing the network structure, thereby improving the rule reasoning efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is the Rete rule network diagram before condition sorting improvement.

[0026] Figure 2 Improved Rete rule network diagram for condition sorting.

[0027] Figure 3 This is the decision tree for gate form.

[0028] Figure 4 This is the Rete rule network diagram before improvement using decision tree.

[0029] Figure 5 This is the improved Rete rule network diagram using decision tree. DETAILED DESCRIPTION

[0030] The technical solution of the present invention is described in detail below with reference to the accompanying drawings:

[0031] Step 1: Reorder the rule conditions through the database.

[0032] Step 1.1:

[0033] Establish a rule condition library and count the frequency of occurrence of each condition in the condition library. Use SQL database to establish a corresponding condition library for the rule library, extract the prerequisites of each rule in the rule library and store them in the condition library.

[0034] When the rule base contains two rules, Rule1 and Rule2, and four conditions, C1, C2, C3, and C4, Rule1 consists of conditions C1, C2, and C3, and Rule2 consists of conditions C1, C2, and C4, the order of the rule conditions is as follows:

[0035] Rule1: IF C1∪C2∪C3 THENA1

[0036] Rule2: IF C4∪C1∪C2 THENA2

[0037] Conditions C1 and C2 appear most frequently, so the order of the conditions in the condition library is C1, C2, C3, and C4.

[0038] Step 1.2:

[0039] Reorder the prerequisites in each rule in the rule base. Reorder the prerequisites in each rule based on the order of the conditions in the condition base. The initial order of conditions in Rule 2 (C4, C1, and C2) is incorrect. You need to place conditions C1 and C2 at the front of the rule, i.e., Rule 2 (C1, C2, and C4).

[0040] Before the rule condition sorting is improved, the Rete rule network is constructed as follows Figure 1 As shown, the improved Rete rule network is constructed as Figure 2 As shown. Figure 1 and Figure 2 It can be seen intuitively that the order of conditions in the rule will directly affect the number of Beta nodes in the Rete rule network. Figure 2 When the order of rule conditions is arranged reasonably, Beta nodes are effectively shared, reducing the memory space occupied by the rule network, and ultimately making the Rete algorithm matching more efficient.

[0041] Step 2: Construct a rule decision tree model by calculating information entropy.

[0042] This paper constructs a decision tree to identify strong restrictive conditions and simplify the prerequisites of rules. The resulting Rete rule network is simpler and more efficient. The decision tree is used to determine and select strong restrictive conditions, and rules are split based on these conditions, simplifying the structure of the Rete rule network.

[0043] Taking gate design in mold structure design as an example, the process of building a decision tree is introduced in detail. The gate design rules are shown in Table 1.

[0044] Table 1 Gate form rules

[0045]

[0046] Step 2.1:

[0047] The rules in the rule base are divided into two parts: preconditions and categories. The condition attribute set A = {plastic part shape, plastic part volume, material viscosity, appearance quality requirements, plastic part wall thickness}, and the category set B = {side gate, point gate, latent gate}.

[0048] Step 2.2:

[0049] The conclusion class information entropy Info(B) is calculated, and its original formula is expressed as follows:

[0050]

[0051] where p(x i ) represents the probability of the random event X being x i , and the subsequent conditional information entropy and conditional split information are calculated by this formula.

[0052] According to the class set B, the gate class is divided into 3 classes in the 9 rules: 5 for point gate, 2 for side gate, and 2 for latent gate. Therefore, the class information entropy is calculated as follows:

[0053] Info(B) = -5 / 9*log2(5 / 9) - 2 / 9*log2(2 / 9) - 2 / 9*log2(2 / 9) = 1.436

[0054] Step 2.3:

[0055] The information entropy Info(A) of each conditional attribute is calculated. A1, A2, A3, A4, and A5 represent the shape of the plastic part, the volume of the plastic part, the material viscosity, the appearance quality requirement, and the wall thickness of the plastic part, respectively. Attribute A1 is divided into 3 classes: flat, cylindrical, and shell. Among the 3 rules corresponding to flat, 2 rules have the conclusion class of point gate, and 1 rule has the conclusion class of side gate. Among the 3 rules corresponding to cylindrical, 2 rules have the conclusion class of point gate, and 1 rule has the conclusion class of latent gate. Among the 3 rules corresponding to shell, the conclusion classes are different. According to formula (3-16), the information entropy calculation process of attribute A1 is as follows:

[0056]

[0057] Therefore, the information entropy calculation results of each conditional attribute are: Info(A1) = 1.141, Info(A2) = 0.918, Info(A3) = 0.539, Info(A4) = 0.984, and Info(A5) = 0.984

[0058] Step 2.4:

[0059] The information gain Gain(A) is calculated, which is the difference between the class information entropy and the attribute information entropy. The information gain calculation results of each conditional attribute are as follows:

[0060] Gain(A1)=0.295, Gain(A2)=0.518, Gain(A3)=0.897, Gain(A4)=0.452, Gain(A5)=0.452

[0061] Step 2.5:

[0062] Calculate the splitting information C(A) of the conditional attribute. Attribute A1 is divided into flat, cylindrical, and shell shapes. Among the 9 rules, flat, cylindrical, and shell shapes each account for 3 rules. According to formula (2), the splitting information metric calculation process of attribute A1 is as follows:

[0063]

[0064] The calculation results of the splitting information amount of each conditional attribute are: C(A1)=1.585, C(A2)=1.585, C(A3)=1.436, C(A4)=0.991, C(A5)=0.991.

[0065] Step 2.6:

[0066] Calculate the information gain rate IGR(A), information gain rate = information gain / split information amount. The information gain rate of each condition attribute is calculated as follows:

[0067] IGR(A1)=0.186, IGR(A2)=0.327, IGR(A3)=0.625, IGR(A4)=0.456, IGR(A5)=0.456

[0068] Step 2.7:

[0069] The condition with the highest information gain rate is selected as the most restrictive condition. The above calculation results show that material viscosity has the highest information gain rate, making it the optimal splitting attribute. After splitting, the gate categories are consistent for both "high" and "medium" material viscosities. However, the conclusions for "low" material viscosity remain inconsistent, requiring further classification, as shown in Table 2.

[0070] Table 2 Classification of low viscosity materials

[0071]

[0072] Step 2.8:

[0073] Repeat steps 2.2 through 2.7 to calculate and determine the restrictive rankings for other conditions. Based on the conditional attributes in Table 2, we continue to calculate the category information entropy, conditional attribute information entropy, information gain, attribute split information, and information gain rate. We find that the attributes appearance quality requirements and wall thickness have the highest information gain rates. By randomly selecting one of these attributes as the splitting point, we find that the gate categories after splitting are consistent, so the splitting is complete.

[0074] Step 2.9: Construct a rule decision tree based on the restrictive order of each condition, such as Figure 3 shown.

[0075] Step 3: Determine the restrictive conditions through the decision tree model to optimize the structure of the Rete rule network.

[0076] According to step 3, a decision tree in the form of a gate is established to optimize the premise conditions of the rules in the database, filter out redundant conditions in the premise conditions, and improve the efficiency of rule reasoning.

[0077] Two rules are selected from the gate form rules in Table 1 as follows to introduce in detail the process of simplifying rules of the decision tree model.

[0078] Rule 1: IF A1. Flat Part ∪ A2. Large ∪ A3. High ∪ A4. Low ∪ A5. Thick THEN Point Gate

[0079] Rule 2: IF A1. Flat ∪ A2. Medium ∪ A3. Low ∪ A4. Low ∪ A5. Thick THEN Side Gate

[0080] according to Figure 3 The gate form decision tree shows that the material viscosity is "high," which is A3. High is a strongly restrictive condition. The appearance quality requirement attribute is second only to the material viscosity attribute in terms of restrictiveness, so it needs to be placed at the front of the Rete rule network. Therefore, after the decision tree is improved, the judgment of attributes A1, A2, and A5 is filtered out. The above two rules can be split and processed as shown below.

[0081] Rule 1: IF A3. High THEN point gate

[0082] Rule 2: IF A3.Low ∪ A4.Low THEN Side Gate

[0083] Condition C1 represents A1. Flat, C2 represents A4. Low, C3 represents A5. Thick, C4 represents A2. Large, C5 represents A2. Medium, C6 represents A3. High, and C7 represents A3. Low. Therefore, Rule 1 consists of conditions C1, C2, C3, C4, and C6, and Rule 2 consists of conditions C1, C2, C3, C5, and C7.

[0084] According to the above two rules, a Rete rule network is established, and its improvement is as follows:Figure 4 As shown and Figure 5 When building a Rete rule network, placing the restrictive conditions in the front can filter out a large amount of initial condition information first, which can reduce the temporary matching results in the rule network. Figure 5 It can be seen that the construction of the decision tree effectively simplifies the Rete rule network, thereby improving the reasoning efficiency of rule reasoning.

Claims

1. The rule reasoning method based on the improved Rete algorithm is used for gate form design in mold structure design, which is characterized by: The Rete rule matching algorithm is improved by hybridizing the database and decision tree model to improve the efficiency of rule reasoning. The implementation of this method includes the following three steps: Step 1: Reorder the rule conditions through the database; Step 2: Construct a rule decision tree model by calculating information entropy; Step 3: Determine the restrictive conditions through the decision tree model to optimize the structure of the Rete rule network; In step 1, step 1.1: establish a corresponding condition library for each rule library in the database, extract the prerequisites of each rule in the rule library and store them in the condition library; Calculate the frequency of occurrence of each condition in the condition library and sort them from high to low in terms of frequency; Step 1.2: Reorder the preconditions in each rule of the rule base; Reorder the prerequisites in each rule in the rule base according to the order of each condition in the condition base; the conditions that are ranked higher in the condition base need to be placed at the front of the rule; Step 2: Construct a rule decision tree model by calculating information entropy; Step 2.1: After the condition sorting operation in step 1, the rules in the rule base are divided into two parts: preconditions and categories; the condition attribute set A = {plastic part shape, plastic part volume, material viscosity, appearance quality requirements, plastic part wall thickness}, and the category set B = {side gate, point gate, latent gate}; Step 2.2: The original formula for calculating information entropy is as follows: (1) in, The random event X is represented by probability; First, the category information entropy is calculated. The category information entropy represents the sum of the uncertainties of the various conclusion categories in all rule samples. The subsequent conditional information entropy and the conditional split information are calculated using this formula. Step 2.3: Calculate the conditional information entropy. The larger the information entropy of the conditional attribute, the more inconsistent the sample conclusion categories in this attribute are. Step 2.4: Calculate information gain, information gain = category information entropy - conditional information entropy, which represents the degree of reduction in information uncertainty; Step 2.5: Calculate the split information of the condition; Step 2.6: Calculate the information gain rate, information gain rate = information gain / split information amount; Step 2.7: Select the condition with the largest information gain rate as the most restrictive condition; Step 2.8: Repeat steps 2.2 to 2.7 to calculate the restrictive ranking of other conditions; Step 2.9: Construct a rule decision tree based on the restrictive ranking of each condition.

Citation Information

Patent Citations

  • High-share Rete network construction method

    CN106127306A

  • Method for pushing field operation and maintenance information of power communication network based on Apriori and RETE

    CN111292201A