57 Actor* Actor::sentinel;
60 Actor::~Actor(
void) {}
97 std::ostream&)
const {
109 #ifdef GECODE_HAS_VAR_DISPOSE
115 #ifdef GECODE_HAS_VAR_DISPOSE
122 b_status = b_commit = Brancher::cast(&bl);
124 d_fst = d_cur = d_lst = NULL;
126 pc.p.active = &pc.p.queue[0]-1;
129 pc.p.queue[
i].init();
130 pc.p.branch_id = reserved_branch_id+1;
137 if (duplicate && (d_fst != NULL)) {
138 for (
Actor** f = d_fst; f < d_cur; f++)
142 if (d_cur == d_lst) {
146 d_fst = alloc<Actor*>(4);
151 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
153 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
230 #ifdef GECODE_HAS_VAR_DISPOSE
233 if (_vars_d[
i] != NULL)
259 if (pc.p.active >= &pc.p.queue[0]) {
282 assert(pc.p.active >= &pc.p.queue[0]);
285 if (pc.p.active != fst) {
286 p = Propagator::cast(fst);
296 p->u.
med = 0; p->unlink(); pl.
head(p);
300 assert(pc.p.active >= &pc.p.queue[0]);
303 if (pc.p.active != fst) {
304 p = Propagator::cast(fst);
307 }
while (--pc.p.active >= &pc.p.queue[0]);
308 assert(pc.p.active < &pc.p.queue[0]);
312 goto stable_or_unstable;
315 assert(p->u.
med != 0);
346 while (b_status != Brancher::cast(&bl))
347 if (b_status->
status(*
this)) {
352 b_status = Brancher::cast(b_status->next());
357 stat.
wmp = (wmp() > 0U);
368 if (
failed() || (b_status == Brancher::cast(&bl))) {
372 while (b != Brancher::cast(&bl)) {
374 b = Brancher::cast(b->next());
378 b_status = b_commit = Brancher::cast(&bl);
386 while (b != b_status) {
388 b = Brancher::cast(b->next());
394 return b_status->
choice(*
this);
399 unsigned int id; e >> id;
401 while (b_cur != Brancher::cast(&bl)) {
402 if (
id == b_cur->
id())
403 return b_cur->
choice(*
this,e);
404 b_cur = Brancher::cast(b_cur->next());
410 Space::_commit(
const Choice&
c,
unsigned int a) {
421 throw SpaceNoBrancher(
"Space::commit");
426 Space::_trycommit(
const Choice& c,
unsigned int a) {
427 if (a >= c.alternatives())
428 throw SpaceIllegalAlternative(
"Space::commit");
446 return b->ngl(*
this,c,a);
458 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c._id)) {
460 b->print(*
this,c,a,o);
468 Space::kill_brancher(
unsigned int id) {
472 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
476 b_commit = Brancher::cast(
b->next());
478 b_status = Brancher::cast(
b->next());
500 : sm(s.sm->copy(share)),
503 d_fst(&
Actor::sentinel),
504 _wmp_afc(s._wmp_afc) {
505 #ifdef GECODE_HAS_VAR_DISPOSE
510 pc.c.vars_u[
i] = NULL;
511 pc.c.vars_noidx = NULL;
519 Actor* c = Actor::cast(a)->
copy(*
this,share);
533 Actor* c = Actor::cast(a)->
copy(*
this,share);
543 if (s.b_status == &s.bl) {
544 b_status = Brancher::cast(&bl);
546 b_status = Brancher::cast(s.b_status->prev());
548 if (s.b_commit == &s.bl) {
549 b_commit = Brancher::cast(&bl);
551 b_commit = Brancher::cast(s.b_commit->prev());
556 Space::_clone(
bool share) {
558 throw SpaceFailed(
"Space::clone");
560 throw SpaceNotStable(
"Space::clone");
563 Space* c = copy(share);
565 if (c->d_fst != &Actor::sentinel)
566 throw SpaceNotCloned(
"Space::clone");
570 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
573 c->d_fst = c->d_cur = c->d_lst = NULL;
576 c->d_fst = c->alloc<Actor*>(n+1);
578 c->d_lst = c->d_fst+n+1;
579 for (Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
580 if ((*d_fst_iter)->prev())
581 *(c->d_cur++) = Actor::cast((*d_fst_iter)->prev());
587 VarImp<NoIdxVarImpConf>*
x =
588 static_cast<VarImp<NoIdxVarImpConf>*
>(c->pc.c.vars_noidx);
590 VarImp<NoIdxVarImpConf>* n = x->next();
591 x->b.base = NULL; x->u.idx[0] = 0;
592 if (
sizeof(ActorLink**) >
sizeof(
unsigned int))
593 *(1+&x->u.idx[0]) = 0;
597 c->update(static_cast<ActorLink**>(c->mm.subscriptions()));
601 ActorLink* p_a = &pl;
602 ActorLink* c_a = p_a->next();
605 Propagator* p = Propagator::cast(c_a);
606 if (p->u.advisors != NULL) {
607 ActorLink* a = p->u.advisors;
608 p->u.advisors = NULL;
610 a->prev(p); a = a->next();
613 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
617 ActorLink* p_a = &bl;
618 ActorLink* c_a = p_a->next();
621 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
626 for (SharedHandle::Object* s = c->pc.c.shared; s != NULL; s = s->next)
630 for (ActorLink*
l = c->pc.c.local;
l != NULL;
l =
l->next())
634 c->pc.p.active = &c->pc.p.queue[0]-1;
635 for (
int i=0;
i<=PropCost::AC_MAX;
i++)
636 c->pc.p.queue[
i].init();
638 c->pc.p.n_sub = pc.p.n_sub;
639 c->pc.p.branch_id = pc.p.branch_id;
653 Space::slave(
unsigned long int,
const Space*) {
657 LocalObject::fwdcopy(
Space& home,
bool share) {
658 ActorLink::cast(
this)->prev(copy(home,share));
659 next(home.pc.
c.local);
660 home.pc.
c.local =
this;
669 Space::afc_decay(
double d) {
672 if (gafc.decay() != 1.0)
674 (
void) gafc.afc(p.propagator().gafc);
679 Space::afc_set(
double a) {
682 gafc.set(p.propagator().gafc,
a);
687 NGL::notice(
void)
const {
Double-linked list for actors.
void init(void)
Initialize links (self-linked)
Space must be branched (at least one brancher left)
ActorLink * prev(void) const
Routines for double-linked list.
virtual Actor * copy(Space &home, bool share)=0
Create copy.
Actor must always be disposed.
void id(CArray t1, int w1, int h1, Array t2, int &w2, int &h2)
Identity symmetry.
Statistics for execution of commit
unsigned int branchers(void) const
Return number of branchers.
Base-class for propagators.
Internal: propagator is subsumed, do not use.
Exception: Commit with illegal alternative
bool wmp
Whether a weakly monotonic propagator might have been executed.
unsigned int alternatives(void) const
Return number of alternatives.
Base-class for variable implementations.
ActorLink * next(void) const
Routines for double-linked list.
unsigned long int propagate
Number of propagator executions.
Propagation has computed fixpoint.
virtual bool status(const Space &home) const =0
Check status of brancher, return true if alternatives left.
bool failed(void) const
Check whether space is failed.
Base-class for both propagators and branchers.
Statistics for execution of status
void fail(Counter &c)
Increment failure count.
void head(ActorLink *al)
Insert al directly after this.
Gecode::FloatVal c(-8, 8)
unsigned int propagators(void) const
Return number of propagators.
int p
Number of positive literals for node type.
Class to iterate over branchers of a space.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
int n
Number of negative literals for node type.
Exception: Operation on not stable space invoked
void release(SharedMemory *sm)
Release all allocated heap chunks.
Execution has resulted in failure.
Statistics for execution of clone
virtual NGL * ngl(Space &home, const Choice &c, unsigned int a) const
Create no-good literal for choice c and alternative a.
ModEventDelta med
A set of modification events (used during propagation)
void fail(void)
Fail space.
virtual ~Space(void)
Destructor.
void print(const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
bool stable(void) const
Return if space is stable (at fixpoint or failed)
virtual const Choice * choice(Space &home)=0
Return choice.
void flush(void)
Flush cached memory blocks.
size_t size
The size of the propagator (used during subsumption)
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Advise function.
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
Class to iterate over propagators of a space.
Node * x
Pointer to corresponding Boolean expression node.
Generic domain change information to be supplied to advisors.
Space(void)
Default constructor.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
static const int idx_c
Index for cloning.
Choice for performing commit
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
No-goods recorded from restarts.
virtual size_t dispose(Space &home)
Delete actor and return its size.
static ActorLink * cast(T *a)
Static cast for a non-null pointer (to give a hint to optimizer)
Exception: Commit when no brancher present
struct Gecode::Space::@49::@51 c
Data available only during copying.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Internal: propagator has computed partial fixpoint, do not use.
Propagation has not computed fixpoint.
virtual void post(Space &home)
Post no-goods.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)=0
Propagation function.
virtual void dispose(Space &home, VarImpBase *x)
Dispose list of variable implementations starting at x.
struct Gecode::Space::@49::@50 p
Data only available during propagation.
unsigned int id(void) const
Return unsigned brancher id.
virtual void print(const Space &home, const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
Gecode toplevel namespace
ActorProperty
Actor properties.
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
virtual ~VarImpDisposerBase(void)
Destructor (not used)
const Choice * choice(void)
Create new choice for current brancher.
int ModEventDelta
Modification event deltas.
static const int idx_d
Index for dispose.
Shared object for several memory areas.
#define GECODE_NEVER
Assert that this command is never executed.
NGL * ngl(const Choice &c, unsigned int a)
Create no-good literal for choice c and alternative a.
void flush(void)
Flush all cached memory.
Base class for Variable type disposer.
void rfree(void *p, size_t s)
Free memory previously allocated with alloc (might be reused later)
bool release(void)
Release by one space.
Space is solved (no brancher left)
No-good literal recorded during search.