Upload
vimal-kumar
View
2.376
Download
3
Tags:
Embed Size (px)
Citation preview
Balaji Venugopal Vimal Kumar
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
Definition
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?
Some frequently asked questions
We will attempt to address these questions…….
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.”
Why use a Rule Engine?
Complicated logic (not 1+1 = 2)
When should I use a Rule Engine? "when there is no satisfactory traditional programming approach to solve the problem."
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.
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
When should you use a Rule Engine?
Declarative Programming
Logic and Data Separation
Speed and Scalability
Centralization of Knowledge
Tool Integration
Explanation Facility
Advantages of a Rule Engine
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
rule memory
Inference engine
working memory
observed data
fire
modify select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
interpreter
working memory
New information
fire
modify select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
interpreter
working memory
New information
fire
modify
select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
Inference
engine
executes
actions
working memory
New information
fire
modify select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
Inference
engine
executes
actions
working memory
New information
fire
modify select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
interpreter
working memory
New information
fire
modify
select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
Inference engine
executes actions
working memory
New information
fire
modify select
output
Reasoning with production rules
Architecture of a typical production system:
rule memory
Inference engine
executes
actions
working memory
New information
fire
modify select
output
Methods of execution for a rule system
Forward Chaining Backward Chaining
Goal
Start
Goal
Start
Goal
conclude the color of my pet Fritz
Forward Chaining
Working Memory he croaks eats flies
Rule Base 1. If X croaks and eats flies - Then X is a frog 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 he croaks eats flies
Rule Base 1. If X croaks and eats flies - Then X is a frog 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 he croaks eats flies frog
the color of my pet Fritz
GREEN
Backward Chaining
Working Memory he croaks eats flies
Rule Base 1. If X croaks and eats flies - Then X is a frog 2. If X is a frog - Then X is green 3. If X is a canary - Then X is yellow
Goal
conclude the color of my pet Fritz
Rule Base 1. If X croaks and eats flies - Then X is a frog 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 1. conclude the color of my pet Fritz
Goal List 1. conclude the color of my pet Fritz 2. X is a frog 3. X is a canary
Working Memory he croaks eats flies
So my pet Fritz
Is frog Is Green He croaks and eats flies
• Business Process/Workflow • Data Validation/Formatting • Self-Service Web Inquiries • Regulatory Compliance • Order Configuration • Call Center/CRM • Fraud Detection • Authorization • Benefits Analysis • Manufacturing Process • Claims Processing • Compliance Enforcement • Database Migration Tool.
Solutions Which Are Attracting The Use Of Business Rules For More Efficiency
• Marketing/Campaign • Management Account • Management/Personalization
Behavior Scoring • Product / Service
Recommendation • Underwriting
(Lending/Insurance) • Diagnostics/Problem Resolution • Sales Commission Calculation • Pension Portfolio Marketing • Risk Analysis
Drools
BizTalk
Blaze Advisor
Jess
JRules
OpenRules
PegaRules
RulesPower
Rule Engines
Heart of the System