none
BRE Forward Chaining and Backward Chaining RRS feed

  • Question

  • Hello Experts,

    Can you please help me in understanding what is forward and backward chaining in BRE

    Thanks

    Saturday, December 6, 2014 12:18 PM

Answers

  • Forward chaining:

    Following is the extract from my favourite BizTalk book - Professional BizTalk Server 2006. I would recomment you to read though this book on forward chaining with BRE.

    In short: Forward chaining describes the ability for one rule’s actions to impact facts relied on by another rule and thus require such a rule to be reevaluated to maintain consistency.

    Forward chaining describes the ability for one rule’s actions to impact facts relied on by another rule and thus require such a rule to be reevaluated to maintain consistency.

    Consider this three-rule scenario: Rules 1 and 2 rely on the Loan Risk property to establish which APR the loan should be set to. Rule 3 marks the customer as High Risk if the customer meets the profiling criteria.
    Rule 1: IF Customer.LoanRisk = “Low” THEN Loan.APR = 0%
    Rule 2: IF Customer.LoanRisk = “High” THEN Loan.APR = 39%
    Rule 3: IF Customer.Age < 21 AND Income < “20,000” THEN Customer.LoanRisk = “High”

    A clear dependency exists between these rules. The action of Rule 1 or Rule 2 can be made invalid by Rule 3.  The action of Rule 3 modifies the LoanRisk fact, which is used as part of the conditions for Rule 1 and Rule 2. 

    This is where forward chaining comes in. The BRE requires that users create rules with this mind and add an UPDATE statement to the rule. This indicates to the BRE that the fact specified with the UPDATE statement has changed and that all rules that rely on this fact in a condition should be reevaluated and therefore pass through the match–conflict resolution–action stages again.

    The previous rule statement would need to be modified as follows.  

    Rule 1: IF Customer.LoanRisk = “Low” THEN Loan.APR = 0%
    Rule 2: IF Customer.LoanRisk = “High” THEN Loan.APR = 39%
    Rule 3: IF Customer.Age < 21 AND Income < “20,000” THEN Customer.LoanRisk = “High” UPDATE Customer

    Here Forward chaining describes the ability for one rule’s actions (Rule3's action) to impact facts relied on by another rule( Rule1 and Rule2) and thus require such a rule to be reevaluated to maintain consistency.


     Backward chaining

    Regarding Backward chaining, I don't know anyone who has implemented backward chaining other than Charles Young. In case of Microsoft's BRE with backward chaining, his blogpost on this topic is the only reference. So its better I refer to his one and only blog on this topic (in Microsoft BRE engine)

    Charles Young's excellent blog on this: MS BRE Backward Chaining - Part 2: The 'Simple Name' pattern

    Other references for you on this topic..

    Technet Wiki:Biztalk: BRE Forward Chaining

     A real time use case addressed in MSDN forum

    As said from my favourite - excellent detail provided on this topic with an in book Professional BizTalk Server 2006 with an example


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.



    Saturday, December 6, 2014 12:55 PM
  • Forward Chaining :
    A forward-chaining rule based system contains two basic components:

        1. A collection of rules.
        2. A collection of facts or assumptions that the rules operate on. (This is sometimes called the rules "Working Memory.")

    The standard definition of a forward-chaining system is that the system operates by repeating the following sequence of operations:

        1. Examine the rules to find one whose If part is satisfied by the current contents of Working memory.
        2. Fire the rule by adding to Working Memory the facts that are specified in the rule’s Then part. (The Then part may perform other actions as well, but we can ignore that for now.)

    This control cycle continues until no rules have satisfied If parts.

    backward chaining in BRE

    A backward-chaining rule based system contains three basic components:

        A collection of rules.
        A collection of facts or assumptions for the rules to operate on. (The Working Memory.)
        A stack of goals, where a goal is simply a statement of something that the rules need to determine.

    The control flow of a backward-chaining system is more complex than that of a forward-chaining system. Backward-chaining systems try to satisfy the goals in the goal stack. They do this by finding rules that can conclude the information needed by the goal, and trying to make the If parts of those rules satisfied. In more detail, the standard backward-chaining control cycle is:

        1. Check the conclusions of the rules to find all rules that can satisfy the top goal on the stack.

        2. Process these rules one at a time:

            a. Evaluate the conditions in the rule’s If part one at a time:

                i. If the condition is currently unknown (that is, if there is not enough information currently known to determine whether the condition is satisfied) push a goal to make that condition known, and recursively invoke the system.

                ii. If the condition is known to be unsatisfied, continue with the loop at Step 2.

                iii. If it was not possible to determine whether the condition was satisfied, continue with the loop at Step 2.

            b. If all the conditions in the selected rule are satisfied, add to Working Memory the facts specified in the Then part of the rule, pop the goal off the stack, and return from this invocation of the system.

    The system terminates with success when the goal stack is empty. It terminates with failure if the system runs out of rules to try in Step 2.

    There are various reference available which can guide you with BRE concept. Some of them are listed below

    Biztalk: BRE Forward Chaining

    BizTalk Server Business Rule Engine: Survival Guide by Steef-Jan Wiggers

    MS BRE Backward Chaining - Part 2: The 'Simple Name' pattern

    I would also suggest to go through BizTalk Unleased 2010 . I think its best resource to understand MS BizTalk  BRE.

    Thanks

    Abhishek

    Saturday, December 6, 2014 2:55 PM

All replies

  • Forward chaining:

    Following is the extract from my favourite BizTalk book - Professional BizTalk Server 2006. I would recomment you to read though this book on forward chaining with BRE.

    In short: Forward chaining describes the ability for one rule’s actions to impact facts relied on by another rule and thus require such a rule to be reevaluated to maintain consistency.

    Forward chaining describes the ability for one rule’s actions to impact facts relied on by another rule and thus require such a rule to be reevaluated to maintain consistency.

    Consider this three-rule scenario: Rules 1 and 2 rely on the Loan Risk property to establish which APR the loan should be set to. Rule 3 marks the customer as High Risk if the customer meets the profiling criteria.
    Rule 1: IF Customer.LoanRisk = “Low” THEN Loan.APR = 0%
    Rule 2: IF Customer.LoanRisk = “High” THEN Loan.APR = 39%
    Rule 3: IF Customer.Age < 21 AND Income < “20,000” THEN Customer.LoanRisk = “High”

    A clear dependency exists between these rules. The action of Rule 1 or Rule 2 can be made invalid by Rule 3.  The action of Rule 3 modifies the LoanRisk fact, which is used as part of the conditions for Rule 1 and Rule 2. 

    This is where forward chaining comes in. The BRE requires that users create rules with this mind and add an UPDATE statement to the rule. This indicates to the BRE that the fact specified with the UPDATE statement has changed and that all rules that rely on this fact in a condition should be reevaluated and therefore pass through the match–conflict resolution–action stages again.

    The previous rule statement would need to be modified as follows.  

    Rule 1: IF Customer.LoanRisk = “Low” THEN Loan.APR = 0%
    Rule 2: IF Customer.LoanRisk = “High” THEN Loan.APR = 39%
    Rule 3: IF Customer.Age < 21 AND Income < “20,000” THEN Customer.LoanRisk = “High” UPDATE Customer

    Here Forward chaining describes the ability for one rule’s actions (Rule3's action) to impact facts relied on by another rule( Rule1 and Rule2) and thus require such a rule to be reevaluated to maintain consistency.


     Backward chaining

    Regarding Backward chaining, I don't know anyone who has implemented backward chaining other than Charles Young. In case of Microsoft's BRE with backward chaining, his blogpost on this topic is the only reference. So its better I refer to his one and only blog on this topic (in Microsoft BRE engine)

    Charles Young's excellent blog on this: MS BRE Backward Chaining - Part 2: The 'Simple Name' pattern

    Other references for you on this topic..

    Technet Wiki:Biztalk: BRE Forward Chaining

     A real time use case addressed in MSDN forum

    As said from my favourite - excellent detail provided on this topic with an in book Professional BizTalk Server 2006 with an example


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.



    Saturday, December 6, 2014 12:55 PM
  • Forward Chaining :
    A forward-chaining rule based system contains two basic components:

        1. A collection of rules.
        2. A collection of facts or assumptions that the rules operate on. (This is sometimes called the rules "Working Memory.")

    The standard definition of a forward-chaining system is that the system operates by repeating the following sequence of operations:

        1. Examine the rules to find one whose If part is satisfied by the current contents of Working memory.
        2. Fire the rule by adding to Working Memory the facts that are specified in the rule’s Then part. (The Then part may perform other actions as well, but we can ignore that for now.)

    This control cycle continues until no rules have satisfied If parts.

    backward chaining in BRE

    A backward-chaining rule based system contains three basic components:

        A collection of rules.
        A collection of facts or assumptions for the rules to operate on. (The Working Memory.)
        A stack of goals, where a goal is simply a statement of something that the rules need to determine.

    The control flow of a backward-chaining system is more complex than that of a forward-chaining system. Backward-chaining systems try to satisfy the goals in the goal stack. They do this by finding rules that can conclude the information needed by the goal, and trying to make the If parts of those rules satisfied. In more detail, the standard backward-chaining control cycle is:

        1. Check the conclusions of the rules to find all rules that can satisfy the top goal on the stack.

        2. Process these rules one at a time:

            a. Evaluate the conditions in the rule’s If part one at a time:

                i. If the condition is currently unknown (that is, if there is not enough information currently known to determine whether the condition is satisfied) push a goal to make that condition known, and recursively invoke the system.

                ii. If the condition is known to be unsatisfied, continue with the loop at Step 2.

                iii. If it was not possible to determine whether the condition was satisfied, continue with the loop at Step 2.

            b. If all the conditions in the selected rule are satisfied, add to Working Memory the facts specified in the Then part of the rule, pop the goal off the stack, and return from this invocation of the system.

    The system terminates with success when the goal stack is empty. It terminates with failure if the system runs out of rules to try in Step 2.

    There are various reference available which can guide you with BRE concept. Some of them are listed below

    Biztalk: BRE Forward Chaining

    BizTalk Server Business Rule Engine: Survival Guide by Steef-Jan Wiggers

    MS BRE Backward Chaining - Part 2: The 'Simple Name' pattern

    I would also suggest to go through BizTalk Unleased 2010 . I think its best resource to understand MS BizTalk  BRE.

    Thanks

    Abhishek

    Saturday, December 6, 2014 2:55 PM