57 Actor* Actor::sentinel;
98 std::ostream&)
const {
111 #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.bid_sc = (reserved_bid+1) << sc_bits;
136 Space::ap_notice_dispose(
Actor*
a,
bool duplicate) {
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);
163 Space::ap_ignore_dispose(
Actor* a,
bool duplicate) {
165 assert(d_fst != NULL);
198 #ifdef GECODE_HAS_VAR_DISPOSE 201 if (_vars_d[
i] != NULL)
216 Space::findtracerecorder(
void) {
217 for (
Actor** a=d_fst; a<d_cur; a++) {
236 if (pc.p.active >= &pc.p.queue[0]) {
238 if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == 0) {
257 assert(pc.p.active >= &pc.p.queue[0]);
260 if (pc.p.active != fst) {
261 p = Propagator::cast(fst);
273 p->unlink(); pl.
head(p);
274 f_stable_or_unstable:
277 assert(pc.p.active >= &pc.p.queue[0]);
280 if (pc.p.active != fst) {
281 p = Propagator::cast(fst);
284 }
while (--pc.p.active >= &pc.p.queue[0]);
285 assert(pc.p.active < &pc.p.queue[0]);
289 goto f_stable_or_unstable;
292 assert(p->u.
med != 0);
299 }
else if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == sc_disabled) {
305 goto d_put_into_idle;
319 assert(pc.p.active >= &pc.p.queue[0]);
322 if (pc.p.active != fst) {
323 p = Propagator::cast(fst);
336 p->unlink(); pl.
head(p);
337 d_stable_or_unstable:
340 assert(pc.p.active >= &pc.p.queue[0]);
343 if (pc.p.active != fst) {
344 p = Propagator::cast(fst);
347 }
while (--pc.p.active >= &pc.p.queue[0]);
348 assert(pc.p.active < &pc.p.queue[0]);
352 goto d_stable_or_unstable;
355 assert(p->u.
med != 0);
367 #define GECODE_STATUS_TRACE(q,s) \ 368 if ((tr != NULL) && (tr->events() & TE_PROPAGATE) && \ 369 (tr->filter()(p->group()))) { \ 370 PropagateTraceInfo pti(p->id(),p->group(),q, \ 371 PropagateTraceInfo::s); \ 372 tr->tracer()._propagate(*this,pti); \ 379 goto t_put_into_idle;
380 pc.p.vti.propagator(*p);
396 assert(pc.p.active >= &pc.p.queue[0]);
399 if (pc.p.active != fst) {
400 p = Propagator::cast(fst);
414 p->unlink(); pl.
head(p);
415 t_stable_or_unstable:
418 assert(pc.p.active >= &pc.p.queue[0]);
421 if (pc.p.active != fst) {
422 p = Propagator::cast(fst);
425 }
while (--pc.p.active >= &pc.p.queue[0]);
426 assert(pc.p.active < &pc.p.queue[0]);
431 goto t_stable_or_unstable;
435 assert(p->u.
med != 0);
443 #undef GECODE_STATUS_TRACE 470 while (b_status != Brancher::cast(&bl))
471 if (b_status->
status(*
this)) {
476 b_status = Brancher::cast(b_status->next());
495 switch (top->
propagate(*
this,top_med_o)) {
511 if (
failed() || (b_status == Brancher::cast(&bl))) {
515 while (b != Brancher::cast(&bl)) {
517 b = Brancher::cast(b->next());
521 b_status = b_commit = Brancher::cast(&bl);
529 while (b != b_status) {
531 b = Brancher::cast(b->next());
537 return b_status->
choice(*
this);
542 unsigned int id; e >> id;
544 while (b_cur != Brancher::cast(&bl)) {
545 if (
id == b_cur->
id())
546 return b_cur->
choice(*
this,e);
547 b_cur = Brancher::cast(b_cur->next());
553 Space::_commit(
const Choice&
c,
unsigned int a) {
560 if (pc.p.bid_sc & sc_trace) {
565 tr->
tracer()._commit(*
this,cti);
567 pc.p.vti.brancher(*
b);
583 Space::_trycommit(
const Choice& c,
unsigned int a) {
590 if (pc.p.bid_sc & sc_trace) {
595 tr->
tracer()._commit(*
this,cti);
597 pc.p.vti.brancher(*
b);
617 return b->ngl(*
this,c,a);
629 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c.bid)) {
631 b->print(*
this,c,a,o);
639 Space::kill_brancher(
unsigned int id) {
643 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
665 d_fst(&
Actor::sentinel) {
666 #ifdef GECODE_HAS_VAR_DISPOSE 671 pc.c.vars_u[
i] = NULL;
672 pc.c.vars_noidx = NULL;
679 Actor* c = Actor::cast(a)->copy(*
this);
693 Actor* c = Actor::cast(a)->copy(*
this);
703 if (s.b_status == &s.bl) {
704 b_status = Brancher::cast(&bl);
706 b_status = Brancher::cast(s.b_status->prev());
708 if (s.b_commit == &s.bl) {
709 b_commit = Brancher::cast(&bl);
711 b_commit = Brancher::cast(s.b_commit->prev());
716 Space::_clone(
void) {
725 if (c->d_fst != &Actor::sentinel)
730 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
733 c->d_fst = c->d_cur = c->d_lst = NULL;
738 c->d_lst = c->d_fst+n+1;
739 for (
Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
743 *(c->d_cur++) = Actor::cast(static_cast<ActorLink*>
754 x->b.base = NULL; x->u.idx[0] = 0;
755 if (
sizeof(
ActorLink**) >
sizeof(
unsigned int))
756 *(1+&x->u.idx[0]) = 0;
776 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
784 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
793 c->pc.
p.active = &c->pc.
p.queue[0]-1;
795 c->pc.
p.queue[
i].init();
797 c->pc.
p.n_sub = pc.p.n_sub;
798 c->pc.
p.bid_sc = pc.p.bid_sc;
801 c->pc.
p.vti.other(); pc.p.vti.other();
814 if (mi.
last() != NULL)
844 p.gpi_disabled = gpi;
850 LocalObject::fwdcopy(
Space& home) {
852 next(home.pc.
c.local);
853 home.pc.
c.local =
this;
891 if (gid == GROUPID_MAX)
898 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
900 if (g.
in(ps.propagator().group()))
901 ps.propagator().group(*
this);
907 if (
id() == GROUPID_ALL)
910 if (ps.propagator().id() == pid) {
911 ps.propagator().group(*
this);
925 if (in(ps.propagator().group()))
948 if (in(ps.propagator().group()))
949 ps.propagator().disable(home);
968 if (in(ps.propagator().group()))
969 ps.propagator().enable(home);
976 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
978 if (g.
in(bs.brancher().group()))
979 bs.brancher().group(*
this);
985 if (
id() == GROUPID_ALL)
988 if (bs.brancher().id() == bid) {
989 bs.brancher().group(*
this);
1003 if (in(bs.brancher().group()))
Double-linked list for actors.
unsigned int alternatives(void) const
Return number of alternatives.
bool marked(void *p)
Check whether p is marked.
Reserved for recording information.
void init(void)
Initialize links (self-linked)
Base-class for variable implementations.
Space must be branched (at least one brancher left)
Info * allocate(unsigned int p, unsigned int gid)
Allocate info for existing propagator with pid p.
static BrancherGroup all
Group of all branchers.
Kernel::GPI::Info & gpi(void)
Provide access to global propagator information.
void fail(Info &c)
Increment failure count.
bool in(Group a) const
Check whether actor group a is included in this group.
SharedMemory sm
The shared memory area.
virtual void print(const Space &home, const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
void kill(Space &home)
Kill all branchers in a group.
ActorLink * next(void) const
Routines for double-linked list.
Gecode::ActorLink * advisors
A list of advisors (used during cloning)
virtual void reschedule(Space &home)=0
Schedule function.
void disable(Space &home)
Disable all propagators in a group.
static PropagatorGroup all
Group of all propagators.
static BrancherGroup def
Group of branchers not in any user-defined group.
ActorLink * prev(void) const
Routines for double-linked list.
Statistics for execution of commit
virtual void post(Space &home) const
Post no-goods.
bool unshare(void)
Provide access to unshare info and set to true.
Exception: unknown brancher
virtual Space * copy(void)=0
Copying member function.
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.
#define GECODE_STATUS_TRACE(q, s)
Node representing failure.
Exception: Commit with illegal alternative
Exception: too many groups
Exception: Operation on failed space invoked
static Group def
Group of actors not in any user-defined group.
void kill(Space &home)
Kill all propagators in a group.
void * mark(void *p)
Return marked pointer for unmarked pointer p.
BrancherGroup & move(Space &home, BrancherGroup g)
Move branchers from group g to this group.
Base-class for variable implementations.
unsigned long int propagate
Number of propagator executions.
Propagation has computed fixpoint.
unsigned int id(void) const
Return a unique id for the group.
virtual bool status(const Space &home) const =0
Check status of brancher, return true if alternatives left.
unsigned int size(Space &home) const
Return number of propagators in a group.
Trace commit operations by branchers.
Base-class for both propagators and branchers.
const TraceFilter & filter(void) const
Return trace filter.
Statistics for execution of status
A mutex for mutual exclausion among several threads.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
virtual ~Actor(void)
To avoid warnings.
PropagatorGroup & move(Space &home, PropagatorGroup g)
Move propagators from group g to this group.
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.
void afc_unshare(void)
Unshare AFC information for all propagators.
Tracer & tracer(void) const
Return tracer.
int n
Number of negative literals for node type.
BrancherGroup group(void) const
Return group brancher belongs to.
Exception: Operation on not stable space invoked
Execution has resulted in failure.
Commit trace information.
Propagator & propagator(void) const
Return propagator.
Exception: unknown propagator
Propagator for recording trace information.
Statistics for execution of clone
unsigned int size(Space &home) const
Return number of branchers in a group.
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.
struct Gecode::Space::@58::@59 p
Data only available during propagation or branching.
bool stable(void) const
Return if space is stable (at fixpoint or failed)
struct Gecode::Space::@58::@60 c
Data available only during copying.
Data & data(void) const
Provide access.
void * ptrjoin(void *p, ptrdiff_t m)
Join unmarked pointer p and m into marked pointer.
virtual const Choice * choice(Space &home)=0
Return choice.
PropagatorGroup group(void) const
Return group propagator belongs to.
size_t size
The size of the propagator (used during subsumption)
static Support::Mutex m
Mutex for protection.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Advise function.
virtual bool slave(const MetaInfo &mi)
Slave configuration function for meta search engines.
Group baseclass for controlling actors.
bool disabled(void) const
Whether propagator is currently disabled.
Exception: Copy constructor did not call base class copy constructor
static unsigned int next
Next group id.
void * subscriptions(void) const
Get the memory area for subscriptions.
unsigned int id(void) const
Return brancher id.
Class to iterate over propagators of a space.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
static PropagatorGroup def
Group of propagators not in any user-defined group.
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Class for storing propagator information.
Generic domain change information to be supplied to advisors.
Space(void)
Default constructor.
static const int idx_c
Index for cloning.
virtual void archive(Archive &e) const
Archive into e.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Choice for performing commit
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
void enable(Space &home, bool s=true)
Enable all propagators in a group.
virtual bool notice(void) const
Whether dispose must always be called (returns false)
virtual bool master(const MetaInfo &mi)
Master configuration function for meta search engines.
virtual ~NGL(void)
To avoid warnings.
static NoGoods eng
Empty no-goods.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Internal: propagator has computed partial fixpoint, do not use.
Post propagator for SetVar x
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.
void * ptrsplit(void *p, ptrdiff_t &m)
Split possibly marked pointer p into mark m and unmarked pointer.
void release(SharedMemory &sm)
Release all allocated heap chunks.
Gecode toplevel namespace
static Group all
Group of all actors.
unsigned int pid
Propagator identifier.
int events(void) const
Which events to trace.
virtual ~VarImpDisposerBase(void)
Destructor (not used)
const Choice * choice(void)
Create new choice for current brancher.
GPI gpi
The global propagator information.
int ModEventDelta
Modification event deltas.
unsigned int gid
Group identifier.
static const int idx_d
Index for dispose.
#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.
Brancher & brancher(void) const
Return propagator.
Base class for Variable type disposer.
void rfree(void *p, size_t s)
Free memory previously allocated with alloc (might be reused later)
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Space is solved (no brancher left)
No-good literal recorded during search.