40 template<
class Tracer>
44 template<
class Tracer>
51 template<
class Tracer>
56 template<
class Tracer>
62 template<
class Tracer>
68 template<
class Tracer>
74 template<
class Tracer>
79 template<
class Tracer>
84 template<
class Tracer>
89 template<
class Tracer>
94 template<
class Tracer>
99 template<
class Tracer>
106 template<
class Tracer>
112 template<
class Tracer>
126 template<
class Tracer>
131 template<
class Tracer>
137 template<
class Tracer>
143 template<
class Tracer>
146 if (!
ds.empty() &&
ds.top().lao()) {
154 stat.
stack_depth(
static_cast<unsigned long int>(
ds.entries()));
158 template<
class Tracer>
162 if (
ds.top().rightmost()) {
165 assert(
ds.top().work());
167 if (!
ds.top().work())
173 template<
class Tracer>
180 template<
class Tracer>
186 template<
class Tracer>
193 template<
class Tracer>
196 int l =
ds.entries()-1;
197 while (
ds[l].space() == NULL)
202 template<
class Tracer>
208 template<
class Tracer>
211 assert((
ds[l].space() == NULL) ||
ds[l].space()->failed());
212 int n =
ds.entries();
214 for (
int i=l; i<
n; i++) {
216 unsigned int fa = (i != l) ?
top.alt() + 1 :
top.alt();
217 for (
unsigned int a = fa; a <
top.choice()->alternatives(); a++) {
226 for (
int i=l; i<
n; i++) {
232 assert(
ds.entries() == l);
235 template<
class Tracer>
244 template<
class Tracer>
250 template<
class Tracer>
255 int n =
ds.entries()-1;
264 while (
ds[l].space() == NULL)
266 Space* c =
ds[l].space()->clone();
268 for (
int i=l; i<
n; i++)
270 unsigned int a =
ds[
n].steal();
271 c->commit(*
ds[
n].choice(),a);
275 ngdl(std::min(
ngdl(),
static_cast<unsigned int>(
n)));
276 d = stat.
steal_depth(
static_cast<unsigned long int>(
n+1));
278 ot.ei()->init(myt.wid(),
ds[
n].nid(), a, *c, *
ds[
n].choice());
287 template<
class Tracer>
296 if ((
ds.top().space() != NULL) &&
ds.top().rightmost()) {
299 assert(
ds.entries()-1 ==
lc());
300 ds.top().space(NULL);
302 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
309 int n =
ds.entries();
311 d =
static_cast<unsigned int>(
n - l);
313 Space* s =
ds[l].space()->clone();
317 for (
int i=l; i<
n; i++)
320 int m = l +
static_cast<int>(d >> 1);
326 for (; (i<
n) &&
ds[i].rightmost(); i++)
344 d =
static_cast<unsigned int>(
n-i);
353 template<
class Tracer>
356 const Space& best,
int& mark,
363 if ((
ds.top().space() != NULL) &&
ds.top().rightmost()) {
366 assert(
ds.entries()-1 ==
lc());
367 if (mark >
ds.entries()-1) {
368 mark =
ds.entries()-1;
371 ds.top().space(NULL);
373 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
380 int n =
ds.entries();
382 d =
static_cast<unsigned int>(
n - l);
408 for (
int i=l; i<
n; i++)
411 int m = l +
static_cast<int>(d >> 1);
417 for (; (i<
n) &&
ds[i].rightmost(); i++)
438 d =
static_cast<unsigned int>(
n-i);
447 template<
class Tracer>
Choice for performing commit
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 NULL)
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 NULL)
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 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.
void commit(const Choice &c, unsigned int a, CommitStatistics &stat=unused_commit)
Commit choice c for alternative a.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
@ SS_FAILED
Space is failed
const unsigned int steal_limit
Minimal number of open nodes for stealing.
Gecode toplevel namespace