-
Notifications
You must be signed in to change notification settings - Fork 27
Understanding Rule Evaluation
Let us take the case of defining and using the taxation rule system included in the rulette-examples package and examined in the case study. This is just some random data to see how the output would change for different inputs.
Also, consider that rule input priorities are:
- source state
- item type
- material
- mrp threshold
First let's understand the defined rule-set.
- There are no rules defined for any state other than Karnataka.
- There is no default rule for states.
- There is a default rule for all other input other than source state. This implies that anytime we pass in a source state Karnataka and any specific value for any of the other inputs, we are sure to get at least this rule (rule#1)
All rules will be returned, since we are not applying any filter on the rule-set.
No rule will be returned.
We start going over rule inputs in decreasing order of priority.
- Nothing matches in the source state column since specific rules are defined only for Karnataka state.
- We stop right there and return nothing.
All rules will be returned, since we are not applying any filter on the rule-set excpet for state, and Karnatak is the only state defined anyway.
Rule#1 will be returned.
We start going over rule inputs in decreasing order of priority.
- All rules match for the source state column.
- Next, only rule#1 matches for item type.
- Since we have only one candidate, we return that.
Rule#1,2,3,5 will be returned after applying filtering for Karnatak and Cotton in order of priority.
Rule#1 will be returned.
We start going over rule inputs in decreasing order of priority.
- All rules match for the source state column.
- Next, only rule#1 matches for item type.
- Since we have only one candidate, we return that.
Rule#2,3 will be returned after applying filtering for Karnatak, Jeans, and Cotton in order of priority.
Rule#1 will be returned.
We start going over rule inputs in decreasing order of priority.
- All rules match for the source state column.
- Next, only rule#1,2,3 matches for item type.
- Next, only rule#1 matches (as default rule for material type).
- Since we have only one candidate, we return that.