Business Rule Technology
- Backward chaining
- A style of rule processing where rules are selected for execution based
on a goal-seeking strategy. Each rule breaks a goal into subgoals, or satisfies
a subgoal(s). When trying to satisfy a goal, the rule engine looks for rules
that conclude that goal, and then checks for any whose conditions are true.
For example, a system that evaluates a loan application might have a goal to
determine the risk the applicant poses. A rule such as:
If applicant.creditScore > 675 and
applicant.salary > 50,000 and
applicant.debtLoad < bank.debtLimit
Then applicant.creditRisk = Low
can be used if the system is currently trying to evaluate the credit risk. If the three bits of information about the applicant are already known (are in working memory), the rule immediately succeeds or fails, depending on their values. If any are not known, they are set up as subgoals. Other rules may then be able to establish whether the condition holds or not, or may be able to obtain the data in some other manner.
-
- Chaining
-
Chaining occurs in a rule system when one rule makes a change in working memory that leads to another rule
executing. While this can be used to define sequential processing (writing rules so that the change one
rule makes explicitly triggers one specific other rule), that is considered bad form because it does not
use the rule technology correctly. One of the
advantages of a rule system is the modularity of the knowledge. When you trust the rule engine to
select the best rule at each point, you avoid the complex interdependencies and difficult maintenance of
a heavily nested set of IF statements in a traditional programming language.
- Complex event processing
-
Complex event processing (CEP) is a style of rule processing where a rule’s condition specifies
patterns within a stream of events, generally with a time element. It is like forward chaining, specialized for
time-based reasoning. Patterns include expressions like “When an Event1 occurs within 5 min of
an Event2,” or “When 3 instances of Event1 occur within a 30 min window.” These systems are often used
in very fast-moving situations, like real-time securities trading. A CEP system can execute actions
directly, or can recognize significant patterns that it adds as data to a more traditional working memory.
- Forward chaining
- The forward-chaining style of rule processing is data driven, rather
than goal driven. The rules are interpreted as “When the condition becomes
true (because of a change in working memory), then do ...” Take a rule such as:
If phase = "risk scoring" and
applicant.creditScore > 675 and
applicant.salary > 50,000 and
applicant.debtLoad < bank.debtLimit
Then set applicant.creditRisk = Low and
set phase = "summarize application"
- The inference engine applies this rule when all the clauses in the condition have become true and there is no better rule to run. Its actions place two new facts into working memory, which might trigger other rules.
- RETE algorithm
- In a forward-chaining system, any rule whose condition has become true
is eligible to execute. There will typically be many ready to execute, and
it is the job of the rule engine to select the best one to actually execute.
The RETE algorithm is a method for compiling a rule base into an efficient
network. When a change takes place in working memory, the network determines
the right rule to execute, using the minimal number of tests, and with the
maximal reuse of shared patterns. Almost every forward-chaining rule engine
today uses some variant of the RETE algorithm.
- Rule
- A rule is a small unit of knowledge or computation that contains a condition and an action. The
condition defines when the rule is applicable. The condition is defined as a pattern of working memory elements
in the form of a Boolean expression. The action defines what should happen when the rule executes.
Actions can add, delete, and modify working memory elements. They can also call methods that cause
processing to occur outside working memory. The order in which rules execute is controlled by the
rule engine.
- Rule base
- Sometimes also called a knowledge base. A rule base contains definitions for the data elements
that can appear in the working memory. It includes the rule definitions. It might include
configuration settings that govern how the rule engine works. A rule base can be seen as the program for the
business decision.
- Rule engine
- A rule engine is technically the code that selects and executes the next
rule. The term also refers to the entire application that supports creation
and maintenance of rule bases, instrumentation of execution for debugging,
and other functions needed for a full rule-based application. Most rule
bases today are designed to support applications integrated within a traditional
language such as Java. Most also have some form of stand-alone mode for rule-development
purposes.
- Working memory
-
A rule system will pay attention only to the data known to it. Working memory is exactly what it sounds
like—the collection of data items that are available for examination by the rules. This data may have come into the system from outside, and also includes
data created internally by rule conclusions.