Custom Template for Nested Loops

If you read attentively my latest post, you may notice this interesting table:

What does it do? It compares every unique pair (G1;G2) of elements of the array “Guests” using rules “SeatingForTwoGuests”. It is based on the newly introduced custom template “ActionNestedLoops” that our customers may find it quite useful.

This template defines a new action type that allows you to compare different elements inside the same array. Here is its implementation with a Java snippet:

Of course, OpenRules business users don’t have to know how this template was implemented but they can easily use it in their practical decision modeling. For instance, the sample project DuplicateCharges in the downloadable OpenRulesSamples uses this table:

It analyzes array “Bill Charges” to find out if a bill has duplicate charges using the following business rules:

Another good example is the standard project OpenRulesSamples/ICD10 with these tables:

It is interesting to note that the rules “SearchCSV” is not a regular decision table but rather a BigTable that analyzes different pairs of diagnoses found in the large CSV file “ICD10Codes.csv” with ~70,000 records that looks as below:

The use of “BigTable” guarantees that this search will be done highly efficiently.

These samples demonstrate how adding a relatively simple custom template allows OpenRules users essentially simplify their decision models. So, we highly recommend our customers build their own custom templates or contact us if they need help doing this.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.