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
65 changes: 65 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,71 @@ Rank: minor
Fix duplicate registration of EFPA's symmetry option, which hid its other
command-line options.

[ENTRY]
Module: search
What: documentation
Rank: minor
[DESCRIPTION]
Document that LDS does not report reaching its discrepancy limit as a stop.
[MORE]
Finding no solution proves that none exists only if the discrepancy limit
covers every path of the search tree.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Fix a crash when deleting a portfolio of restart-based engines.
[MORE]
Every asset took ownership of the same cutoff and deleted it. The assets now
share one cutoff sequence, which the portfolio deletes once.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Honour the stop object of a portfolio built from engine builders.
[MORE]
The stop object is checked with the statistics of each asset, so a node or
failure limit applies to each asset separately.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Do not report DFS and BAB as stopped when the search tree is exhausted at
the same failure that reaches a limit.
[MORE]
Restart-based search with no-goods then restarted without new no-goods, and
could repeat the same search forever on unsatisfiable models.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Count a failed root as a failure when a search engine is reset.
[MORE]
Restart-based search resets its engine at every restart, so failure limits
did not advance when the slave space failed right away, as it can in large
neighbourhood search. Restart-based search now also checks its stop object
before restarting after an incomplete slave search, so a parallel engine
cannot restart forever.

[ENTRY]
Module: search
What: bug
Rank: minor
[DESCRIPTION]
Do not report restart-based search as stopped when the master fails at a
restart.
[MORE]
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
Expand Down
25 changes: 24 additions & 1 deletion gecode/search.hh
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ namespace Gecode { namespace Search {
unsigned int c_d;
/// Create a clone during recomputation if distance is greater than \a a_d (adaptive distance)
unsigned int a_d;
/// Discrepancy limit (for LDS)
/// Discrepancy limit (for LDS, reaching it does not stop the engine)
unsigned int d_l;
/// Number of assets (engines) in a portfolio
unsigned int assets;
Expand Down Expand Up @@ -1405,6 +1405,18 @@ namespace Gecode {

/**
* \brief Limited discrepancy search engine
*
* The engine explores the paths of the search tree with at most
* Search::Options::d_l discrepancies, allowing more discrepancies in each
* iteration, starting from none.
*
* When next() returns nullptr and stopped() returns false, either the
* search tree has been explored completely, or the discrepancy limit has
* been reached while parts of the tree are still unexplored. The engine
* does not report which: a search that finds no (further) solution only
* proves that none exists if no path of the tree has more discrepancies
* than the limit.
*
* \ingroup TaskModelSearch
*/
template<class T>
Expand All @@ -1418,6 +1430,10 @@ namespace Gecode {

/**
* \brief Invoke limited-discrepancy search for \a s as root node and options\a o
*
* Returning nullptr does not prove that there is no solution when the
* discrepancy limit has been reached, see LDS.
*
* \ingroup TaskModelSearch
*/
template<class T>
Expand Down Expand Up @@ -1529,6 +1545,10 @@ namespace Gecode {
* builders, each with its own control and immutable worker capacity.
* PBS does not allocate workers or adjust those controls.
*
* When the assets are restart-based engines, the portfolio takes
* ownership of the cutoff in \a o and the assets share its sequence:
* each restart of an asset takes the next value of the sequence.
*
* The class \a T can implement member functions
* \code virtual bool master(const MetaInfo& mi) \endcode
* and
Expand All @@ -1551,6 +1571,9 @@ namespace Gecode {
/**
* Initialize with engine builders \a sebs
*
* The stop object of \a o is checked for each builder's engine with the
* statistics of that engine, as is the stop object of the builder.
*
* The outer options must not contain a worker control. Each builder can
* instead supply a distinct control for its underlying engine.
* In parallel PBS, the outer thread count limits how many builders run,
Expand Down
8 changes: 6 additions & 2 deletions gecode/search/par/bab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ namespace Gecode { namespace Search { namespace Par {
d = 0;
mark = 0;
idle = false;
if ((s == nullptr) || (s->status(*this) == SS_FAILED)) {
// Reset the statistics first, so that a failed root is counted
Search::Worker::reset();
if (s == nullptr) {
cur = nullptr;
} else if (s->status(*this) == SS_FAILED) {
fail++;
delete s;
cur = nullptr;
} else {
cur = s;
}
Search::Worker::reset();
}

template<class Tracer>
Expand Down
8 changes: 6 additions & 2 deletions gecode/search/par/dfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ namespace Gecode { namespace Search { namespace Par {
path.reset((s != nullptr) ? ngdl : 0);
d = 0;
idle = false;
if ((s == nullptr) || (s->status(*this) == SS_FAILED)) {
// Reset the statistics first, so that a failed root is counted
Search::Worker::reset();
if (s == nullptr) {
cur = nullptr;
} else if (s->status(*this) == SS_FAILED) {
fail++;
delete s;
cur = nullptr;
} else {
cur = s;
}
Search::Worker::reset();
}

template<class Tracer>
Expand Down
3 changes: 2 additions & 1 deletion gecode/search/par/pbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace Gecode { namespace Search { namespace Par {
bool
PortfolioStop::stop(const Statistics& s, const Options& o) {
return tostop->load(std::memory_order_acquire) ||
((so != nullptr) && so->stop(s,o));
((so != nullptr) && so->stop(s,o)) ||
((po != nullptr) && po->stop(s,o));
}

void
Expand Down
6 changes: 4 additions & 2 deletions gecode/search/par/pbs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ namespace Gecode { namespace Search { namespace Par {
private:
/// The stop object for the slaves
Stop* so;
/// The stop object for the portfolio (possibly nullptr)
Stop* po;
/// Worker control for waking a paused asset
WorkerControl worker_control;
/// Whether search must be stopped
std::atomic<bool>* tostop;
public:
/// Initialize
PortfolioStop(Stop* so, const WorkerControl& control);
/// Initialize with slave stop \a so, portfolio stop \a po, and \a control
PortfolioStop(Stop* so, Stop* po, const WorkerControl& control);
/// Set pointer to shared \a tostop variable
void share(std::atomic<bool>* ts);
/// Return true if portfolio engine must be stopped
Expand Down
5 changes: 3 additions & 2 deletions gecode/search/par/pbs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ namespace Gecode { namespace Search { namespace Par {


forceinline
PortfolioStop::PortfolioStop(Stop* so0, const WorkerControl& control)
: so(so0), worker_control(control), tostop(nullptr) {}
PortfolioStop::PortfolioStop(Stop* so0, Stop* po0,
const WorkerControl& control)
: so(so0), po(po0), worker_control(control), tostop(nullptr) {}

forceinline void
PortfolioStop::share(std::atomic<bool>* ts) {
Expand Down
12 changes: 11 additions & 1 deletion gecode/search/pbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ namespace Gecode { namespace Search { namespace Seq {
return new PortfolioStop(so);
}

Stop*
pbsstop(Stop* so, Stop* po) {
return new PortfolioStop(so,po);
}

Engine*
pbsengine(Engine** slaves, Stop** stops, unsigned int n_slaves,
const Statistics& stat, const Search::Options& opt, bool best) {
Expand All @@ -59,7 +64,12 @@ namespace Gecode { namespace Search { namespace Par {

Stop*
pbsstop(Stop* so, const WorkerControl& control) {
return new PortfolioStop(so,control);
return new PortfolioStop(so,nullptr,control);
}

Stop*
pbsstop(Stop* so, Stop* po, const WorkerControl& control) {
return new PortfolioStop(so,po,control);
}

Engine*
Expand Down
Loading
Loading