CN102999324A - Establishing method and system of Rete network - Google Patents

Establishing method and system of Rete network Download PDF

Info

Publication number
CN102999324A
CN102999324A CN2011102776530A CN201110277653A CN102999324A CN 102999324 A CN102999324 A CN 102999324A CN 2011102776530 A CN2011102776530 A CN 2011102776530A CN 201110277653 A CN201110277653 A CN 201110277653A CN 102999324 A CN102999324 A CN 102999324A
Authority
CN
China
Prior art keywords
node
rete
child nodes
type
present
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2011102776530A
Other languages
Chinese (zh)
Other versions
CN102999324B (en
Inventor
郑叔亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing State Owned Financial Leasing Co.,Ltd.
Original Assignee
STAR SOFTWARE TECHNOLOGY CO LTD
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by STAR SOFTWARE TECHNOLOGY CO LTD filed Critical STAR SOFTWARE TECHNOLOGY CO LTD
Priority to CN201110277653.0A priority Critical patent/CN102999324B/en
Publication of CN102999324A publication Critical patent/CN102999324A/en
Application granted granted Critical
Publication of CN102999324B publication Critical patent/CN102999324B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an establishing method and system of a Rete network. The method comprises the following steps of: establishing an expression tree of a current rule and determining a root node of the expression tree; taking the root node as a current node, judging attribution states of two child nodes of the current node; establishing a Rete local network corresponding to the current node according to the attribution states obtained by judging; and establishing a final node of the Rete network and taking the final node as a child node of a Rete node corresponding to the current node. According to the method and the system disclosed by the invention, the establishment of the Rete network can be carried out based on a rule language provided by the embodiment of the invention.

Description

A kind of method for building up of Rete network and system
Technical field
The present invention relates to rule engine technique, relate in particular to a kind of method for building up and system of Rete network.
Background technology
Rule engine technique has possessed quite complete theoretical foundation, and develops the product of a lot of maturations.Various fields all with regulation engine as the support technology of realizing key business, such as telecommunications, bank, insurance, etc.Rule engine technique the IF-THEN production rule language that generally adopts be a kind of the most succinct of Description of Knowledge and method intuitively.Rule engine technique is the logic that system is soluble and carry out with the representation conversion of this knowledge then, thereby realizes the combination and unification of data, information and knowledge.
General, in regulation engine, with rale store in default rule base, the facts object that will mate is stored in the work internal memory, by the concentrated strictly all rules of specified rule in the pattern matcher calling rule storehouse, the production pattern that each is regular extracts sets up the Rete network, the facts object of needs coupling is imported in this Rete network carried out rule match, obtains rule corresponding to facts object.
Above-mentioned rule is described by rule language.Although the regulation engine product of main flow is being obtained good effect aspect the hommization Rule Expression at present, its kernel is not all simplified and is transformed.That is to say that the more complicated rule language that the rule language of presenting to the business personnel all needs to be mapped to bottom just can be performed.Although the complexity that has reduced on the surface exploitation and safeguarded has increased pattern matcher and has processed the complexity of described rule, and do not had the complexity of decline law store and management.And according to the experience of reality, the business personnel is difficult to the disposable correct rule of writing out, and often needs the software engineer that bottom rule code is debugged.
In order to promote easily writing property and the ease for use of rule as far as possible, the regulation engine product all provides the rule editing interface for the business personnel.These interfaces can guide the user to write out correct rule to a certain extent, but still have presented the phenomenon that a kind of natural language and rule language mix, and make the business personnel produce puzzlement.The basic reason that causes this situation is exactly fundamentally rule language not to be carried out the transformation of syntax and semantics aspect, and regulation engine itself does not carry out special optimization to specific language construction yet, so execution performance does not promote; Further, existing Rete network creating method also is to set up corresponding Rete network for existing rule language.
Summary of the invention
In view of this, the technical problem to be solved in the present invention is, a kind of Rete network creating method and system are provided, and carries out the foundation of Rete network based on a kind of rule language of new proposition.
For this reason, the embodiment of the invention adopts following technical scheme:
The embodiment of the invention provides a kind of Rete network creating method, comprising:
Make up the expression tree of current rule, determine the root node of this expression tree;
Described root node as present node, is judged the attribute status of two child nodes of present node;
If have a child nodes at least in two child nodes neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return described determining step;
If two child nodes all are factor expression formula nodes, then make up the corresponding Rete localized network of present node according to two factor expression formula nodes; If two child nodes all are processing nodes, then according to two processing node make up the corresponding Rete localized network of present node; If two one of child nodes are factor expression formula nodes, one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node;
Create the finish node of Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
Describedly make up the corresponding Rete localized networks of present node according to two factor expression formula nodes and comprise:
Determine the associated model of condition element of two child nodes;
The condition element of two child nodes of judgement is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes;
Judge respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The condition element of two child nodes of judgement is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
Judge related model of condition element of a child nodes in two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The condition element of judging two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.
Making up the corresponding Rete localized network of present node according to processing node comprises:
When the arithmetic type of judging present node is the AND computing, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node;
When the arithmetic type of judging present node is the OR computing, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.
According to factor expression node and processing node make up the corresponding Rete localized network of present node and comprise:
When the arithmetic type of judgement present node is the AND computing, determine two models that child nodes is associated of present node;
If the associated model of two child nodes is identical, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
If two model differences that child nodes is associated, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
Judge when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
The embodiment of the invention also provides a kind of Rete network to set up system, comprising:
Construction unit for the expression tree that makes up current rule, is determined the root node of this expression tree;
Judging unit is used for described root node judging the attribute status of two child nodes of present node as present node;
The first processing unit, if be used for that two child nodes have a child nodes at least neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return judging unit and proceed described judgement;
The second processing unit all is factor expression formula node if be used for two child nodes, then makes up the corresponding Rete localized network of present node according to two factor expression formula nodes;
The 3rd processing unit all is processing node if be used for two child nodes, then according to two processing node make up the corresponding Rete localized network of present node;
The manages the unit everywhere, is factor expression formula node if be used for two one of child nodes, and one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node;
Creating unit is for the finish node that creates the Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
The second processing unit comprises:
First determines subelement, is used for determining the associated model of condition element of two child nodes;
First processes subelement, condition element that be used for to judge two child nodes is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes;
Second processes subelement, be used for judging respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 3rd processes subelement, condition element that be used for to judge two child nodes is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
Manages subelement everywhere, be used for judging related model of condition element of a child nodes of two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 5th processes subelement, condition element that be used for to judge two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.
The 3rd processing unit comprises:
The 6th processes subelement, when being the AND computing for the arithmetic type of judging present node, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node;
The 7th processes subelement, when being the OR computing for the arithmetic type of judging present node, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.
Manages the unit everywhere comprises:
Second determines subelement, when being the AND computing for the arithmetic type of judging present node, determines two models that child nodes is associated of present node;
The 8th processes subelement, determine that the associated model of two definite child nodes of subelement is identical if be used for second, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The 9th processes subelement, determine the associated model difference of two child nodes that subelement is determined if be used for second, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The tenth processes subelement, be used for judging when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
Technique effect for technique scheme is analyzed as follows:
Make up the expression tree of current rule, determine the root node of this expression tree; Described root node as present node, is judged the attribute status of two child nodes of present node; If have a child nodes at least in two child nodes neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return described determining step; If two child nodes all are factor expression formula nodes, then make up the corresponding Rete localized network of present node according to two factor expression formula nodes; If two child nodes all are processing nodes, then according to two processing node make up the corresponding Rete localized network of present node; Carry out the step of the finish node that creates the Rete network; If two one of child nodes are factor expression formula nodes, one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node; Create the finish node of Rete network, with the child nodes of finish node as the corresponding Rete node of present node.Processing by above step, realized the foundation of the corresponding Rete network of expression tree, also namely realized the foundation of regular corresponding Rete network, and then realized setting up Rete network corresponding to each rule based on the rule language that the embodiment of the invention provides.
Description of drawings
Fig. 1 is embodiment of the invention Rete localized network structural representation;
Fig. 2 is a kind of Rete network creating method of embodiment of the invention schematic flow sheet;
Fig. 3 is the another kind of Rete network creating method of embodiment of the invention schematic flow sheet;
Fig. 3 a is that a kind of regular expression tree construction of the embodiment of the invention is given an example;
Fig. 4 a~Fig. 4 d is that the constructed Rete localized network structure of the different factor expression trees of the embodiment of the invention is given an example;
Fig. 5 is that embodiment of the invention Rete network is set up the system architecture synoptic diagram.
Embodiment
For the ease of understanding Rete network creating method and the system of the embodiment of the invention, at first to embodiment of the invention Rete network creating method and system based on the language syntax of rule be introduced.
One, about described rule language
1, syntax gauge
At first, illustrate the actual institute of the present invention based on the syntactic structure of rule language define.
Following giving an example for the syntax gauge of coming the description rule language with a kind of context-free grammar of BNF normal form statement:
1.<RuleExpression>::=[(]<FactorExpression>[)][<SimpleLogicSymbol>
[(]<RuleExpression>[)]]
2.<FactorExpression>::=<FactorIdentity>{<BooleanExpression>|
<NumericExpression>|<StringExpression>|<EnumExpression>|
<TemporalExpression>|<ObjectExpression>|<ConstantSetExpression>|
<ObjectSetExpression>}
3.<FactorIdentity>::={<ModelName>|<FactorIdentity>}::<FactorName>
4.<BooleanExpression>::={==|!=}{<BooleanConstant>|<FactorIdentity>}
5.<NumericExpression>::={==|!=|>|<|>=|<=}{<NumericLiteral>|
<FactorIdentity>}
6.<StringExpression>::={==|!=}{<CharacterList>|<FactorIdentity>}
7.<EnumExpression>::={==|!=}{<EnumConstant>|<FactorIdentity>}
8.<TemporalExpression>::={==|!=|>|<}{<TemporalLiteral>|<FactorIdentity>}
9.<ObjectExpression>::={meet|not?meet}<RuleExpression>
10.<ConstantSetExpression>::={contain|not?contain}{<NumericLiteral>...|
<CharacterList>...|<TemporalLiteral>...}
11.<ObjectSetExpression>::={contain|not?contain|for?all}<ObjectExpression>
12.<SimpleLogicSymbol>::=AND|OR
13.<BooleanConstant>::=TRUE|FALSE
14.<NumericLiteral>::=<IntegerLiteral>|<DecimalLiteral>
15.<IntegerLiteral>::=[+|-]<WholeNumber>
16.<DecimalLiteral>::=[+|-]<WholeNumber>[.<WholeNumber>]|[+|
-]<WholeNumber>.|[+|-].<WholeNumber>
17.<TemporalLiteral>::=<DateLiteral>|<TimeLiteral>
18.<DateLiteral>::=‘<years>-<months>-<days>’
19.<TimeLiteral>::=‘<hours>:<minutes>:<seconds>’
The meaning of the symbol that comprises for above rule language is described as follows: "<" and ">" and middle identifier have formed some syntactic elements of rule language.Symbol ": :=" represent that left part is by right part definition and refinement.Content in the middle of " [] " expression is optional, and namely can have not to have yet; And the content in the middle of " { } " expression is essential; In addition, these two kinds of brackets also define the associativity of syntactic structure." | " expression is selected, and a plurality of elements of namely being separated by " | " are relations of multiselect one.Other element then is character or the character string that directly is presented in the language.
The above has defined the condition part of rule language, it is the left part (LHS) of production, the right part of production (RHS) is not within the scope that the embodiment of the invention is considered, because all carry out for LHS in the time of real executing rule pattern match, RHS has successfully mated just in rule to carry out.This is the key character of production system, also is the main thought of research production rule language.Table 4-1 has provided several business rule examples of following this syntax gauge.
Table 1 rule language example and corresponding professional implication
Figure BDA0000092336770000101
Figure BDA0000092336770000111
2, semantic standard
Based on the syntax gauge that provides in 1, further the execution of restrictive rule language is semantic, following listed:
1. unique starting point of rule language is<RuleExpression 〉.
<RuleExpression be by logical connector (AND is connected connection<FactorExpression with OR〉regular expression that forms.The execution of AND and OR is semantic consistent with the Boolean operator of generally stipulating, expression " with " and "or".
3.<FactorExpression〉be by<FactorIdentity the condition element expression formula of guiding.
4.<and FactorIdentity〉by model name guiding, the factor identifier of heel factor title (can be multistage).
5. the condition element expression formula has polytype, comprises Boolean expression, numeral expression formula, string expression, enumerates these 8 types of expression formula, temporal expression, object expression, constant aggregate expression and object set expression formulas.
6. simple types expression formula (be Boolean expression, numeral expression formula, string expression, enumerate expression formula and temporal expression) both can compare with the constant of respective type, also can identify corresponding value with factor and compare (needing to guarantee that type is identical).
7. the condition element type of expression is operation platform (such as the JRE of Java, the CLR of the .NET etc.) mapping by model under the condition element.Different operation platforms can define different type systems, but all needs to be mapped to uniquely in 7 kinds of factor patterns that rule language supports.
8. for object expression, its semanteme is: whether the condition element of appointment satisfies the rule that a certain sub-rule expression formula is explained.Here require the operation platform type of the affiliated model of all conditions factor in the sub-rule consistent with the operation platform type of current object expression conditional factor.
9. for the constant aggregate expression, its semanteme is: whether the condition element of appointment comprises the constant value in the tabulation.The type of constant value can be numeral, character string and time on date.
10. for the object set expression formula, its semanteme is: whether the condition element of appointment comprises is satisfied the element that a certain sub-rule expression formula is explained rule, or all satisfies the rule that some sub-rule expression formulas are explained for all elements of set-inclusion.Here require the operation platform type of the affiliated model of all conditions factor in the sub-rule consistent with the operation platform type of current aggregate expression conditional factor.
11. regular expression should satisfy the matched rule of bracket on the whole.
3, above rule language can carry out the input of rule language by the business personnel by the mode of definition template is provided for the business personnel, and is concrete, and following two kinds of interfaces respectively realization condition factor and regular definition can be provided:
4.1 condition element is browsed panel: by tissue and the logical organization of flat and tree-shaped two kinds of views browsing condition elements.Allow the business personnel be expressly understood which condition element can be used for rule definition, and the implication of these factors and mutual relationship.This is the maximum prerequisite of correctly carrying out rule definition.If the business personnel can not these factors of correct understanding, the definition rule of how correctly also just not knowing where to begin.
4.2 rule definition panel: the main panel that is used for definition rule, the dirigibility that mode by dynamic generation UI control improves rule definition, according to type and the value of the contextual information bound controls such as factor pattern, operational symbol type, regular texture, can effectively guarantee the correctness of rule definition simultaneously.
Two, about the Rete network
The Rete network mainly is comprised of two category nodes, and a class is 1-input node (being called again the Alpha node), and a unique input end is arranged; The another kind of 2-input of being node (being called again the Beta node) has two input ends.The 1-input node is used for the detection in the condition element, i.e. the relatively detection of factor and constant, and the 2-input node is used for striding the detection of condition element, the i.e. relatively detection of factor and factor.Also have in addition two class special joints, the one, Ingress node, i.e. the starting point of Rete network, each Ingress node represents the model under a kind of pattern; The one, finish node, i.e. the terminal point of Rete network, each finish node represents a rule.The Alpha network that the first half of Rete network is comprised of the 1-input node, the Beta network that latter half is comprised of the 2-input node.
The described rule language of the embodiment of the invention is compared with traditional production rule language (such as OPS5), there are differences in following several respects:
1, is to connect with AND or OR between the factor expression formula, and uses bracket to limit associativity.Logically all be the relation of AND between the pattern of traditional production rule language, and comprise one or more factor expression formulas in each pattern.
2, the grammer that has nested rule is such as object expression and aggregate expression.There is not this grammer in traditional production rule.
Because the existence of above otherness, need to be to the Alpha node in traditional Rete algorithm and Beta node be expanded:
Simple condition factor Alpha node is designated as the SF-Alpha node.The effect of the Alpha node in this category node and the traditional Rete network establishing method is the same, is exactly to be used for calculating the most basic factor expression formula;
Nested networks condition element Alpha node is designated as the NF-Alpha node.This category node can be quoted a sub-Rete network, is used for object factor expression formula and set factor expression formula to the checking of sub-rule;
Simple condition factor Beta node is designated as the SF-Beta node.This category node is the same with the effect of the Beta node in traditional Rete network establishing method, is used for the relatively detection of factor and factor;
AND computing Beta node is designated as the AND-Beta node.This category node represent for the intermediate node of computing;
OR computing Beta node is designated as the OR-Beta node.This category node represents the intermediate node for exclusive disjunction.
More than these 5 kinds of nodes in the Rete network, can consist of several different local organization forms.Each organizational form can be regarded a kind of network element of part as.The organizational form that these are local is analyzed clear, helps the algorithm of our design construction expansion Rete network.Fig. 1 has showed the classification of all local network structures that exist in the Rete network, wherein:
1 type localized network: the localized network that is in series by two Alpha nodes (can be the SF-Alpha node, also can be the NF-Alpha node).This network possesses two key characters, and the one, these two Alpha nodes come from same Ingress node, and namely they have common model identification; The 2nd, WME need to pass through test on two nodes could pass through this network, so is the logical relation of AND between two Alpha nodes.
2 type SF localized networks: two Ingress nodes (E-Node) and the localized network that the SF-Beta node forms.This is the network form that forms for the SF-Beta node specially.Because the SF-Beta node model different from two is correlated with, so must be pooled to the SF-Beta node from two Ingress nodes.
2 type AND localized networks: two nodes are pooled to the localized network that an AND-Beta node forms.It is the logical operation relation of AND between these two nodes.
2 type OR localized networks: two nodes are pooled to the localized network that an OR-Beta node forms.It is the logical operation relation of OR between these two nodes.
Can construct the Rete network based on above analysis and following algorithm.Because AND and OR operational symbol are same other operational symbols of level in the basic structure of the rule language that the embodiment of the invention is designed, and there is bracket, so can initial rules be configured to an expression tree according to the computing priority of bracket definition, so just can remove the bracket in the rule, and not break original priority of operations.If do not have bracket on a certain a part or whole part of rule, this part just follows computation sequence from left to right so.So, the expression tree of structure is a binary tree.The leaf node of binary tree is exactly the condition element expression formula, and intermediate node is exactly AND or OR operational symbol.For the situation of nested rule, the leaf node of regular expression tree can be quoted a sub-expression tree.
The key data structure definition:
Figure BDA0000092336770000151
Figure BDA0000092336770000161
Below, be described with reference to the accompanying drawings the realization of embodiment of the invention Rete network creating method and system.
Fig. 2 is embodiment of the invention Rete network creating method schematic flow sheet, and as shown in Figure 2, the method comprises:
Step 201: make up the expression tree of current rule, determine the root node of this expression tree;
Step 202: described root node as present node, is judged the attribute status of two child nodes of present node;
If have a child nodes at least in two child nodes neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return described determining step;
If two child nodes all are factor expression formula nodes, then make up the corresponding Rete localized network of present node according to two factor expression formula nodes; If two child nodes all are processing nodes, then according to two processing node make up the corresponding Rete localized network of present node; Carry out the step of the finish node that creates the Rete network; If two one of child nodes are factor expression formula nodes, one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node; Execution in step 203.
Step 203: create the finish node of Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
Embodiment of the invention Rete network creating method shown in Figure 2, attribute status according to two child nodes of present node, correspondence establishment Rete localized network, pass through circular treatment, realized the foundation of the corresponding Rete network of expression tree, also namely realized the foundation of regular corresponding Rete network, and then realized setting up Rete network corresponding to each rule based on the rule language that the embodiment of the invention provides.
On the basis of Fig. 2, by Fig. 3 embodiment of the invention Rete network creating method is described in more detail.As shown in Figure 3, the method comprises:
Step 301: make up the expression tree of rule, determine the root node of this expression tree.
Wherein, AND and OR operational symbol are same other operational symbols of level in the basic structure of the described rule language of the embodiment of the invention, and there is bracket, so can rule be configured to an expression tree according to the computing priority of bracket definition, so just can remove the bracket in the rule, and not break original priority of operations.If do not have bracket on a certain a part or whole part of rule, this part just follows computation sequence from left to right so.Here, the expression tree of structure is a binary tree, and the leaf node of binary tree is exactly the condition element expression formula, and intermediate node is exactly AND or OR operational symbol.For the situation of nested rule, the leaf node of the expression tree of rule can be quoted a sub-expression tree.
Wherein, when not having bracket in the rule of processing in this step, last operational symbol is the root node of this expression tree.
For example, described rule is as follows:
Figure BDA0000092336770000181
The professional implication of this rule is:
If the amount of money of order more than or equal to 50 yuan/month or (order duration greater than 12 months and the order amount of money more than or equal to 30 yuan/month, less than 50 yuan/month) or (order duration greater than 24 months and the order amount of money more than or equal to 15 yuan/month, less than 30 yuan/month)
It is preferential to make a call to so 7.5 foldings;
Then, shown in Fig. 3 a, wherein, root node is the OR node of topmost based on the constructed expression tree of this rule.Exp1:Order::price>=50;Exp2:Order::validPeriod>12;Exp3:Order::price>=30;Exp4:Order::price<50;Exp5:Order::validPeriod>24;Exp6:Order::price>=15;Exp7:Order::price<30。
Step 302: with root node as present node, judge the attribute status of two child nodes of present node, if have a child nodes at least in two child nodes neither factor expression formula node, processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return the described determining step of step 302; If two child nodes all are factor expression formula nodes, execution in step 303; If two child nodes all are processing nodes, execution in step 304; If a child nodes is factor expression formula node, another child nodes is processing node, and then execution in step 305;
Wherein, if two child nodes all neither factor expression formula node, processing node then needs respectively with two child nodes to return step 302 as present node; Also namely, two child nodes all need to process.Here, can first one of them child nodes be carried out the processing of this child nodes respective branches as present node, after finishing dealing with, carry out again the processing of respective branches as present node with the another one child nodes.
Step 303: make up the corresponding Rete localized network of present node according to two factor expression formula nodes; Execution in step 306.
The realization of this step can comprise:
A1: the associated model of condition element of determining two child nodes;
In actual applications, can preset the corresponding relation between various condition elements and the model, thereby the condition element that can directly comprise according to child nodes in this step finds the associated model of condition element.
Described model refers to: with type, concept or the data entity of attribute, the order Order during for example aforementioned rule is given an example is a model.
Described condition element refers to: participate in the courtyard variable of regular computing, such as the order price, described condition element can be directly corresponding to the attribute of model, for example the price attribute of Order.
A2: model quantity and mutual relationship corresponding the make up Rete localized network associated according to the condition element of child nodes.This step specifically comprises:
The condition element of two child nodes of judgement is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes; For example provided the structure of expression tree among the left figure in Fig. 4 a, comprising: root node is the AND computing, two child nodes Exp1 and Exp2, and two associated models of child nodes are m1; Then the right side such as Fig. 4 a there is shown the 1 type localized network structure of setting up according to this expression tree structure, wherein, the corresponding model node of model m1 is as the Ingress node of 1 type localized network, and the Alpha1 in the 1 type localized network and Alpha2 node are respectively the corresponding Rete node of two child nodes of present node.Corresponding relation between two child nodes of the record here and the Rete node that is to say the corresponding relation between the Rete node in the expression tree node that record is above-mentioned and the Rete network that creates.Here the corresponding relation and in the subsequent step between two child nodes of record and the Rete node, for follow-up when setting up the corresponding Rete localized network of other expression tree nodes, relation between each Rete localized network of determining to create according to the relation between the expression tree node, for example in follow-up step 304 and 305, namely need further to create the Rete localized network according to the corresponding Rete node of node of having processed, thereby construct complete Rete network by continuous establishment.In addition, at record during described corresponding relation, can realize by the ReteNode attribute that expression tree node corresponding Rete address of node or sign is write the key data structure of this expression tree node in the embodiment of the invention.
Perhaps, judge respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes; For example provided the structure of expression tree among the left figure in Fig. 4 b, comprising: root node is the AND computing, two child nodes Exp1 and Exp2, and two associated models of child nodes are respectively m1 and m2; Then the right side such as Fig. 4 a there is shown the 1 type localized network structure of setting up according to this expression tree structure, wherein, the corresponding model node of model m1 and m2 is respectively as the Ingress node of 1 type localized network, and a father node Alpha1 in the 1 type localized network is as the corresponding Rete node of child nodes Exp1, another father node Alpha2 node is the corresponding Rete node of child nodes Exp2, is the corresponding Rete node of present node and compile node AND-Beta.
The condition element of two child nodes of judgement is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes; Here the process that creates the process of 2 type OR localized networks and aforementioned establishment 2 type AND localized networks is similar, no longer gives an actual example and gives unnecessary details, can be with reference to the example among Fig. 4 b, and difference only is that compiling node changes into OR-Beta.
Judge related model of condition element of a child nodes in two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes; For example in Fig. 4 c, left figure is the expression tree part-structure, and wherein the arithmetic type of present node is OR, and in two child nodes, the model of child nodes Exp1 association is m1, and the model of child nodes Exp2 association is m1 and m2; And provided corresponding Rete localized network among the right figure, wherein, first made up 2 type SF localized networks with child nodes Exp2 associated model m1 and model node corresponding to m2 as Ingress node, the node SF-Beta that compiles wherein is the corresponding Rete node of child nodes Exp2; Afterwards, arithmetic type OR according to present node has made up 2 type OR localized networks, wherein, father node be 2 type SF localized networks compile node SF-Beta, also be the corresponding Rete node of child nodes Exp2, another father node Alpha1 is the corresponding Rete node of child nodes Exp1, and the associated corresponding model node of model m1 of its child nodes Exp1 is also as the Ingress node of father node Alpha1; And the node OR-Beta that compiles of 2 type OR localized networks is the corresponding Rete node of present node.In addition, such as the arithmetic type that has provided present node among Fig. 4 d be the Rete localized network of AND time institute correspondence establishment; And Fig. 4 d is with another difference of Fig. 4 c: in the associated model of two child nodes an identical model m1 is arranged among Fig. 4 c, at this moment, the corresponding model node while of model m1 is as the Ingress node of father node Alpha1 and SF-Beta, and among Fig. 4 d, the associated model of two child nodes is different, therefore, the corresponding model node of model m1 is as the Ingress node of father node Alpha1, and the corresponding model node of model m2 and m3 is as the Ingress node of the father node SF-Beta2 of correspondence.
The condition element of judging two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.Similar among constructed Rete localized network and Fig. 4 c or Fig. 4 d in this case, difference only is that the corresponding Rete node of child nodes Exp1 is the node that compiles of another 2 type SF localized network, two Ingress nodes of this 2 type SF localized network are the associated corresponding model node of two models of child nodes Exp1, thereby two father nodes of the Rete localized network that makes up in this step all are the nodes that compiles of 2 type SF localized networks.
Step 304: according to two processing node make up the corresponding Rete localized network of present node, execution in step 306.
The realization of this step can comprise:
When the arithmetic type of judging present node is the AND computing, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node; In this step, two father nodes of 2 constructed type AND localized networks are two Rete nodes in the Rete localized network that has made up, two the Rete nodes that node will set up that compile by 2 type AND localized networks connect, and the node AND-Beta that compiles of this 2 type AND localized network also is the corresponding Rete node of present node.
When the arithmetic type of judging present node is the OR computing, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.In this step, two father nodes of 2 constructed type OR localized networks are two Rete nodes in the Rete localized network that has made up, two the Rete nodes that node OR-Beta will set up that compile by 2 type OR localized networks connect, and the node OR-Beta that compiles of this 2 type AND localized network also is the corresponding Rete node of present node.
Step 305: according to factor expression node and processing node make up the corresponding Rete localized network of present node; Execution in step 306.
The realization of this step can comprise:
When the arithmetic type of judgement present node is the AND computing, determine two models that child nodes is associated of present node;
If the associated model of two child nodes is identical, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
If two model differences that child nodes is associated, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
Judge when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
Corresponding with above-mentioned Rete network creating method, the embodiment of the invention also provides a kind of Rete network to set up system, as shown in Figure 5, comprising:
Construction unit 510 for the expression tree that makes up current rule, is determined the root node of this expression tree;
Judging unit 520 is used for described root node judging the attribute status of two child nodes of present node as present node;
The first processing unit 530, if be used for that two child nodes have a child nodes at least neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return judging unit and proceed described judgement;
The second processing unit 540 all is factor expression formula node if be used for two child nodes, then makes up the corresponding Rete localized network of present node according to two factor expression formula nodes;
The 3rd processing unit 550 all is processing node if be used for two child nodes, then according to two processing node make up the corresponding Rete localized network of present node;
The manages unit 560 everywhere, is factor expression formula node if be used for two one of child nodes, and one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node;
Creating unit 570 is for the finish node that creates the Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
Preferably, the second processing unit 540 can comprise:
First determines subelement, is used for determining the associated model of condition element of two child nodes;
First processes subelement, condition element that be used for to judge two child nodes is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes;
Second processes subelement, be used for judging respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 3rd processes subelement, condition element that be used for to judge two child nodes is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
Manages subelement everywhere, be used for judging related model of condition element of a child nodes of two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 5th processes subelement, condition element that be used for to judge two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.
Preferably, the 3rd processing unit 550 can comprise:
The 6th processes subelement, when being the AND computing for the arithmetic type of judging present node, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node;
The 7th processes subelement, when being the OR computing for the arithmetic type of judging present node, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.
Preferably, manage unit 560 everywhere and can comprise:
Second determines subelement, when being the AND computing for the arithmetic type of judging present node, determines two models that child nodes is associated of present node;
The 8th processes subelement, determine that the associated model of two definite child nodes of subelement is identical if be used for second, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The 9th processes subelement, determine the associated model difference of two child nodes that subelement is determined if be used for second, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The tenth processes subelement, be used for judging when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
In system shown in Figure 5, construction unit makes up the expression tree of current rule, determines the root node of this expression tree; Judging unit as present node, is judged the attribute status of two child nodes of present node with described root node; The first processing unit to the is managed the unit everywhere according to the Rete localized network corresponding to the corresponding structure present node of judged result of judging unit, created at last the finish node of Rete network by creating unit, with the child nodes of finish node as the corresponding Rete node of present node.By above processing, realized the foundation of the corresponding Rete network of expression tree, also namely realized the foundation of regular corresponding Rete network, and then realized setting up Rete network corresponding to each rule based on the rule language that the embodiment of the invention provides.
One of ordinary skill in the art will appreciate that, the process of the method for realization above-described embodiment can be finished by the relevant hardware of programmed instruction, described program can be stored in the read/write memory medium, and this program is carried out the corresponding step in the said method when carrying out.Described storage medium can be such as ROM/RAM, magnetic disc, CD etc.
The above only is preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.

Claims (8)

1. a Rete network creating method is characterized in that, comprising:
Make up the expression tree of current rule, determine the root node of this expression tree;
Described root node as present node, is judged the attribute status of two child nodes of present node;
If have a child nodes at least in two child nodes neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return described determining step;
If two child nodes all are factor expression formula nodes, then make up the corresponding Rete localized network of present node according to two factor expression formula nodes; If two child nodes all are processing nodes, then according to two processing node make up the corresponding Rete localized network of present node; If two one of child nodes are factor expression formula nodes, one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node;
Create the finish node of Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
2. method according to claim 1 is characterized in that, describedly makes up the corresponding Rete localized networks of present node according to two factor expression formula nodes and comprises:
Determine the associated model of condition element of two child nodes;
The condition element of two child nodes of judgement is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes;
Judge respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The condition element of two child nodes of judgement is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
Judge related model of condition element of a child nodes in two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The condition element of judging two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.
3. method according to claim 1 and 2 is characterized in that, makes up the corresponding Rete localized network of present node according to processing node and comprises:
When the arithmetic type of judging present node is the AND computing, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node;
When the arithmetic type of judging present node is the OR computing, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.
4. method according to claim 3 is characterized in that, according to factor expression node and processing node make up the corresponding Rete localized network of present node and comprise:
When the arithmetic type of judgement present node is the AND computing, determine two models that child nodes is associated of present node;
If the associated model of two child nodes is identical, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
If two model differences that child nodes is associated, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
Judge when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
5. a Rete network is set up system, it is characterized in that, comprising:
Construction unit for the expression tree that makes up current rule, is determined the root node of this expression tree;
Judging unit is used for described root node judging the attribute status of two child nodes of present node as present node;
The first processing unit, if be used for that two child nodes have a child nodes at least neither factor expression formula node processing node, then with the child nodes of described neither factor expression formula node processing node as present node, return judging unit and proceed described judgement;
The second processing unit all is factor expression formula node if be used for two child nodes, then makes up the corresponding Rete localized network of present node according to two factor expression formula nodes;
The 3rd processing unit all is processing node if be used for two child nodes, then according to two processing node make up the corresponding Rete localized network of present node;
The manages the unit everywhere, is factor expression formula node if be used for two one of child nodes, and one is processing node, then according to factor expression node and processing node make up the corresponding Rete localized network of present node;
Creating unit is for the finish node that creates the Rete network, with the child nodes of finish node as the corresponding Rete node of present node.
6. system according to claim 5 is characterized in that, the second processing unit comprises:
First determines subelement, is used for determining the associated model of condition element of two child nodes;
First processes subelement, condition element that be used for to judge two child nodes is related identical model respectively, and when the arithmetic type of present node is the AND computing, the model node corresponding with this identical model makes up 1 type localized network as Ingress node, and two Alpha nodes in the 1 type localized network are respectively two corresponding Rete nodes of child nodes; Record the corresponding relation between two child nodes and the Rete node, present node is labeled as processes;
Second processes subelement, be used for judging respectively related different model of condition element of two child nodes, and when the arithmetic type of present node is the AND computing, make up 2 type AND localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type AND localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 3rd processes subelement, condition element that be used for to judge two child nodes is related model respectively, and when the arithmetic type of present node is the OR computing, make up 2 type OR localized networks with two corresponding model nodes of model as Ingress node, the corresponding father node of model node in the 2 type OR localized networks is the corresponding Rete node of child nodes of this model node association, and compiling node is Rete node corresponding to present node; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
Manages subelement everywhere, be used for judging related model of condition element of a child nodes of two child nodes, during related two models of the condition element of another child nodes, make up 2 type SF localized networks take the corresponding model node of described two models as Ingress node, the node that compiles of 2 type SF localized networks is the corresponding Rete node of child nodes of related two models; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, one of them father node is the node that compiles of described 2 type SF localized networks, and another father node is the corresponding Rete node of child nodes of a related model; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes;
The 5th processes subelement, condition element that be used for to judge two child nodes is all during related two models, make up 2 type SF localized networks with two corresponding model nodes of model as Ingress node respectively, the node that compiles of 2 type SF localized networks of structure is the corresponding Rete node of corresponding child nodes; Arithmetic type according to present node makes up corresponding 2 type AND localized networks or 2 type OR localized networks, and two father nodes of described 2 type AND localized networks or 2 type OR localized networks are respectively the node that compiles of two 2 type SF localized networks; Corresponding relation between record present node and two child nodes and the Rete node is labeled as present node and processes.
7. according to claim 5 or 6 described systems, it is characterized in that the 3rd processing unit comprises:
The 6th processes subelement, when being the AND computing for the arithmetic type of judging present node, as father node, make up 2 type AND localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node;
The 7th processes subelement, when being the OR computing for the arithmetic type of judging present node, as father node, make up 2 type OR localized networks with the corresponding Rete node of two child nodes of present node, the node that compiles of 2 type AND localized networks is the corresponding Rete node of present node; Corresponding relation between record present node and the Rete node.
8. system according to claim 7 is characterized in that, manages the unit everywhere comprises:
Second determines subelement, when being the AND computing for the arithmetic type of judging present node, determines two models that child nodes is associated of present node;
The 8th processes subelement, determine that the associated model of two definite child nodes of subelement is identical if be used for second, make up 1 type localized network, an Alpha node in the 1 type localized network is the corresponding Rete node of processing node in the child nodes, and another Alpha node is the corresponding Rete node of factor expression formula node in the child nodes; Record in the child nodes factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The 9th processes subelement, determine the associated model difference of two child nodes that subelement is determined if be used for second, make up 2 type AND localized networks, a father node in the 2 type AND localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes;
The tenth processes subelement, be used for judging when present node represents the OR computing, make up 2 type OR localized networks, a father node in the 2 type OR localized networks is the corresponding Rete node of processing node in the child nodes, another father node is the corresponding Rete node of factor expression formula node in the child nodes, and compiling node is the corresponding Rete node of present node; Record present node and attribute are the child nodes of factor expression formula node and the corresponding relation between the Rete node, present node is labeled as processes.
CN201110277653.0A 2011-09-19 2011-09-19 The method for building up and system of a kind of Rete network Active CN102999324B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110277653.0A CN102999324B (en) 2011-09-19 2011-09-19 The method for building up and system of a kind of Rete network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110277653.0A CN102999324B (en) 2011-09-19 2011-09-19 The method for building up and system of a kind of Rete network

Publications (2)

Publication Number Publication Date
CN102999324A true CN102999324A (en) 2013-03-27
CN102999324B CN102999324B (en) 2018-05-18

Family

ID=47927934

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110277653.0A Active CN102999324B (en) 2011-09-19 2011-09-19 The method for building up and system of a kind of Rete network

Country Status (1)

Country Link
CN (1) CN102999324B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104679790A (en) * 2013-12-03 2015-06-03 富士通株式会社 Distributed rule engine system, distributed rule engine construction method and rule processing method
CN108399066A (en) * 2018-01-25 2018-08-14 链家网(北京)科技有限公司 A kind of regulation engine implementation method and device
CN107247588B (en) * 2017-05-26 2020-10-23 电子科技大学 Rule engine optimization method based on constraint frequency
WO2020215574A1 (en) * 2019-04-22 2020-10-29 平安科技(深圳)有限公司 Method, apparatus, computer device, and storage medium for automatically adjusting rete network

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409885A (en) * 2008-11-18 2009-04-15 中国移动通信集团福建有限公司 Method for analyzing abnormal index based on rule engine
CN102170360A (en) * 2011-04-19 2011-08-31 北京神州数码思特奇信息技术股份有限公司 Mode matching method of rule engine and RETE network

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409885A (en) * 2008-11-18 2009-04-15 中国移动通信集团福建有限公司 Method for analyzing abnormal index based on rule engine
CN102170360A (en) * 2011-04-19 2011-08-31 北京神州数码思特奇信息技术股份有限公司 Mode matching method of rule engine and RETE network

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
庞伟正等: "一种规则引擎的实现方法", 《哈尔滨工程大学学报》 *
方应飞: "基于规则引擎的自定义查询系统的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
陈飞: "业务规则管理系统的研究与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104679790A (en) * 2013-12-03 2015-06-03 富士通株式会社 Distributed rule engine system, distributed rule engine construction method and rule processing method
CN104679790B (en) * 2013-12-03 2018-01-16 富士通株式会社 The method of distributed rule automotive engine system, building method and executing rule processing
CN107247588B (en) * 2017-05-26 2020-10-23 电子科技大学 Rule engine optimization method based on constraint frequency
CN108399066A (en) * 2018-01-25 2018-08-14 链家网(北京)科技有限公司 A kind of regulation engine implementation method and device
WO2020215574A1 (en) * 2019-04-22 2020-10-29 平安科技(深圳)有限公司 Method, apparatus, computer device, and storage medium for automatically adjusting rete network

Also Published As

Publication number Publication date
CN102999324B (en) 2018-05-18

Similar Documents

Publication Publication Date Title
CN112100054B (en) Data management and control oriented program static analysis method and system
Lara et al. AToM 3: A Tool for Multi-formalism and Meta-modelling
Li et al. A formal semantics of UML sequence diagram
CN102810057B (en) A kind of method of log
Chok et al. Automatic construction of user interfaces from constraint multiset grammars
Li et al. PASS: string solving with parameterized array and interval automaton
Campos et al. Formally verifying interactive systems: A review
CN106598579A (en) Method and device for integrating dynamic type programming language on block chain
CN107844093B (en) Element model-based custom function block and configuration packaging method
US20120054590A1 (en) Spreadsheet-based graphical user interface for dynamic system modeling and simulation
CN103052943A (en) Source code conversion method and source code conversion program
CN101601012A (en) Has the programming framework that scene is supported towards producer graph
CN101617292A (en) Programming and execution towards producer graph
CN111880784B (en) SIMSCRIPT language-oriented discrete event simulation graphical modeling method
Biermann et al. Lifting parallel graph transformation concepts to model transformation based on the eclipse modeling framework
De Lara et al. A-posteriori typing for model-driven engineering
CN104391731A (en) Editing method based on C# and irrelevant to data types
CN102999324A (en) Establishing method and system of Rete network
Heinen et al. Juggrnaut: Graph grammar abstraction for unbounded heap structures
Le et al. Domain-driven design using meta-attributes: A DSL-based approach
Michel et al. An SMT-based approach to automated configuration
JPWO2002097727A1 (en) Automatic knowledge generation method, automatic knowledge generation system, automatic knowledge generation program, automatic design method, and automatic design system
Jaghoori et al. Modere: The model-checking engine of Rebeca
Golas Analysis and correctness of algebraic graph and model transformations
Kehrer et al. An EMOF-compliant abstract syntax for bigraphs

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220114

Address after: 100010 8th floor, longfu building, No. 95, longfushi street, Dongcheng District, Beijing

Patentee after: Beijing State Owned Financial Leasing Co.,Ltd.

Address before: 100085, No. 3, No. 002, Section 1, building No. 3, 3rd floor, information industry base, Beijing, Haidian District

Patentee before: BEIJING STARTIMES SOFTWARE TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right