In my enterprise application I have business rules like :
((AMOUNT < 20000.00) || ((AMOUNT >= 20000.00) && (RISKEXPOSURE == 'N')))
(ind = A1 || ind = A2 || ind = A3 || ind = S1 || ind = S2 || ind = S9)
The rule, as you can see, is made of business expressions ex: (AMOUNT < 20000.00)
.
The rules could have any number of business conditions joined by boolean operators &&
and ||
.
The identifiers AMOUNT
, RISKEXPOSURE
and ind
are the business variables (which could vary from 1 to n based on the business domain).
My requirement is to find those expressions when true make the entire rule true.
For ex:
for business rule #1 - the whole rule will be true if:
(AMOUNT < 20000.00)
is true or ((AMOUNT >= 20000.00) && (RISKEXPOSURE == 'N'))
is true hence my output should be:
Solution #1: (AMOUNT < 20000.00)
Solution #2: ((AMOUNT >= 20000.00) && (RISKEXPOSURE == 'N'))
Similarly for Business rule #2:
Solution #1:ind = A1
Solution #2:ind = A2
Solution #3:ind = A3
Solution #4:ind = S1
Solution #5:ind = S2
Solution #6:ind = S9
What I tried:
Since each business expression can be either true or false, I changed my business rule #1 as (A || ( B && C ) )
. I used the propositional logic library from Tweetyproject. This gives me results but I cannot enforce a constraint such as an XOR. In my example A and B are mutually exclusive but my output possible results. Representing the rule in truth table form, I get all the following true conditions
011 ,100 ,101 ,110 ,111
However my result should be only 100, 011
This lead me to look for alternatives and the answer here suggested a constraint solver. I have been reading about the Choco Solver. But I am not sure how my business rule can be represented in a model acceptable by the solver. Any help is greatly appreciated.