57 Actor* Actor::sentinel;
60 Actor::~Actor(
void) {}
98 std::ostream&)
const {
110 #ifdef GECODE_HAS_VAR_DISPOSE
116 #ifdef GECODE_HAS_VAR_DISPOSE
123 b_status = b_commit = Brancher::cast(&bl);
125 d_fst = d_cur = d_lst = NULL;
127 pc.p.active = &pc.p.queue[0]-1;
130 pc.p.queue[
i].init();
131 pc.p.branch_id = reserved_branch_id+1;
138 if (duplicate && (d_fst != NULL)) {
139 for (
Actor** f = d_fst; f < d_cur; f++)
143 if (d_cur == d_lst) {
147 d_fst = alloc<Actor*>(4);
152 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
154 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
231 #ifdef GECODE_HAS_VAR_DISPOSE
234 if (_vars_d[
i] != NULL)
260 if (pc.p.active >= &pc.p.queue[0]) {
283 assert(pc.p.active >= &pc.p.queue[0]);
286 if (pc.p.active != fst) {
287 p = Propagator::cast(fst);
297 p->u.
med = 0; p->unlink(); pl.
head(p);
301 assert(pc.p.active >= &pc.p.queue[0]);
304 if (pc.p.active != fst) {
305 p = Propagator::cast(fst);
308 }
while (--pc.p.active >= &pc.p.queue[0]);
309 assert(pc.p.active < &pc.p.queue[0]);
313 goto stable_or_unstable;
316 assert(p->u.
med != 0);
347 while (b_status != Brancher::cast(&bl))
348 if (b_status->
status(*
this)) {
353 b_status = Brancher::cast(b_status->next());
358 stat.
wmp = (wmp() > 0U);
369 if (
failed() || (b_status == Brancher::cast(&bl))) {
373 while (b != Brancher::cast(&bl)) {
375 b = Brancher::cast(b->next());
379 b_status = b_commit = Brancher::cast(&bl);
387 while (b != b_status) {
389 b = Brancher::cast(b->next());
395 return b_status->
choice(*
this);
400 unsigned int id; e >> id;
402 while (b_cur != Brancher::cast(&bl)) {
403 if (
id == b_cur->
id())
404 return b_cur->
choice(*
this,e);
405 b_cur = Brancher::cast(b_cur->next());
411 Space::_commit(
const Choice&
c,
unsigned int a) {
422 throw SpaceNoBrancher(
"Space::commit");
427 Space::_trycommit(
const Choice& c,
unsigned int a) {
428 if (a >= c.alternatives())
429 throw SpaceIllegalAlternative(
"Space::commit");
447 return b->ngl(*
this,c,a);
459 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c._id)) {
461 b->print(*
this,c,a,o);
469 Space::kill_brancher(
unsigned int id) {
473 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
477 b_commit = Brancher::cast(
b->next());
479 b_status = Brancher::cast(
b->next());
501 : sm(s.sm->copy(share)),
504 d_fst(&
Actor::sentinel),
505 _wmp_afc(s._wmp_afc) {
506 #ifdef GECODE_HAS_VAR_DISPOSE
511 pc.c.vars_u[
i] = NULL;
512 pc.c.vars_noidx = NULL;
520 Actor* c = Actor::cast(a)->
copy(*
this,share);
534 Actor* c = Actor::cast(a)->
copy(*
this,share);
544 if (s.b_status == &s.bl) {
545 b_status = Brancher::cast(&bl);
547 b_status = Brancher::cast(s.b_status->prev());
549 if (s.b_commit == &s.bl) {
550 b_commit = Brancher::cast(&bl);
552 b_commit = Brancher::cast(s.b_commit->prev());
557 Space::_clone(
bool share) {
559 throw SpaceFailed(
"Space::clone");
561 throw SpaceNotStable(
"Space::clone");
564 Space* c = copy(share);
566 if (c->d_fst != &Actor::sentinel)
567 throw SpaceNotCloned(
"Space::clone");
571 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
574 c->d_fst = c->d_cur = c->d_lst = NULL;
577 c->d_fst = c->alloc<Actor*>(n+1);
579 c->d_lst = c->d_fst+n+1;
580 for (Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
581 if ((*d_fst_iter)->prev())
582 *(c->d_cur++) = Actor::cast((*d_fst_iter)->prev());
588 VarImp<NoIdxVarImpConf>*
x =
589 static_cast<VarImp<NoIdxVarImpConf>*
>(c->pc.c.vars_noidx);
591 VarImp<NoIdxVarImpConf>* n = x->next();
592 x->b.base = NULL; x->u.idx[0] = 0;
593 if (
sizeof(ActorLink**) >
sizeof(
unsigned int))
594 *(1+&x->u.idx[0]) = 0;
598 c->update(static_cast<ActorLink**>(c->mm.subscriptions()));
602 ActorLink* p_a = &pl;
603 ActorLink* c_a = p_a->next();
606 Propagator* p = Propagator::cast(c_a);
607 if (p->u.advisors != NULL) {
608 ActorLink* a = p->u.advisors;
609 p->u.advisors = NULL;
611 a->prev(p); a = a->next();
614 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
618 ActorLink* p_a = &bl;
619 ActorLink* c_a = p_a->next();
622 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
627 for (SharedHandle::Object* s = c->pc.c.shared; s != NULL; s = s->next)
631 for (ActorLink*
l = c->pc.c.local;
l != NULL;
l =
l->next())
635 c->pc.p.active = &c->pc.p.queue[0]-1;
636 for (
int i=0;
i<=PropCost::AC_MAX;
i++)
637 c->pc.p.queue[
i].init();
639 c->pc.p.n_sub = pc.p.n_sub;
640 c->pc.p.branch_id = pc.p.branch_id;
649 Space::master(
const CRI& cri) {
650 if (cri.
last() != NULL)
651 constrain(*cri.
last());
658 Space::slave(
const CRI&) {
663 LocalObject::fwdcopy(
Space& home,
bool share) {
664 ActorLink::cast(
this)->prev(copy(home,share));
665 next(home.pc.
c.local);
666 home.pc.
c.local =
this;
675 Space::afc_decay(
double d) {
678 if (gafc.decay() != 1.0)
680 (
void) gafc.afc(p.propagator().gafc);
685 Space::afc_set(
double a) {
688 gafc.set(p.propagator().gafc,
a);
693 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.
Current restart information during search.
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.
virtual void post(Space &home) const
Post no-goods.
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.
const Space * last(void) const
Return last solution found (possibly NULL)
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::Space::@52::@53 p
Data only available during propagation.
struct Gecode::Space::@52::@54 c
Data available only during copying.
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
static NoGoods eng
Empty no-goods.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Internal: propagator has computed partial fixpoint, do not use.
Propagation has not computed fixpoint.
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.
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.
const NoGoods & nogoods(void) const
Return no-goods recorded from restart.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
ActorProperty
Actor properties.
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.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
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.