Skip to content

Commit

Permalink
fix assertion error to include sum
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnaceBleukx committed Aug 23, 2024
1 parent 6433e86 commit b8e80a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpmpy/solvers/exact.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ def __add__(self, cpm_expr_orig):
if isinstance(cpm_expr, Comparison):
lhs, rhs = cpm_expr.args
if cpm_expr.name == "==":
# can be wsum or mul
assert isinstance(lhs, Operator) and (lhs.name == "wsum" or lhs.name == "mul")
assert isinstance(lhs, Operator)
# can be sum, wsum or mul
if lhs.name == "mul":
assert pkg_resources.require("exact>=2.1.0"), f"Multiplication constraint {cpm_expr} only supported by Exact version 2.1.0 and above"
if is_num(rhs): # make dummy var
Expand All @@ -460,6 +460,7 @@ def __add__(self, cpm_expr_orig):
self.xct_solver.addMultiplication(self.solver_vars(lhs.args), True, xct_rhs, True, xct_rhs)

else:
assert lhs.name == "sum" or lhs.name == "wsum"
xct_cfvars, xct_rhs = self._make_numexpr(lhs, rhs)
self._add_xct_constr(xct_cfvars, True, xct_rhs, True, xct_rhs)

Expand Down

0 comments on commit b8e80a8

Please sign in to comment.