Inferencing with Decision Tables - Gnorion/BizVR GitHub Wiki
Suppose you have some business rules to determine if you should go out and if so, what to wear. Weather Rules
In what order should you execute these rules?
Option 1 Forward Chaining
- Start with the first rule
- if any of its condition variables is unknown then move on to the next rule
- if all of its conditions have values then execute the rules to set the value of its output variables
- Keep doing this for each of the rules until none of the rules executes
Option 2 Backward Chaining
- Select a variable that is the goal (or output) of the rules. In this case we might choose "go_out" as the goal.
- Find all the rules that set the goal variable and try to execute them
- If you encounter a variable that has no value make a new goal for that variable and repeat this process
- When a goal is met (variable is set), go back to the rule that needs it and continue from there.
The big difference between these two approaches is this:
- Forward chaining will execute all rules that have values for their conditions (eventually) - this might result in multiple alternative solutions
- Backward chaining will only execute rules that contribute to the goal (or subgoal). Once a goal has been achieved no further rules are executed for that goal. You will only get one solution.
An illustration of why you would use forward or backward chaining.
Imagine there is a missile heading in your direction.
Do you want to
- Know if you should get out of its way (yes/no)
- Get all the details about it (size, color, shape, origin, destination etc etc)
You'd use backward chaining to determine #1 as quickly as possible
You'd use forward chaining for #2 to get as much information as possible (which might take a long time)