I've been thinking about this since Jaymer asked about a complex rule and have drawn on my prior life working for an advanced rules engine supplier.

Prior versions of (up to V7, I think) attempted to build a rules matrix for the business rules that you created. It very quickly became complicated, but it was good for showing you the route through your business rules. Unlike linear programming it appears that AIM checks records against all the permutations of the rule checking whether both the rule and the inverse are true (based on looking at what happens in the logger).

If you consider the rules engine as trying to filter a record through various options the aim should be to get that record to the action required as fast as possible. If you have any experience with writing SQL queries that check against multiple tables there is a fast way and a slow way to write a query to get the same result. A rules engine is the same.

Redundancy in rules is your enemy.

The above example creates a matrix of 4 rules and 2 conditions and in each of the rules the same thing is being asked multiple times. 4x2

In the above example by streaming out the rule based on BO.Att value you reduce the size of the matrix to two rules and one condition.

If you stream records where BO.Att=1 to another sub process you then reduce the matrix at this sub process level to 2 x 1, does Att= 1? Yes or No, does Att=2? Yes or No.

You then need to do the subsequent checking in a sub process that receives only the BO.Att=1 records so DoTheChecksOn1 looks like:

Another 2x1 matrix with simple choices.

You are also asking the questions once and will have less difficulty maintaining this; in the event that another test for BO.Att=1 and BO.OthAtt='efg' requires one line of code in one sub process making the matrices 2x1 + 3x1 instead of one larger process where the matrix grows from 4x2 to 5x2

The process maps for your processes will also become easier to read and a bit more useful.

Prior versions of (up to V7, I think) attempted to build a rules matrix for the business rules that you created. It very quickly became complicated, but it was good for showing you the route through your business rules. Unlike linear programming it appears that AIM checks records against all the permutations of the rule checking whether both the rule and the inverse are true (based on looking at what happens in the logger).

If you consider the rules engine as trying to filter a record through various options the aim should be to get that record to the action required as fast as possible. If you have any experience with writing SQL queries that check against multiple tables there is a fast way and a slow way to write a query to get the same result. A rules engine is the same.

Redundancy in rules is your enemy.

Code: Select all

`IF BO.Att=1 AND BO.OthAtt='xyx' THEN Do Stuff ELSE`

IF BO.Att=1 AND Bo.OthAtt='abc' THEN Do More Stuff ELSE

IF BO.Att=2 AND BO.OthAtt='pqr' THEN Something Different ELSE

IF BO.Att=2 AND BO.OthAtt='lmn' THEN The Other Different Thing

The above example creates a matrix of 4 rules and 2 conditions and in each of the rules the same thing is being asked multiple times. 4x2

In the above example by streaming out the rule based on BO.Att value you reduce the size of the matrix to two rules and one condition.

Code: Select all

`IF BO.Att=1 THEN DoTheChecksOn1 ELSE`

IF BO.Att=2 THEN DoTheChecksOn2

If you stream records where BO.Att=1 to another sub process you then reduce the matrix at this sub process level to 2 x 1, does Att= 1? Yes or No, does Att=2? Yes or No.

You then need to do the subsequent checking in a sub process that receives only the BO.Att=1 records so DoTheChecksOn1 looks like:

Code: Select all

`IF BO.OthAtt='xyz' THEN Do stuff ELSE`

IF BO.OthAtt='abc' THEN Do mores stuff

Another 2x1 matrix with simple choices.

You are also asking the questions once and will have less difficulty maintaining this; in the event that another test for BO.Att=1 and BO.OthAtt='efg' requires one line of code in one sub process making the matrices 2x1 + 3x1 instead of one larger process where the matrix grows from 4x2 to 5x2

The process maps for your processes will also become easier to read and a bit more useful.

Last edited by PointsWell on Fri Jan 31, 2020 3:26 am, edited 4 times in total.