Top Banner
Balaji Venugopal Vimal Kumar
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Rule engine

Balaji Venugopal Vimal Kumar

Page 2: Rule engine

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

Page 3: Rule engine

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…….

Page 4: 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?

Page 5: 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?

Page 6: 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?

Page 7: 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."

Page 8: Rule engine

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

Page 9: Rule engine

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.

Page 10: 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

When should you use a Rule Engine?

Page 11: Rule engine

Declarative Programming

Logic and Data Separation

Speed and Scalability

Centralization of Knowledge

Tool Integration

Explanation Facility

Advantages of a Rule Engine

Page 12: Rule engine

High Level view of a Rule Engine

Page 13: Rule engine
Page 14: 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.

Page 15: Rule engine

Architecture of Typical Rule Based System

rule memory

Inference engine

working memory

observed data

fire

modify select

output

Page 16: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

interpreter

working memory

New information

fire

modify select

output

Page 17: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

interpreter

working memory

New information

fire

modify

select

output

Page 18: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

Inference

engine

executes

actions

working memory

New information

fire

modify select

output

Page 19: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

Inference

engine

executes

actions

working memory

New information

fire

modify select

output

Page 20: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

interpreter

working memory

New information

fire

modify

select

output

Page 21: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

Inference engine

executes actions

working memory

New information

fire

modify select

output

Page 22: Rule engine

Reasoning with production rules

Architecture of a typical production system:

rule memory

Inference engine

executes

actions

working memory

New information

fire

modify select

output

Page 23: Rule engine

Methods of execution for a rule system

Forward Chaining Backward Chaining

Goal

Start

Goal

Start

Page 24: Rule engine

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

Page 25: Rule engine

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

Page 26: Rule engine

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

Page 27: Rule engine

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

Page 28: Rule engine

• 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

Page 30: Rule engine

Heart of the System

Page 31: Rule engine
Page 32: Rule engine