62 Actor* Actor::sentinel;
66 Actor::~Actor(
void) {}
91 #ifdef GECODE_HAS_VAR_DISPOSE
97 #ifdef GECODE_HAS_VAR_DISPOSE
104 b_status = b_commit = Brancher::cast(&bl);
106 d_fst = d_cur = d_lst = NULL;
108 pc.p.active = &pc.p.queue[0]-1;
111 pc.p.queue[
i].init();
112 pc.p.branch_id = reserved_branch_id+1;
117 Space::d_resize(
void) {
120 d_fst = alloc<Actor*>(4);
125 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
127 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
169 #ifdef GECODE_HAS_VAR_DISPOSE
172 if (_vars_d[
i] != NULL)
198 if (pc.p.active >= &pc.p.queue[0]) {
221 assert(pc.p.active >= &pc.p.queue[0]);
224 if (pc.p.active != fst) {
225 p = Propagator::cast(fst);
235 p->u.
med = 0; p->unlink(); pl.
head(p);
239 assert(pc.p.active >= &pc.p.queue[0]);
242 if (pc.p.active != fst) {
243 p = Propagator::cast(fst);
246 }
while (--pc.p.active >= &pc.p.queue[0]);
247 assert(pc.p.active < &pc.p.queue[0]);
251 goto stable_or_unstable;
254 assert(p->u.
med != 0);
285 while (b_status != Brancher::cast(&bl))
286 if (b_status->
status(*
this)) {
291 b_status = Brancher::cast(b_status->next());
296 stat.
wmp = (wmp() > 0U);
307 if (
failed() || (b_status == Brancher::cast(&bl))) {
311 while (b != Brancher::cast(&bl)) {
313 b = Brancher::cast(b->next());
317 b_status = b_commit = Brancher::cast(&bl);
325 while (b != b_status) {
327 b = Brancher::cast(b->next());
333 return b_status->
choice(*
this);
338 unsigned int id; e >> id;
340 while (b_cur != Brancher::cast(&bl)) {
341 if (
id == b_cur->
id())
342 return b_cur->
choice(*
this,e);
343 b_cur = Brancher::cast(b_cur->next());
349 Space::_commit(
const Choice&
c,
unsigned int a) {
360 throw SpaceNoBrancher(
"Space::commit");
365 Space::kill_brancher(
unsigned int id) {
369 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
373 b_commit = Brancher::cast(
b->next());
375 b_status = Brancher::cast(
b->next());
397 : sm(s.sm->copy(share)),
400 d_fst(&
Actor::sentinel),
401 _wmp_afc(s._wmp_afc) {
402 #ifdef GECODE_HAS_VAR_DISPOSE
407 pc.c.vars_u[
i] = NULL;
408 pc.c.vars_noidx = NULL;
416 Actor* c = Actor::cast(a)->copy(*
this,share);
430 Actor* c = Actor::cast(a)->copy(*
this,share);
440 if (s.b_status == &s.bl) {
441 b_status = Brancher::cast(&bl);
443 b_status = Brancher::cast(s.b_status->prev());
445 if (s.b_commit == &s.bl) {
446 b_commit = Brancher::cast(&bl);
448 b_commit = Brancher::cast(s.b_commit->prev());
453 Space::_clone(
bool share) {
455 throw SpaceFailed(
"Space::clone");
457 throw SpaceNotStable(
"Space::clone");
460 Space* c = copy(share);
462 if (c->d_fst != &Actor::sentinel)
463 throw SpaceNotCloned(
"Space::clone");
467 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
470 c->d_fst = c->d_cur = c->d_lst = NULL;
473 c->d_fst = c->alloc<Actor*>(n+1);
475 c->d_lst = c->d_fst+n+1;
476 for (Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
477 if ((*d_fst_iter)->prev())
478 *(c->d_cur++) = Actor::cast((*d_fst_iter)->prev());
484 VarImp<NoIdxVarImpConf>*
x =
485 static_cast<VarImp<NoIdxVarImpConf>*
>(c->pc.c.vars_noidx);
487 VarImp<NoIdxVarImpConf>* n = x->next();
488 x->b.base = NULL; x->u.idx[0] = 0;
489 if (
sizeof(ActorLink**) >
sizeof(
unsigned int))
490 *(1+&x->u.idx[0]) = 0;
494 c->update(static_cast<ActorLink**>(c->mm.subscriptions()));
498 ActorLink* p_a = &pl;
499 ActorLink* c_a = p_a->next();
502 Propagator* p = Propagator::cast(c_a);
503 if (p->u.advisors != NULL) {
504 ActorLink* a = p->u.advisors;
505 p->u.advisors = NULL;
507 a->prev(p); a = a->next();
510 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
514 ActorLink* p_a = &bl;
515 ActorLink* c_a = p_a->next();
518 c_a->prev(p_a); p_a = c_a; c_a = c_a->next();
523 for (SharedHandle::Object* s = c->pc.c.shared; s != NULL; s = s->next)
527 for (ActorLink*
l = c->pc.c.local;
l != NULL;
l =
l->next())
531 c->pc.p.active = &c->pc.p.queue[0]-1;
532 for (
int i=0;
i<=PropCost::AC_MAX;
i++)
533 c->pc.p.queue[
i].init();
535 c->pc.p.n_sub = pc.p.n_sub;
536 c->pc.p.branch_id = pc.p.branch_id;
545 Space::master(
unsigned long int,
const Space*) {
549 Space::slave(
unsigned long int,
const Space*) {
553 LocalObject::fwdcopy(
Space& home,
bool share) {
554 ActorLink::cast(
this)->prev(copy(home,share));
555 next(home.pc.
c.local);
556 home.pc.
c.local =
this;
565 Space::afc_decay(
double d) {
568 if (gafc.decay() != 1.0)
569 for (Propagators
p(*
this);
p(); ++
p)
570 (
void) gafc.afc(p.propagator().gafc);