Thursday, September 30, 2010

Rule engine

Check out this SlideShare Presentation:

Rule engine

Check out this SlideShare Presentation:

Rule Engine

The content of this post is all about the tech debate on "Procedural programming vs Rule Engine", held on last Friday (24/9/2010), as a part of series of tech debates happening at OrangeScape among the Knowledge Sharing Team every Friday on various tech topics. @Balaji vg and myself represented Rule Engine and @Anbarasan & @Siva represented Procedural Programming. My team's progress can be checked here. And the tech debates can be checked by following #ostechtalk in twitter.

[slideshare id=5321225&doc=ruleenginelatest-100930005049-phpapp02]

The Evolution & Future :

The evolution of Rule engine started when the research on Artificial Intelligence begun. Yes, Rule Engine or Inference Engine falls under the branches of Knowledge Engineering and Artificial Intelligence. And hence Rule Engine will play a major role in future as Artificial Intelligence is going to be the future.

Pros

  • Declarative Programming - What to do Not How to Do
  • No to Loops.
  • Centralization of Knowledge -Logic & Data Separation
  • Business Rules are easily maintainable

Cons

  • Requirements like UI programing and workflow programming cannot be done in Rule Engine.

The Transcript of my presentation

RULE ENGINE

"In any IT application, business rules change more frequently than the rest of the application code. Rules engines or inference engines are the pluggable software components that execute business rules that have been externalized from application code as part of a business rules approach. This externalization of business rules allows the business users to modify the rules frequently without the need of ITintervention. The system as whole becomes more adaptable with business rules that can be changed dynamically, although QA and other testing would still be required." - Wikipedia

Definitions :

  • "A rule engine is a piece of software, which having some knowledge is able to perform conclusions."
  • “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 to use 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

How Rule Engine Works :

Rule Engine is a major component of Rule Based System which composes of three components, they are Production Memory, Working Memory and Rule Engine.

The Rule Engine matches the rules from production memory against the facts from working memory based on the algorithms

•Linear

•Rete

•Treat

•Leaps

which is known as Pattern Matching.

Then the selected rules are executed in an order sorted by Agenda. This takes care of conflict resolution strategy.

The two methods of execution for a Rule System

a. Forward Chaining (Data Driven)

Forward chaining starts with the available data and uses inference rules to extract more data (from an end user for example) until a goal is reached. An inference engine using forward chaining searches the inference rules until it finds one where the antecedent (If clause) is known to be true. When found it can conclude, or infer, the consequent (Thenclause), resulting in the addition of new information to its data. - wikipedia

b. Backward Chaining (Goal Driven)

Backward chaining starts with a list of goals (or a hypothesis) and works backwards from the consequentto the antecedent to see if there is data available that will support any of these consequents. An inference engine using backward chaining would search the inference rules until it finds one which has a consequent (Then clause) that matches a desired goal. If the antecedent (If clause) of that rule is not known to be true, then it is added to the list of goals (in order for one's goal to be confirmed one must also provide data that confirms this new rule). - wikipedia

In short, Rule Engine is the Heart of the Business Based Application.

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

The Verdict :-

Procedural Programming or Rule Engine?

"According to Hindu Legends, once Lord Vishnu, saved Lord Shiva from Bhasmasur, in the form of Mohini during a critical and complex situation faced by Lord Shiva". Likewise, Rule Engine saves, when a complex Decision Making logic which changes often, is required to be written in procedural programming. And Procedural Programming saves, when UI and Workflow related program is to be written in Rule Engine. So According to me both are Gods. Each having its own strength and both plays an important role in business applications.