maanantai 9. heinäkuuta 2007

More Range Checks

Now I have all the solutions for the patterns inside the rule, and all the possibilities for constraints inside patterns. I can use this information to compare two rules for redundancy and subsumption, and check for incoherence inside one rule.

Range checks for numbers, dates and variables are done, even found a way to check for variable ranges. Basically the structure of the rule that finds missing ranges is the same for all. Here is an example of two rules, the check for bar == $value is missing.

rule "Sample 1"

when

Something( $value :value )

Foo( bar < $value )

then

# Do something.

end


rule "Sample 2"

when

Something( $value :value )

Foo( bar > $value )

then

# Do something.

end




In this case the variable points to field value in class Something, variable could also be any number, like 42 or a date like 21-Oct-2007. In my last blog entry I talked about finding all the values that bar is being compared to, that was not needed as I'm using rule engine to solve this problem. All I needed to do was to find constraint that has field bar from Foo compared to any value for example ( bar > 42 ) and then check if there is a constraint that checks for ( bar == 42 ) or ( bar <= 42 ), of course if 42 is an integer there is the need to add +1 or -1 to 42. Rule engine then does the work for me and goes trough all the cases.

The checks for numbers in patters is still undone. When field x is compared to 10, 20, 30, 50 and 60 there should be a warning that x == 40 is missing. I don't think there is any way to check for all the of the possible patterns, but at least addition, deduction, division and multiplying could be possible.

The notifications that RAM gives needed an update, they can now be caused by multiple rows, and multiple rules. After range checks are done I'll be doing redundancy and subsumption checks.