diff --git a/changelog.in b/changelog.in index a4cfdd05f9..9d2da9edb8 100755 --- a/changelog.in +++ b/changelog.in @@ -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 diff --git a/gecode/search/relax.hh b/gecode/search/relax.hh index 5e8b1aee60..0a5f16e90e 100755 --- a/gecode/search/relax.hh +++ b/gecode/search/relax.hh @@ -65,7 +65,7 @@ namespace Gecode { namespace Search { ax.clear(r(static_cast(x.size()))); for (Iter::Values::BitSet > i(ax); i(); ++i) if (post(home, x[i.val()], sx[i.val()]) != ES_OK) { - home.failed(); + home.fail(); return; } } diff --git a/test/search.cpp b/test/search.cpp index b1f0354815..cb00a26472 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -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 Engine> class PBS : public Test {