diff --git a/cpmpy/expressions/globalfunctions.py b/cpmpy/expressions/globalfunctions.py index 6c2234c6d..3135526a8 100644 --- a/cpmpy/expressions/globalfunctions.py +++ b/cpmpy/expressions/globalfunctions.py @@ -133,9 +133,6 @@ def decompose_comparison(self, cpm_op, cpm_rhs): they should be enforced toplevel. """ from .python_builtins import any, all - if cpm_op == "==": # can avoid creating aux var - return [any(x <= cpm_rhs for x in self.args)], [all(x >= cpm_rhs for x in self.args)] - lb, ub = self.get_bounds() _min = intvar(lb, ub) return [eval_comparison(cpm_op, _min, cpm_rhs)], \ @@ -173,9 +170,6 @@ def decompose_comparison(self, cpm_op, cpm_rhs): they should be enforced toplevel. """ from .python_builtins import any, all - if cpm_op == "==": # can avoid creating aux var here - return [any(x >= cpm_rhs for x in self.args)], [all(x <= cpm_rhs for x in self.args)] - lb, ub = self.get_bounds() _max = intvar(lb, ub) return [eval_comparison(cpm_op, _max, cpm_rhs)], \ diff --git a/tests/test_transf_decompose.py b/tests/test_transf_decompose.py index e7649b166..afe9c2b83 100644 --- a/tests/test_transf_decompose.py +++ b/tests/test_transf_decompose.py @@ -89,15 +89,15 @@ def test_decompose_nested(self): cons = [min(ivs) == max(ivs)] self.assertEqual(str(decompose_in_tree(cons, supported={"min"})), - "[or([(x) >= (min(x,y,z)), (y) >= (min(x,y,z)), (z) >= (min(x,y,z))]), (x) <= (min(x,y,z)), (y) <= (min(x,y,z)), (z) <= (min(x,y,z))]") + '[(IV0) == (min(x,y,z)), or([(x) >= (IV0), (y) >= (IV0), (z) >= (IV0)]), (x) <= (IV0), (y) <= (IV0), (z) <= (IV0)]') self.assertEqual(str(decompose_in_tree(cons, supported={"max"})), - "[or([(x) <= (max(x,y,z)), (y) <= (max(x,y,z)), (z) <= (max(x,y,z))]), (x) >= (max(x,y,z)), (y) >= (max(x,y,z)), (z) >= (max(x,y,z))]") + "[(IV1) == (max(x,y,z)), or([(x) <= (IV1), (y) <= (IV1), (z) <= (IV1)]), (x) >= (IV1), (y) >= (IV1), (z) >= (IV1)]") # numerical in non-comparison context cons = [AllEqual([min(ivs[:-1]),ivs[-1]])] self.assertEqual(str(decompose_in_tree(cons, supported={"allequal"})), - "[allequal(IV0,z), ((x) <= (IV0)) or ((y) <= (IV0)), (x) >= (IV0), (y) >= (IV0)]") + "[allequal(IV2,z), (IV3) == (IV2), ((x) <= (IV3)) or ((y) <= (IV3)), (x) >= (IV3), (y) >= (IV3)]") self.assertEqual(str(decompose_in_tree(cons, supported={"min"})), "[(min(x,y)) == (z)]")