validatetools icon indicating copy to clipboard operation
validatetools copied to clipboard

rules with '&'

Open balima78 opened this issue 4 years ago • 1 comments

I'm trying some rules with '&' but when I try to run your functions from {validatetoos} I have an error. Here the example:

rules <- validator( r1 = A1 == 0 & A2 == 0 & A3 <= A4 , r2 = A1 == 0 & A2 == 0 & A3 > A4 )

is_infeasible(rules)

Error in A[, v] : subscript out of bounds In addition: Warning message: In to_miprules(x) : Ignoring rules: r1, r2

balima78 avatar Mar 31 '21 13:03 balima78

Thanks for your question!

In validate and validator a record is considered valid if it obeys all rule. So implicitely a rule set is "&"-ding all rules.

validatetools (and errorlocate) currently assume that rules are not composed by "&".

Current work-around is splitting your rules (replacing "&" with ",")

rules <- validator(
                   r1   = A1 == 0
                 , r2 = A2 == 0
                 , r3 = A3 <= A4
                 , r4 = A3 > A4 
                )

Suggestions for validatetools are welcome: validatetools could rewrite the ruleset to do exactly this...

Best,

Edwin

edwindj avatar Apr 01 '21 11:04 edwindj