What is the Rete Algorithm?
Your first question is likely – how do I say “Rete”? Well, a quick search leading to several dictionaries suggests “Reet” is appropriate while “Ree-tee” and and other pronunciations are less common.
The goal of a Rete Algorithm is pretty simple, to reduce the number of rule executions to get to the same eventual result. By evaluating the structure of the rules, inferences can be made to allow some rules to not execute in order as they are unnecessary.
A simple non technical example:
Fact:
- Bob stole from Joe
Rules:
- Stealing is a crime
- Do not do business with someone who is a criminal
- Do not lend money to someone we do not do business with
Execution
- Data: Bob stole from Joe
- Result: Do not lend money to Bob
As you can see, we can easily skip the second rule because the we can infer or remember Stealing = crime = no business relationship = no lending.
The Rete Algorithm is a design methodology that sacrifices memory for speed. It optimizes execution times by reducing the number of rules or data a transaction requires with an intelligent network or structure of rules and data. The fundamental idea is simple, while implementations can grow to be quite complex.
The principle essentially boils down to creating the leanest decision tree possible at runtime. In a project where you might have millions or billions of business rule transactions – designing their execution in such a way that calls for each and every rule to run will add costly overhead to total execution times. The Rete Algorithm optimizes the rule execution pattern with “test rules” that are placed early and strategically in any execution in order to determine if other data or rules need to be run/accessed or not.


