44 template<
class Tracer>
48 template<
class Tracer>
53 template<
class Tracer>
58 template<
class Tracer>
64 template<
class Tracer>
65 forceinline
unsigned int
69 template<
class Tracer>
70 forceinline
unsigned int
74 template<
class Tracer>
79 template<
class Tracer>
84 template<
class Tracer>
89 template<
class Tracer>
95 template<
class Tracer>
101 template<
class Tracer>
102 forceinline
unsigned int
107 template<
class Tracer>
121 template<
class Tracer>
126 template<
class Tracer>
127 forceinline
unsigned int
132 template<
class Tracer>
138 template<
class Tracer>
141 if (!
ds.empty() &&
ds.top().lao()) {
151 template<
class Tracer>
155 if (
ds.top().rightmost()) {
163 template<
class Tracer>
170 template<
class Tracer>
176 template<
class Tracer>
183 template<
class Tracer>
186 int l =
ds.entries()-1;
187 while (
ds[l].space() ==
nullptr)
192 template<
class Tracer>
198 template<
class Tracer>
201 assert((
ds[l].space() ==
nullptr) ||
ds[l].space()->failed());
202 int n =
ds.entries();
204 for (
int i=l; i<
n; i++) {
206 unsigned int fa = (i != l) ?
top.alt() + 1 :
top.alt();
207 for (
unsigned int a = fa; a <
top.choice()->alternatives(); a++) {
214 for (
int i=l; i<
n; i++)
217 assert(
ds.entries() == l);
220 template<
class Tracer>
227 template<
class Tracer>
236 if ((
ds.top().space() !=
nullptr) &&
ds.top().rightmost()) {
239 assert(
ds.entries()-1 ==
lc());
240 ds.top().space(
nullptr);
242 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
249 int n =
ds.entries();
251 d =
static_cast<unsigned int>(
n - l);
253 Space* s =
ds[l].space()->clone();
257 for (
int i=l; i<
n; i++)
260 int m = l +
static_cast<int>(d >> 1);
266 for (; (i<
n) &&
ds[i].rightmost(); i++)
284 d =
static_cast<unsigned int>(
n-i);
293 template<
class Tracer>
296 const Space* best,
int& mark,
303 if ((
ds.top().space() !=
nullptr) &&
ds.top().rightmost()) {
306 assert(
ds.entries()-1 ==
lc());
307 if ((best !=
nullptr) && (mark >
ds.entries()-1)) {
308 mark =
ds.entries()-1;
311 ds.top().space(
nullptr);
313 if (
static_cast<unsigned int>(
ds.entries()) >
ngdl())
320 int n =
ds.entries();
322 d =
static_cast<unsigned int>(
n - l);
326 if ((best !=
nullptr) && (l < mark)) {
348 for (
int i=l; i<
n; i++)
351 int m = l +
static_cast<int>(d >> 1);
357 for (; (i<
n) &&
ds[i].rightmost(); i++)
378 d =
static_cast<unsigned int>(
n-i);
387 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
Space * space(void) const
Return space for edge.
Space * _space
Space corresponding to this edge (might be nullptr).
unsigned int alt(void) const
Return number for alternatives.
Edge(void)
Default constructor.
bool rightmost(void) const
Test whether current alternative is rightmost.
void next(void)
Move to next alternative.
bool leftmost(void) const
Test whether current alternative is leftmost.
bool lao(void) const
Test whether current alternative was LAO.
void dispose(void)
Free memory for edge.
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization).
unsigned int nid(void) const
Return node identifier.
const Choice * _choice
Choice.
const Choice * choice(void) const
Return choice.
unsigned int _alt
Current alternative.
unsigned int _ngdl
Depth limit for no-good generation.
void unwind(int l, Tracer &t)
Unwind the stack up to position l (after failure).
bool empty(void) const
Test whether path is empty.
int entries(void) const
Return number of entries on stack.
int lc(void) const
Return position on stack of last copy.
void next(void)
Generate path for next node.
virtual void post(Space &home) const
Post no-goods.
void commit(Space *s, int i) const
Commit space s as described by stack entry at position i.
unsigned int ngdl(void) const
Return no-good depth limit.
Support::DynamicStack< Edge, Heap > ds
Stack to store edge information.
Path(unsigned int l)
Initialize with no-good depth limit l.
Edge & top(void) const
Provide access to topmost edge.
void reset(void)
Reset stack.
const Choice * push(Worker &stat, Space *s, Space *c, unsigned int nid)
Push space c (a clone of s or nullptr).
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.
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
Gecode toplevel namespace