Skip to content

Commit

Permalink
Fix FlatZinc posting for element constraints
Browse files Browse the repository at this point in the history
The element constraint posting logic for FlatZinc when used without an
offset had an error where the posted propagator used an offest of 1
instead of -1, as should be done for 1-indexed arrays like in
MiniZinc/FlatZinc.

Fixes #109
  • Loading branch information
zayenz committed May 14, 2021
1 parent 4ab238c commit bbefcea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gecode/flatzinc/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ namespace Gecode { namespace FlatZinc {
rel(s, selector > 0);
if (isConstant) {
IntSharedArray sia = s.arg2intsharedarray(ce[1]);
element(s, sia, selector, 1, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
element(s, sia, selector, -1, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
} else {
IntVarArgs iv = s.arg2intvarargs(ce[1]);
element(s, iv, selector, 1, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
element(s, iv, selector, -1, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
}
}
void p_array_int_element_offset(FlatZincSpace& s, const ConExpr& ce,
Expand Down
2 changes: 1 addition & 1 deletion gecode/int/element/pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace Gecode { namespace Int { namespace Element {
template<class View>
forceinline int
PairValues<View>::val(void) const {
return xv.val()+w*yv.val();
return xv.val() + w*yv.val();
}


Expand Down

0 comments on commit bbefcea

Please sign in to comment.