Dealing with Nested Loops

The DMCommunity Challenge July-2022 “Team Performance” gives BR&DM vendors a good opportunity to demonstrate how to handle nested loops. I will describe how it can be done with OpenRules Decision Manager.

Here are the challenge requirements:

This problem deals with a tournament that includes several teams which players had shown different efficiencies during multiple games. It is quite natural to represent these concepts in the following glossary:

To calculate performance of each team, we need to iterate over all teams and for each team we need to evaluate performance of its players. It requires nested loops which can be implemented in OpenRules as follows:

Hopefully, this representation is self-explanatory and you don’t have to read further. However, below I will provide all details how to test, deploy, and execute this model locally and remotely.

We may define test data using tables “DecisionData” below. All players can be defined in this table:

Then we may describe teams:

And finally the tournament can be described as:

With a click on “test.bat” we execute this decision model locally and receive the following results:

Team(teamName=Mustungs,teamScore=11) Team(teamName=Eagles,teamScore=8)

With a click on “deployLambda.bat” we deploy this model as AWS Lambda function with the following Invoke URL:

https://8dthqs0evg.execute-api.us-east-1.amazonaws.com/test/decision-model-team-performance

We can run this AWS Lambda remotely using POSTMAN:

Running AWS Lambda from POSTMAN

Here we used the automatically generate JSON test as a request:

And here is the produced response:

Our readers may run the same AWS Lambda from their own machines by using POSTMAN with these URL and JSON request. The entire project “TeamPerformance” is included in the standard OpenRules workspace freely available for downloads from here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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