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
13 changes: 13 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ restart.
Failing the master, for example by posting no-goods, proves that no further
solution exists. FlatZinc reported an unknown result instead.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Treat the first slave search of restart-based search as incomplete when the
slave configuration function returns false.
[MORE]
The first search always counted as complete, so a restricted first slave
search that found no solution was reported as a proof that none exists. With
FlatZinc, a model using gecode_on_restart_uniform_int could be reported as
unsatisfiable when the first random value admitted no solution.

[ENTRY]
Module: search
What: bug
Expand Down
5 changes: 2 additions & 3 deletions gecode/kernel/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2197,9 +2197,8 @@ namespace Gecode {
* of whether the search on the slave space finishes or times out.
* The no-goods recorded by an incomplete search only hold in the
* slave's search space, so the meta engine does not pass them to the
* master configuration function. When search starts, the result only
* determines whether no-goods are passed: the meta engine treats the
* first search on a slave space as complete.
* master configuration function. This also holds for the first
* search when search starts.
*
* \li A portfolio meta engine calls this function once on each asset
* (that is, on each slave) and passes the number of the asset,
Expand Down
5 changes: 2 additions & 3 deletions gecode/search/seq/rbs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ namespace Gecode { namespace Search { namespace Seq {
* \brief Constructor
*
* The value \a complete is the result of the slave configuration of the
* space explored by the first engine \a e0. It only determines whether
* the no-goods of that search hold in the master: the meta engine treats
* the first search as complete.
* space explored by the first engine \a e0, and is used as for the
* searches after later restarts.
*/
RBS(Space* s, RestartStop* stop0, Engine* e0,
const Search::Statistics& stat, const Options& o, bool best,
Expand Down
2 changes: 1 addition & 1 deletion gecode/search/seq/rbs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace Gecode { namespace Search { namespace Seq {
bool best0, bool complete0)
: e(e0), master(s), last(nullptr), co(opt.cutoff), stop(stop0),
m_opt(opt.expand()), sslr(0),
complete(true), nogoods_valid(complete0), restart(false),
complete(complete0), nogoods_valid(complete0), restart(false),
best(best0), m_stopped(false) {
stop->limit(stat,(*co)());
}
Expand Down
45 changes: 45 additions & 0 deletions test/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,51 @@ namespace Test {

RBSRootFailure rbs_root_failure;

/// Space with solutions whose first, incomplete slave fails at the root
class FailingFirstSlave : public RestrictedFirstSlave {
public:
FailingFirstSlave(void) = default;
FailingFirstSlave(FailingFirstSlave& s) : RestrictedFirstSlave(s) {}
Gecode::Space* copy(void) override {
return new FailingFirstSlave(*this);
}
bool slave(const Gecode::MetaInfo& mi) override {
if ((mi.type() == Gecode::MetaInfo::RESTART) &&
(mi.reason() == Gecode::MetaInfo::RR_INIT)) {
fail();
return false;
}
return true;
}
};

/// A failed first slave search that is incomplete is not a proof
class RBSFailedFirstSlave : public Base {
template<template<class> class Engine>
static bool test(unsigned int threads) {
FailingFirstSlave* m = new FailingFirstSlave;
Gecode::Search::Options o;
o.threads = threads;
o.cutoff = Gecode::Search::Cutoff::constant(1);
Gecode::RBS<FailingFirstSlave,Engine> rbs(m,o);
delete m;
FailingFirstSlave* s = rbs.next();
if (s == nullptr)
return false;
delete s;
return rbs.statistics().restart >= 1U;
}
public:
RBSFailedFirstSlave(void) : Base("Search::RBS::FailedFirstSlave") {}
bool run(void) override {
return test<Gecode::DFS>(1U) && test<Gecode::DFS>(2U) &&
test<Gecode::BAB>(1U) && test<Gecode::BAB>(2U) &&
test<Gecode::LDS>(1U);
}
};

RBSFailedFirstSlave rbs_failed_first_slave;

/// Stop after a number of failures, or after many checks as a safeguard
class FailureLimit : public Gecode::Search::Stop {
public:
Expand Down
Loading