44 template<
class Tracer>
48 template<
class Tracer>
55 template<
class Tracer>
60 template<
class Tracer>
66 template<
class Tracer>
67 forceinline
unsigned int
72 template<
class Tracer>
73 forceinline
unsigned int
78 template<
class Tracer>
79 forceinline
unsigned int
83 template<
class Tracer>
88 template<
class Tracer>
93 template<
class Tracer>
98 template<
class Tracer>
103 template<
class Tracer>
104 forceinline
unsigned int
110 template<
class Tracer>
116 template<
class Tracer>
130 template<
class Tracer>
135 template<
class Tracer>
136 forceinline
unsigned int
141 template<
class Tracer>
147 template<
class Tracer>
150 if (!
ds.empty() &&
ds.top().lao()) {
158 stat.
stack_depth(
static_cast<unsigned long int>(
ds.entries()));
162 template<
class Tracer>
166 if (
ds.top().rightmost()) {
169 assert(
ds.top().work());
171 if (!
ds.top().work())
177 template<
class Tracer>
184 template<
class Tracer>
190 template<
class Tracer>
197 template<
class Tracer>
200 int l =
ds.entries()-1;
201 while (
ds[l].space() ==
nullptr)
206 template<
class Tracer>
212 template<
class Tracer>
215 assert((
ds[l].space() ==
nullptr) ||
ds[l].space()->failed());
216 int n =
ds.entries();
218 for (
int i=l; i<
n; i++) {
220 unsigned int fa = (i != l) ?
top.alt() + 1 :
top.alt();
221 for (
unsigned int a = fa; a <
top.choice()->alternatives(); a++) {
230 for (
int i=l; i<
n; i++) {
236 assert(
ds.entries() == l);
239 template<
class Tracer>
248 template<
class Tracer>
254 template<
class Tracer>
259 int n =
ds.entries()-1;
268 while (
ds[l].space() ==
nullptr)
270 Space* c =
ds[l].space()->clone();
272 for (
int i=l; i<
n; i++)
274 unsigned int a =
ds[
n].steal();
279 ngdl(std::min(
ngdl(),
static_cast<unsigned int>(
n)));
280 d = stat.
steal_depth(
static_cast<unsigned long int>(
n+1));
282 ot.ei()->init(myt.wid(),
ds[
n].nid(), a, *c, *
ds[
n].choice());
291 template<
class Tracer>
300 if ((
ds.top().space() !=
nullptr) &&
ds.top().rightmost()) {
303 assert(
ds.entries()-1 ==
lc());
304 ds.top().space(
nullptr);
306 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
313 int n =
ds.entries();
315 d =
static_cast<unsigned int>(
n - l);
317 Space* s =
ds[l].space()->clone();
321 for (
int i=l; i<
n; i++)
324 int m = l +
static_cast<int>(d >> 1);
330 for (; (i<
n) &&
ds[i].rightmost(); i++)
348 d =
static_cast<unsigned int>(
n-i);
357 template<
class Tracer>
360 const Space* best,
int& mark,
367 if ((
ds.top().space() !=
nullptr) &&
ds.top().rightmost()) {
370 assert(
ds.entries()-1 ==
lc());
371 if ((best !=
nullptr) && (mark >
ds.entries()-1)) {
372 mark =
ds.entries()-1;
375 ds.top().space(
nullptr);
377 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
384 int n =
ds.entries();
386 d =
static_cast<unsigned int>(
n - l);
390 if ((best !=
nullptr) && (l < mark)) {
412 for (
int i=l; i<
n; i++)
415 int m = l +
static_cast<int>(d >> 1);
421 for (; (i<
n) &&
ds[i].rightmost(); i++)
442 d =
static_cast<unsigned int>(
n-i);
451 template<
class Tracer>
Choice for performing commit
std::atomic< unsigned long int > n
Number of no-goods.
static ExecStatus post(Space &home, const Path &p)
Post propagator for path p.
Search tree edge for recomputation
bool work(void) const
Test whether there is an alternative that can be stolen.
void dispose(void)
Free memory for edge.
Edge(void)
Default constructor.
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization).
bool lao(void) const
Test whether current alternative was LAO.
unsigned int nid(void) const
Return node identifier.
const Choice * _choice
Choice.
unsigned int _alt_max
Number of alternatives left.
const Choice * choice(void) const
Return choice.
Space * space(void) const
Return space for edge.
unsigned int alt(void) const
Return number for alternatives.
unsigned int _alt
Current alternative.
bool rightmost(void) const
Test whether current alternative is rightmost.
unsigned int steal(void)
Steal rightmost alternative and return its number.
void next(void)
Move to next alternative.
Space * _space
Space corresponding to this edge (might be nullptr).
void reset(unsigned int l)
Reset stack and set no-good depth limit to l.
unsigned int ngdl(void) const
Return no-good depth limit.
void unwind(int l, Tracer &t)
Unwind the stack up to position l (after failure).
unsigned int n_work
Number of edges that have work for stealing.
const Choice * push(Worker &stat, Space *s, Space *c, unsigned int nid)
Push space c (a clone of s or nullptr).
Path(unsigned int l)
Initialize with no-good depth limit l.
Support::DynamicStack< Edge, Heap > ds
Stack to store edge information.
void commit(Space *s, int i) const
Commit space s as described by stack entry at position i.
void next(void)
Generate path for next node.
bool empty(void) const
Test whether path is empty.
virtual void post(Space &home) const
Post no-goods.
unsigned int _ngdl
Depth limit for no-good generation.
int lc(void) const
Return position on stack of last copy.
int entries(void) const
Return number of entries on stack.
Edge & top(void) const
Provide access to topmost edge.
bool steal(void) const
Make a quick check whether stealing might be feasible.
Space * recompute(unsigned int &d, unsigned int a_d, Worker &s, Tracer &t)
Recompute space according to path.
unsigned long long int fail
Number of failed nodes in search tree.
unsigned long int steal_depth(unsigned long int d) const
Return steal depth.
void stack_depth(unsigned long int d)
Record stack depth d.
Heap heap
The single global heap.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
virtual void constrain(const Space &best)
Constrain function for best solution search.
Space * clone(void) const
Clone space.
SpaceStatus status(StatusStatistics &stat)
Query space status.
void commit(const Choice &c, unsigned int a)
Commit choice c for alternative a.
@ SS_FAILED
Space is failed
const unsigned int steal_limit
Minimal number of open nodes for stealing.
Gecode toplevel namespace