Skip to content

Commit

Permalink
Correctly unshare variables for div and mod constraints. Fixes #170.
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Aug 31, 2023
1 parent c32cd81 commit d1bd874
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ Rank: minor
[DESCRIPTION]
Correctly unshare variables for inverse constraint.

[ENTRY]
Module: flatzinc
What: bug
Issue: 170
Rank: minor
[DESCRIPTION]
Correctly unshare variables for div and mod constraints.

[ENTRY]
Module: flatzinc
What: bug
Expand Down
8 changes: 6 additions & 2 deletions gecode/flatzinc/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,17 @@ namespace Gecode { namespace FlatZinc {
IntVar x0 = s.arg2IntVar(ce[0]);
IntVar x1 = s.arg2IntVar(ce[1]);
IntVar x2 = s.arg2IntVar(ce[2]);
div(s,x0,x1,x2, s.ann2ipl(ann));
IntVarArgs x = {x0, x1, x2};
unshare(s, x);
div(s,x[0],x[1],x[2], s.ann2ipl(ann));
}
void p_int_mod(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
IntVar x0 = s.arg2IntVar(ce[0]);
IntVar x1 = s.arg2IntVar(ce[1]);
IntVar x2 = s.arg2IntVar(ce[2]);
mod(s,x0,x1,x2, s.ann2ipl(ann));
IntVarArgs x = {x0, x1, x2};
unshare(s, x);
mod(s,x[0],x[1],x[2], s.ann2ipl(ann));
}

void p_int_min(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
Expand Down
3 changes: 3 additions & 0 deletions gecode/int/arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ namespace Gecode {
divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3,
IntPropLevel) {
using namespace Int;
IntVarArgs allvars = {x0, x1, x2, x3};
if (same(allvars))
throw ArgumentSame("Int::divmod");
GECODE_POST;

IntVar prod(home, Int::Limits::min, Int::Limits::max);
Expand Down

0 comments on commit d1bd874

Please sign in to comment.