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) {
427 Space::_trycommit(
const Choice& c,
unsigned int a) {
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) {
566 if (c->d_fst != &Actor::sentinel)
571 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
574 c->d_fst = c->d_cur = c->d_lst = NULL;
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());
592 x->b.base = NULL; x->u.idx[0] = 0;
593 if (
sizeof(
ActorLink**) >
sizeof(
unsigned int))
594 *(1+&x->u.idx[0]) = 0;
614 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
622 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
635 c->pc.
p.active = &c->pc.
p.queue[0]-1;
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;
650 if (cri.
last() != NULL)
663 LocalObject::fwdcopy(
Space& home,
bool share) {
665 next(home.pc.
c.local);
666 home.pc.
c.local =
this;
678 if (gafc.
decay() != 1.0)
680 (
void) gafc.
afc(
p.propagator().gafc);
688 gafc.
set(
p.propagator().gafc,
a);
Double-linked list for actors.
unsigned int alternatives(void) const
Return number of alternatives.
unsigned int propagators(void) const
Return number of propagators.
const NoGoods & nogoods(void) const
Return no-goods recorded from restart.
const Space * last(void) const
Return last solution found (possibly NULL)
void init(void)
Initialize links (self-linked)
Base-class for variable implementations.
virtual Space * copy(bool share)=0
Copying member function.
Space must be branched (at least one brancher left)
void afc_set(double a)
Reset AFC to a.
virtual void print(const Space &home, const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
ActorLink * next(void) const
Routines for double-linked list.
Actor must always be disposed.
Gecode::ActorLink * advisors
A list of advisors (used during cloning)
virtual bool master(const CRI &cri)
Master configuration function for restart meta search engine.
void * subscriptions(void) const
Get the memory area for subscriptions.
ActorLink * prev(void) const
Routines for double-linked list.
Statistics for execution of commit
virtual void post(Space &home) const
Post no-goods.
virtual NGL * ngl(Space &home, const Choice &c, unsigned int a) const
Create no-good literal for choice c and alternative a.
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.
Exception: Operation on failed space invoked
Base-class for variable implementations.
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.
Base-class for both propagators and branchers.
Statistics for execution of status
void fail(Counter &c)
Increment failure count.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
void head(ActorLink *al)
Insert al directly after this.
void print(const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
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
double afc_decay(void) const
Return AFC decay factor.
struct Gecode::Space::@55::@56 p
Data only available during propagation.
void release(SharedMemory *sm)
Release all allocated heap chunks.
Execution has resulted in failure.
Statistics for execution of clone
bool failed(void) const
Check whether space is failed.
ModEventDelta med
A set of modification events (used during propagation)
unsigned int n_sub
Number of subscriptions.
void fail(void)
Fail space.
virtual void constrain(const Space &best)
Constrain function for best solution search.
virtual ~Space(void)
Destructor.
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::@519::NNF::@60::@62 a
For atomic nodes.
Exception: Copy constructor did not call base class copy constructor
virtual bool slave(const CRI &cri)
Slave configuration function for restart meta search engine.
unsigned int id(void) const
Return unsigned brancher id.
Class to iterate over propagators of a space.
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
double afc(Counter &c)
Return failure count.
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.
virtual void archive(Archive &e) const
Archive into e.
Choice for performing commit
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
struct Gecode::Space::@55::@57 c
Data available only during copying.
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
virtual bool notice(void) const
Whether dispose must always be called (returns false)
static NoGoods eng
Empty no-goods.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Internal: propagator has computed partial fixpoint, do not use.
void set(Counter &c, double a)
Set failure count to a.
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.
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.
unsigned int branchers(void) const
Return number of branchers.
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.
void decay(double d)
Set decay factor to d.
Space is solved (no brancher left)
No-good literal recorded during search.