Skip to content

Commit

Permalink
fix simplication when comparison is used as num argument
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnaceBleukx committed May 2, 2024
1 parent 6d21c8b commit 240976a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cpmpy/transformations/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ def simplify_boolean(lst_of_expr, num_context=False):
if name == "==" or name == "<=":
newlist.append(recurse_negation(lhs))
if name == "<":
newlist.append(BoolVal(False))
newlist.append(0 if num_context else BoolVal(False))
if name == ">=":
newlist.append(BoolVal(True))
newlist.append(1 if num_context else BoolVal(True))
elif 0 < rhs < 1:
# a floating point value
if name == "==":
newlist.append(BoolVal(False))
newlist.append(0 if num_context else BoolVal(False))
if name == "!=":
newlist.append(BoolVal(True))
newlist.append(1 if num_context else BoolVal(True))
if name == "<" or name == "<=":
newlist.append(recurse_negation(lhs))
if name == ">" or name == ">=":
Expand All @@ -151,9 +151,9 @@ def simplify_boolean(lst_of_expr, num_context=False):
if name == "!=" or name == "<":
newlist.append(recurse_negation(lhs))
if name == ">":
newlist.append(BoolVal(False))
newlist.append(0 if num_context else BoolVal(False))
if name == "<=":
newlist.append(BoolVal(True))
newlist.append(1 if num_context else BoolVal(True))
elif rhs > 1:
newlist.append(BoolVal(name in {"!=", "<", "<="})) # all other operators evaluate to False
else:
Expand Down

0 comments on commit 240976a

Please sign in to comment.