Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ Date: unreleased
[DESCRIPTION]
This is the development changelog for the next Gecode release.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Fail the space in relax when a variable cannot take its value from the
solution. The space stayed unfailed, and an integer variable could be left
assigned without its propagators being notified. Restart-based search with
relaxation, such as large neighbourhood search with no-goods, could then
propagate incorrectly or crash.

[ENTRY]
Module: flatzinc
What: bug
Expand Down
2 changes: 1 addition & 1 deletion gecode/search/relax.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace Gecode { namespace Search {
ax.clear(r(static_cast<unsigned int>(x.size())));
for (Iter::Values::BitSet<Support::BitSet<Region> > i(ax); i(); ++i)
if (post(home, x[i.val()], sx[i.val()]) != ES_OK) {
home.failed();
home.fail();
return;
}
}
Expand Down
27 changes: 27 additions & 0 deletions test/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,33 @@ namespace Test {
}
};

/// Space for relaxing
class RelaxSpace : public Gecode::Space {
public:
RelaxSpace(void) = default;
RelaxSpace(RelaxSpace& s) : Gecode::Space(s) {}
Gecode::Space* copy(void) override {
return new RelaxSpace(*this);
}
};

/// Relaxing fails the space when a value cannot be kept
class RelaxFailed : public Base {
public:
RelaxFailed(void) : Base("Search::Relax::Failed") {}
bool run(void) override {
RelaxSpace s;
// The kept value lies in a hole of the domain
Gecode::IntVarArgs x(s,2,Gecode::IntSet({0,2}));
Gecode::IntVarArgs sx(s,2,1,1);
// Probability zero keeps one of the two values
Gecode::relax(s,x,sx,Gecode::Rnd(1U),0.0);
return s.failed();
}
};

RelaxFailed relax_failed;

/// %Test for portfolio-based search
template<class Model, template<class> class Engine>
class PBS : public Test {
Expand Down
Loading