In this post we will provide a response to the DMCommunity.org Apr-2018 Challenge “Up-Selling Rules“ that deals with two decision tables: 1) up-selling rules that offer new products to a customer based on the customer profile and the products which the customer already has; 2) customer profiling rules. We will use for the first time the latest OpenRules version (not released yet to public) that removes a need for ordering of multiple decision tables.
The challenge’s tables perfectly fit OpenRules default decision tables. Here they are:
As you can see, these tables look exactly as in the challenge – we only added the last unconditional rules to display something if no rules were satisfied. Then we copied/pasted all used variables into the glossary:
To test our decision model, we need to define a data type “Customer”:
and create 3 test customers:
Usually at this point we create one more table of the type “Decision” that directs OpenRules to first execute decision table “DefineCustomerProfile” and then “DefineUpSelProducts”. With a new version of OpenRules we do not need this table as it is capable to automatically discover that “DefineCustomerProfile” should be executed before “DefineUpSelProducts”. So, when we ran our 3 tests we received the following results:
AUTOMATICALLY DETERMINED EXECUTION PATH: - DefineCustomerProfile - DefineUpSellProducts TEST-1: John Execute DefineCustomerProfile Conclusion: Customer Profile Is Silver [Silver] Execute DefineUpSellProducts Conclusion: Offered Products Are Product 6, Product 7, Product 8 [Offered Products] TEST-2: Larry Execute DefineCustomerProfile Conclusion: Customer Profile Is Gold [Gold] Execute DefineUpSellProducts Conclusion: Offered Products Are None [Offered Products] Sorry [produced by DefineUpSellProducts] TEST-3: Mary Execute DefineCustomerProfile Conclusion: Customer Profile Is Platinum [Platinum] Execute DefineUpSellProducts Conclusion: Offered Products Are None [Offered Products] Sorry [produced by DefineUpSellProducts]
Please note that the last two tests did not offered anything to the Gold and to the Premium customers (the last “Sorry”-rule was executed). It points that the up-selling logic proposed in the Challenge has drawbacks and should be approved. This completes our simple OpenRules solution.