57 Actor* Actor::sentinel;
98 std::ostream&)
const {
111 #ifdef GECODE_HAS_VAR_DISPOSE 116 #ifdef GECODE_HAS_CBS 119 #ifdef GECODE_HAS_VAR_DISPOSE 126 b_status = b_commit = Brancher::cast(&bl);
128 d_fst = d_cur = d_lst = NULL;
130 pc.p.active = &pc.p.queue[0]-1;
133 pc.p.queue[
i].init();
134 pc.p.bid_sc = (reserved_bid+1) << sc_bits;
139 Space::ap_notice_dispose(
Actor*
a,
bool duplicate) {
141 if (duplicate && (d_fst != NULL)) {
142 for (
Actor**
f = d_fst;
f < d_cur;
f++)
146 if (d_cur == d_lst) {
150 d_fst = alloc<Actor*>(4);
155 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
157 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
166 Space::ap_ignore_dispose(
Actor* a,
bool duplicate) {
168 assert(d_fst != NULL);
201 #ifdef GECODE_HAS_VAR_DISPOSE 204 if (_vars_d[
i] != NULL)
219 Space::findtracerecorder(
void) {
220 for (
Actor** a=d_fst; a<d_cur; a++) {
239 if (pc.p.active >= &pc.p.queue[0]) {
241 if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == 0) {
260 assert(pc.p.active >= &pc.p.queue[0]);
263 if (pc.p.active != fst) {
264 p = Propagator::cast(fst);
276 p->unlink(); pl.
head(p);
277 f_stable_or_unstable:
280 assert(pc.p.active >= &pc.p.queue[0]);
283 if (pc.p.active != fst) {
284 p = Propagator::cast(fst);
287 }
while (--pc.p.active >= &pc.p.queue[0]);
288 assert(pc.p.active < &pc.p.queue[0]);
292 goto f_stable_or_unstable;
295 assert(p->u.
med != 0);
302 }
else if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == sc_disabled) {
308 goto d_put_into_idle;
322 assert(pc.p.active >= &pc.p.queue[0]);
325 if (pc.p.active != fst) {
326 p = Propagator::cast(fst);
339 p->unlink(); pl.
head(p);
340 d_stable_or_unstable:
343 assert(pc.p.active >= &pc.p.queue[0]);
346 if (pc.p.active != fst) {
347 p = Propagator::cast(fst);
350 }
while (--pc.p.active >= &pc.p.queue[0]);
351 assert(pc.p.active < &pc.p.queue[0]);
355 goto d_stable_or_unstable;
358 assert(p->u.
med != 0);
370 #define GECODE_STATUS_TRACE(q,s) \ 371 if ((tr != NULL) && (tr->events() & TE_PROPAGATE) && \ 372 (tr->filter()(p->group()))) { \ 373 PropagateTraceInfo pti(p->id(),p->group(),q, \ 374 PropagateTraceInfo::s); \ 375 tr->tracer()._propagate(*this,pti); \ 382 goto t_put_into_idle;
383 pc.p.vti.propagator(*p);
399 assert(pc.p.active >= &pc.p.queue[0]);
402 if (pc.p.active != fst) {
403 p = Propagator::cast(fst);
417 p->unlink(); pl.
head(p);
418 t_stable_or_unstable:
421 assert(pc.p.active >= &pc.p.queue[0]);
424 if (pc.p.active != fst) {
425 p = Propagator::cast(fst);
428 }
while (--pc.p.active >= &pc.p.queue[0]);
429 assert(pc.p.active < &pc.p.queue[0]);
434 goto t_stable_or_unstable;
438 assert(p->u.
med != 0);
446 #undef GECODE_STATUS_TRACE 473 while (b_status != Brancher::cast(&bl))
474 if (b_status->
status(*
this)) {
479 b_status = Brancher::cast(b_status->next());
498 switch (top->
propagate(*
this,top_med_o)) {
514 if (
failed() || (b_status == Brancher::cast(&bl))) {
518 while (b != Brancher::cast(&bl)) {
520 b = Brancher::cast(b->next());
524 b_status = b_commit = Brancher::cast(&bl);
532 while (b != b_status) {
534 b = Brancher::cast(b->next());
540 return b_status->
choice(*
this);
545 unsigned int id; e >> id;
547 while (b_cur != Brancher::cast(&bl)) {
548 if (
id == b_cur->
id())
549 return b_cur->
choice(*
this,e);
550 b_cur = Brancher::cast(b_cur->next());
556 Space::_commit(
const Choice&
c,
unsigned int a) {
563 if (pc.p.bid_sc & sc_trace) {
568 tr->
tracer()._commit(*
this,cti);
570 pc.p.vti.brancher(*
b);
586 Space::_trycommit(
const Choice& c,
unsigned int a) {
593 if (pc.p.bid_sc & sc_trace) {
598 tr->
tracer()._commit(*
this,cti);
600 pc.p.vti.brancher(*
b);
620 return b->ngl(*
this,c,a);
632 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c.bid)) {
634 b->print(*
this,c,a,o);
642 Space::kill_brancher(
unsigned int id) {
646 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
669 var_id_counter(s.var_id_counter),
671 d_fst(&
Actor::sentinel) {
672 #ifdef GECODE_HAS_VAR_DISPOSE 677 pc.c.vars_u[
i] = NULL;
678 pc.c.vars_noidx = NULL;
685 Actor* c = Actor::cast(a)->copy(*
this);
699 Actor* c = Actor::cast(a)->copy(*
this);
709 if (s.b_status == &s.bl) {
710 b_status = Brancher::cast(&bl);
712 b_status = Brancher::cast(s.b_status->prev());
714 if (s.b_commit == &s.bl) {
715 b_commit = Brancher::cast(&bl);
717 b_commit = Brancher::cast(s.b_commit->prev());
722 Space::_clone(
void) {
731 if (c->d_fst != &Actor::sentinel)
736 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
739 c->d_fst = c->d_cur = c->d_lst = NULL;
744 c->d_lst = c->d_fst+n+1;
745 for (
Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
749 *(c->d_cur++) = Actor::cast(static_cast<ActorLink*>
760 x->b.base = NULL; x->u.idx[0] = 0;
761 if (
sizeof(
ActorLink**) >
sizeof(
unsigned int))
762 *(1+&x->u.idx[0]) = 0;
782 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
790 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
799 c->pc.
p.active = &c->pc.
p.queue[0]-1;
801 c->pc.
p.queue[
i].init();
803 c->pc.
p.n_sub = pc.p.n_sub;
804 c->pc.
p.bid_sc = pc.p.bid_sc;
807 c->pc.
p.vti.other(); pc.p.vti.other();
820 if (mi.
last() != NULL)
850 p.gpi_disabled = gpi;
856 LocalObject::fwdcopy(
Space& home) {
858 next(home.pc.
c.local);
859 home.pc.
c.local =
this;
897 if (gid == GROUPID_MAX)
904 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
906 if (g.
in(ps.propagator().group()))
907 ps.propagator().group(*
this);
913 if (
id() == GROUPID_ALL)
916 if (ps.propagator().id() == pid) {
917 ps.propagator().group(*
this);
931 if (in(ps.propagator().group()))
954 if (in(ps.propagator().group()))
955 ps.propagator().disable(home);
974 if (in(ps.propagator().group()))
975 ps.propagator().enable(home);
982 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
984 if (g.
in(bs.brancher().group()))
985 bs.brancher().group(*
this);
991 if (
id() == GROUPID_ALL)
994 if (bs.brancher().id() == bid) {
995 bs.brancher().group(*
this);
1009 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.
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
Gecode::IntArgs i({1, 2, 3, 4})
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.
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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.
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.
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.
struct Gecode::@593::NNF::@62::@64 a
For atomic nodes.
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.