Skip to content

Commit

Permalink
Unshare variables for maximum_arg / minimum_arg constraints. Fixes #169.
Browse files Browse the repository at this point in the history
  • Loading branch information
guidotack committed Aug 31, 2023
1 parent 34adb07 commit ecf84ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 8 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Date: 2020-??-??
[DESCRIPTION]
Let's see.

[ENTRY]
Module: flatzinc
What: bug
Issue: 169
Rank: minor
[DESCRIPTION]
Unshare variables for maximum_arg / minimum_arg constraints.

[ENTRY]
Module: int
What: bug
Expand Down
14 changes: 10 additions & 4 deletions gecode/flatzinc/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,25 +1120,31 @@ namespace Gecode { namespace FlatZinc {
}

void p_minimum_arg(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
IntVarArgs iv = s.arg2intvarargs(ce[0]);
IntVar x = s.arg2IntVar(ce[2]);
IntVarArgs iv = x + s.arg2intvarargs(ce[0]);
unshare(s, iv);
int offset = ce[1]->getInt();
argmin(s, iv, offset, s.arg2IntVar(ce[2]), true, s.ann2ipl(ann));
argmin(s, iv.slice(1), offset, x, true, s.ann2ipl(ann));
}

void p_maximum_arg(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
IntVarArgs iv = s.arg2intvarargs(ce[0]);
IntVar x = s.arg2IntVar(ce[2]);
IntVarArgs iv = x + s.arg2intvarargs(ce[0]);
unshare(s, iv);
int offset = ce[1]->getInt();
argmax(s, iv, offset, s.arg2IntVar(ce[2]), true, s.ann2ipl(ann));
argmax(s, iv.slice(1), offset, x, true, s.ann2ipl(ann));
}

void p_minimum_arg_bool(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
unshare(s, bv);
int offset = ce[1]->getInt();
argmin(s, bv, offset, s.arg2IntVar(ce[2]), true, s.ann2ipl(ann));
}

void p_maximum_arg_bool(FlatZincSpace& s, const ConExpr& ce, AST::Node* ann) {
BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
unshare(s, bv);
int offset = ce[1]->getInt();
argmax(s, bv, offset, s.arg2IntVar(ce[2]), true, s.ann2ipl(ann));
}
Expand Down

0 comments on commit ecf84ec

Please sign in to comment.