In rules condition part is contains logical operations (such as OR, AND, NOT) and in a tree like structure control flows from one node to another lower level node. We want to implement tree such that conditions would be in nodes and after evaluating it to be TRUE or FALSE control would go to next node till it reaches at the leaves where rules to be triggered would be stored.

This type of flow is possible only when all conditions are related in AND form (negated or simple). But in rules there might be OR which need to be converted into AND. This can be done as

(A OR B) = (A AND (NOT B)) + ((NOT A) AND B)

so there would be two paths for rule to be triggered.
Here in this issue queue I want to discuss the technical implementation of this proposed scheme or any alternate possible way.

Comments

Saubhagya’s picture

Status: Active » Needs review

I developed the code for the same. It can be found at http://github.com/saubhagya/rules_optimization/blob/master/rules_optimiz....
In the RulesOptimization class convert_rule_conditions() is the function which takes condition of the rule as input and returns an array of arrays. The second level array of this 2D array is the separate sequence of conditions which can trigger the same rule.

As from the previous post:
convert_rule_conditions() takes (A OR B) as input and returns array of two arrays which contain (A, NOT B) and (NOT A, B) respectively.

Currently code is not formatted well but working is fine. Please review the code.

Saubhagya’s picture

Version: » 7.x-1.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.