You are on page 1of 32

Balaji Venugopal Vimal Kumar

Definition

A rule engine is a piece of software, which having some


knowledge is able to perform conclusions.
Rules Engines are the pluggable software components that
separate the business rules from the application code

• A system that attempts to act as a domain


expert
Some frequently asked questions

Why use a Rule Engine?

When should I use a rule engine?


What advantage does a rule engine have over
hand coded "if...then" approaches?

We will attempt to address these


questions…….
Why use a Rule Engine?
If “Procedural Code” is available then why RULE ENGINE ?
The Problem
•Have you developed/seen code with so many nested if statements that
actually looked like a nest?
Why use a Rule Engine?
The Problem (Contd…)
• Have you spent sleepless nights debugging code when you modified one
of those 'if' statements and found that it distorted the next if statement?
• Ever wondered how others implement these?
Why use a Rule Engine?
The Solution
• “Rule engines are a great way to collect complex decision-making logic
and work with data sets too large for humans to effectively use.”
When should I use a Rule Engine?
"when there is no satisfactory traditional programming approach to solve the problem."

Complicated logic (not 1+1 = 2)


The Robot Example
Teaching a robot to prepare breakfast cereal (in an optimal environment)

START
putOnTable(bowl)
putOnTable(spoon)
putOnTable(napkin)
open(cereal-container)
pour(cereal)
open(milk-container)
pour(milk)
inviteOwner("You may begin eating")
END
The Robot Example
Teaching a robot to drive is much more difficult because the task vary
according
to environmental conditions

a. Robot must not do the tasks for backing out of garage if the garage door is
closed or if there is a little girl on a tricycle right behind the car

b. Backing out will be different on warm days and cold days. Also, in a
parking spaces, backing up procedures will be different in different
Settings

c. So many different circumstances lead to endless logic branching

d. Solution: independent rules that are integrated in an inference engine:

IF the engine has stalled


THEN start car
IF you hear sirens
THEN pull over to the curb
etc.
When should you use a Rule Engine?

Changes often (whatever that means)

Traditional approaches are unmaintainable

The problem is beyond any obvious algorithmic solution

Domain experts (or business analysts) are readily available, but are
nontechnical
Advantages of a Rule Engine
Declarative Programming

Logic and Data Separation

Speed and Scalability

Centralization of Knowledge

Tool Integration

Explanation Facility
High Level view of a Rule Engine
Working Memory. The data that rules work on. Also called the fact base.

Production Memory. Knowledge and inferences are stored in rules, which are called 
production rules.

Pattern Matcher. Determines which rules to apply to the data in working memory.
• There are a number of algorithms used for Pattern Matching by Inference Engines
including:
• Linear
• Rete
• Treat
• Leaps

Agenda. Determines the order of execution of rules.

Execution Engine. The part of the rules engine that is responsible for applying rules to
data and then performing the action part of the rules that have fired.
Architecture of Typical Rule Based
System

observed data

working memory
select modify

rule
Inference
memory fire output
engine
Reasoning with production rules
 Architecture of a typical production
system:
New information

working memory
select modify

rule
interpreter
memory fire output
Reasoning with production rules
 Architecture of a typical production
system:
New information

select working memory


modify

rule
interpreter
memory fire output
Reasoning with production rules
 Architecture of a typical production
system:
New information

working memory
select
modify

Inference
rule engine
memory output
fire executes
actions
Reasoning with production rules
 Architecture of a typical production
system:
New information

working memory
select modify

Inference
rule engine
memory
fire executes output
actions
Reasoning with production rules
 Architecture of a typical production
system:
New information

select working memory


modify

rule
interpreter
memory fire output
Reasoning with production rules
 Architecture of a typical production
system:
New information

working memory
select
modify

Inference
rule engine
memory executes output
fire
actions
Reasoning with production rules
 Architecture of a typical production
system:
New information

working memory
select modify

Inference
rule engine
memory executes
fire output
actions
Methods of execution for a rule system
Forward Chaining Backward Chaining

Goal Goal

Start
Start
Forward Chaining
Goal
conclude the color of my pet Fritz

Working Memory Rule Base

he croaks 1. If X croaks and eats flies - Then X is a frog


eats flies 2. If X chirps and sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow
Working Memory Rule Base

he croaks 1. If X croaks and eats flies - Then X is a frog


eats flies 2. If X chirps and sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow

the color of my pet Fritz Working Memory

GREEN he croaks
eats flies
frog
Backward Chaining
Goal
conclude the color of my pet Fritz

Working Memory Rule Base

he croaks 1. If X croaks and eats flies - Then X is a frog


eats flies 2. If X is a frog - Then X is green
3. If X is a canary - Then X is yellow
Goal List Rule Base

1. conclude the color of my pet 1. If X croaks and eats flies - Then X is a frog
Fritz 2. If X chirps and sings - Then X is a canary
3. If X is a frog - Then X is green
4. If X is a canary - Then X is yellow

Goal List
Working Memory
1. conclude the color of my pet Fritz
he croaks 2. X is a frog
eats flies 3. X is a canary

So my pet Fritz

Is frog Is Green He croaks and eats flies


Solutions Which Are Attracting The Use Of
Business Rules For More Efficiency
• Marketing/Campaign • Business Process/Workflow
• Management Account • Data Validation/Formatting
• Management/Personalization • Self-Service Web Inquiries
Behavior Scoring
• Regulatory Compliance
• Product / Service
Recommendation • Order Configuration
• Underwriting • Call Center/CRM
(Lending/Insurance) • Fraud Detection
• Diagnostics/Problem • Authorization
Resolution
• Sales Commission Calculation • Benefits Analysis
• Pension Portfolio Marketing • Manufacturing Process
• Risk Analysis • Claims Processing
• Compliance Enforcement
• Database Migration Tool.
Rule Engines
Drools
BizTalk
Blaze Advisor
Jess
JRules
OpenRules
PegaRules
RulesPower
Heart of the System

You might also like