Find out for a contradicting rule which rules are conflicting. This helps in determining and assessing conflicts in rule sets. Which of the rules should stay and which should go?

is_contradicted_by(x, rule_name, verbose = interactive())

Arguments

x

validate::validator() object with rules.

rule_name

character with the names of the rules that are causing infeasibility.

verbose

if TRUE prints the

Value

character with conflicting rules.

Examples

rules <- validator( x > 0)

is_infeasible(rules)
#> [1] FALSE

# infeasible system!
rules <- validator( rule1 = x > 0
                  , rule2 = x < 0
                  )

is_infeasible(rules)
#> [1] TRUE

detect_infeasible_rules(rules, verbose=TRUE)
#> Found: 
#>   rule1: x > 0
#> [1] "rule1"

# but we want to keep rule1, so specify that it has an Inf weight
detect_infeasible_rules(rules, weight=c(rule1=Inf), verbose=TRUE)
#> Found: 
#>   rule2: x < 0
#> [1] "rule2"

# detect and remove
make_feasible(rules, weight=c(rule1=Inf), verbose = TRUE)
#> Found: 
#>   rule2: x < 0
#> Dropping rule(s): "rule2"
#> Object of class 'validator' with 1 elements:
#>  rule1: x > 0
#> Rules are evaluated using locally defined options

# find out the conflict with rule2
is_contradicted_by(rules, "rule2", verbose = TRUE)
#> Rule(s): 
#>  rule2: x < 0
#> contradicted by:
#>  rule1: x > 0
#> [1] "rule1"