Introduction
At present, the Java community has promoted and developed a compelling new technology--java rules engine (rule Engine). It can be used to separate the business decision logic of business decision-makers and the technology decision of the application developer in the application system. And put these business decisions in the central database or other unified place, so that they can be dynamically managed and modified at runtime, so as to maintain flexibility and competitiveness of enterprises to provide effective technical support.
Principles of the Rule engine
1. Introduction of rule-based Expert system (RBEs)
The Java rule Engine originates from the rule-based expert system, and the rule-based expert system is one of the branches of the expert system. Expert system belongs to the category of artificial intelligence, it imitates human reasoning way, uses exploratory method to infer, and uses the term that human can understand to explain and prove its inference conclusion. For a deeper understanding of the Java Rule Engine, a rule-based expert system is briefly introduced below. RBEs consists of three parts: rule base (Knowledge Base), Working Memory (fact base), and inference Engine. They are structured as shown in the following system:
Fig. 1 The composition of expert system based on rules
As shown in Figure 1, the inference engine consists of three parts: pattern Matcher, the agenda (Agenda), and the execution engine (Execution Engine). The inference engine is added to the agenda by determining which rules meet the facts or objectives, and give precedence to the rules, and the rules that satisfy the facts or objectives. The pattern-matching device determines which rule to execute, when to execute the rule, the order in which the rules are sorted by the agenda management pattern, and the execution engine is responsible for executing the rules and other actions.
As opposed to human thinking, the inference engine has two reasoning methods: Deductive (forward-chaining) and inductive method (backward-chaining). Deduction from an initial fact, constantly applying rules to draw conclusions (or perform specified actions). And the inductive law is based on the assumption, constantly looking for the facts that conform to the hypothesis. Rete algorithm is one of the most efficient forward-chaining inference algorithms, and many Java rule engines are based on rete algorithm to compute inference.
The inference engine's reasoning steps are as follows:
(1) Input the initial data (fact) into working Memory.
(2) Use pattern Matcher the rules (rule) and data (fact) in the rule base.
(3) If the execution rule has a conflict (conflict), that is, multiple rules are activated at the same time, the conflicting rules are put into the conflict set.
(4) Resolve the conflict and put the activated rules into the agenda in order.
(5) Use the execution engine to execute the rules in agenda. Repeat steps 2 through 5 until you have finished executing the rules in all agenda.
This is the original schema of the rule engine, which evolved from this primitive architecture.