57 Actor* Actor::sentinel;
98 std::ostream&)
const {
110 #ifdef GECODE_HAS_VAR_DISPOSE 115 #ifdef GECODE_HAS_VAR_DISPOSE 122 b_status = b_commit = Brancher::cast(&bl);
124 d_fst = d_cur = d_lst = NULL;
126 pc.p.active = &pc.p.queue[0]-1;
129 pc.p.queue[
i].init();
130 pc.p.bid_sc = (reserved_bid+1) << sc_bits;
135 Space::ap_notice_dispose(
Actor*
a,
bool duplicate) {
137 if (duplicate && (d_fst != NULL)) {
138 for (
Actor**
f = d_fst;
f < d_cur;
f++)
142 if (d_cur == d_lst) {
146 d_fst = alloc<Actor*>(4);
151 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
153 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
162 Space::ap_ignore_dispose(
Actor* a,
bool duplicate) {
164 assert(d_fst != NULL);
203 #ifdef GECODE_HAS_VAR_DISPOSE 206 if (_vars_d[
i] != NULL)
231 if (pc.p.active >= &pc.p.queue[0]) {
233 if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == 0) {
252 assert(pc.p.active >= &pc.p.queue[0]);
255 if (pc.p.active != fst) {
256 p = Propagator::cast(fst);
268 p->unlink(); pl.
head(p);
269 f_stable_or_unstable:
272 assert(pc.p.active >= &pc.p.queue[0]);
275 if (pc.p.active != fst) {
276 p = Propagator::cast(fst);
279 }
while (--pc.p.active >= &pc.p.queue[0]);
280 assert(pc.p.active < &pc.p.queue[0]);
284 goto f_stable_or_unstable;
287 assert(p->u.
med != 0);
294 }
else if ((pc.p.bid_sc & ((1 << sc_bits) - 1)) == sc_disabled) {
300 goto d_put_into_idle;
314 assert(pc.p.active >= &pc.p.queue[0]);
317 if (pc.p.active != fst) {
318 p = Propagator::cast(fst);
331 p->unlink(); pl.
head(p);
332 d_stable_or_unstable:
335 assert(pc.p.active >= &pc.p.queue[0]);
338 if (pc.p.active != fst) {
339 p = Propagator::cast(fst);
342 }
while (--pc.p.active >= &pc.p.queue[0]);
343 assert(pc.p.active < &pc.p.queue[0]);
347 goto d_stable_or_unstable;
350 assert(p->u.
med != 0);
362 #define GECODE_STATUS_TRACE(q,s) \ 363 if ((tr != NULL) && (tr->events() & TE_PROPAGATE) && \ 364 (tr->filter()(p->group()))) { \ 365 PropagateTraceInfo pti(p->id(),p->group(),q, \ 366 PropagateTraceInfo::s); \ 367 tr->tracer()._propagate(*this,pti); \ 374 goto t_put_into_idle;
375 pc.p.vti.propagator(*p);
391 assert(pc.p.active >= &pc.p.queue[0]);
394 if (pc.p.active != fst) {
395 p = Propagator::cast(fst);
409 p->unlink(); pl.
head(p);
410 t_stable_or_unstable:
413 assert(pc.p.active >= &pc.p.queue[0]);
416 if (pc.p.active != fst) {
417 p = Propagator::cast(fst);
420 }
while (--pc.p.active >= &pc.p.queue[0]);
421 assert(pc.p.active < &pc.p.queue[0]);
426 goto t_stable_or_unstable;
430 assert(p->u.
med != 0);
438 #undef GECODE_STATUS_TRACE 465 while (b_status != Brancher::cast(&bl))
466 if (b_status->
status(*
this)) {
471 b_status = Brancher::cast(b_status->next());
490 switch (top->
propagate(*
this,top_med_o)) {
506 if (
failed() || (b_status == Brancher::cast(&bl))) {
510 while (b != Brancher::cast(&bl)) {
512 b = Brancher::cast(b->next());
516 b_status = b_commit = Brancher::cast(&bl);
524 while (b != b_status) {
526 b = Brancher::cast(b->next());
532 return b_status->
choice(*
this);
537 unsigned int id; e >> id;
539 while (b_cur != Brancher::cast(&bl)) {
540 if (
id == b_cur->
id())
541 return b_cur->
choice(*
this,e);
542 b_cur = Brancher::cast(b_cur->next());
548 Space::_commit(
const Choice&
c,
unsigned int a) {
555 if (pc.p.bid_sc & sc_trace) {
560 tr->
tracer()._commit(*
this,cti);
562 pc.p.vti.brancher(*
b);
578 Space::_trycommit(
const Choice& c,
unsigned int a) {
585 if (pc.p.bid_sc & sc_trace) {
590 tr->
tracer()._commit(*
this,cti);
592 pc.p.vti.brancher(*
b);
612 return b->ngl(*
this,c,a);
624 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c.bid)) {
626 b->print(*
this,c,a,o);
634 Space::kill_brancher(
unsigned int id) {
638 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
658 : sm(s.sm->
copy(share)),
661 d_fst(&
Actor::sentinel) {
662 #ifdef GECODE_HAS_VAR_DISPOSE 667 pc.c.vars_u[
i] = NULL;
668 pc.c.vars_noidx = NULL;
676 Actor* c = Actor::cast(a)->copy(*
this,share);
690 Actor* c = Actor::cast(a)->copy(*
this,share);
700 if (s.b_status == &s.bl) {
701 b_status = Brancher::cast(&bl);
703 b_status = Brancher::cast(s.b_status->prev());
705 if (s.b_commit == &s.bl) {
706 b_commit = Brancher::cast(&bl);
708 b_commit = Brancher::cast(s.b_commit->prev());
713 Space::_clone(
bool share_data,
bool share_info) {
722 if (c->d_fst != &Actor::sentinel)
727 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
730 c->d_fst = c->d_cur = c->d_lst = NULL;
735 c->d_lst = c->d_fst+n+1;
736 for (
Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
740 *(c->d_cur++) = Actor::cast(static_cast<ActorLink*>
751 x->b.base = NULL; x->u.idx[0] = 0;
752 if (
sizeof(
ActorLink**) >
sizeof(
unsigned int))
753 *(1+&x->u.idx[0]) = 0;
773 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
781 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
794 c->pc.
p.active = &c->pc.
p.queue[0]-1;
796 c->pc.
p.queue[
i].init();
798 c->pc.
p.n_sub = pc.p.n_sub;
799 c->pc.
p.bid_sc = pc.p.bid_sc;
809 p->gpi_disabled = gpi;
813 c->pc.
p.vti.other(); pc.p.vti.other();
826 if (mi.
last() != NULL)
847 LocalObject::fwdcopy(
Space& home,
bool share) {
849 next(home.pc.
c.local);
850 home.pc.
c.local =
this;
888 if (gid == GROUPID_MAX)
895 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
897 if (g.
in(ps.propagator().group()))
898 ps.propagator().group(*
this);
904 if (
id() == GROUPID_ALL)
907 if (ps.propagator().id() == pid) {
908 ps.propagator().group(*
this);
922 if (in(ps.propagator().group()))
945 if (in(ps.propagator().group()))
946 ps.propagator().disable(home);
965 if (in(ps.propagator().group()))
966 ps.propagator().enable(home);
973 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
975 if (g.
in(bs.brancher().group()))
976 bs.brancher().group(*
this);
982 if (
id() == GROUPID_ALL)
985 if (bs.brancher().id() == bid) {
986 bs.brancher().group(*
this);
1000 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.
virtual Space * copy(bool share)=0
Copying member function.
Space must be branched (at least one brancher left)
static BrancherGroup all
Group of all branchers.
bool in(Group a) const
Check whether actor group a is included in this group.
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 * subscriptions(void) const
Get the memory area for subscriptions.
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.
Exception: unknown brancher
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.
struct Gecode::Space::@56::@57 p
Data only available during propagation or branching.
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.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
void print(const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
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
void release(SharedMemory *sm)
Release all allocated heap chunks.
Execution has resulted in failure.
Commit trace information.
Exception: unknown propagator
Info * allocate(unsigned int gid)
Allocate new actor info.
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::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
bool stable(void) const
Return if space is stable (at fixpoint or failed)
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.
void flush(void)
Flush cached memory blocks.
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.
IntPropLevel sm(IntPropLevel ipl)
Extract speed or memory from propagation level.
unsigned int id(void) const
Return brancher id.
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
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
unsigned int gid
Group identifier.
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)
void fail(Info &c)
Increment failure count.
virtual bool master(const MetaInfo &mi)
Master configuration function for meta search engines.
virtual ~NGL(void)
To avoid warnings.
struct Gecode::Space::@56::@58 c
Data available only during copying.
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.
Gecode toplevel namespace
static Group all
Group of all actors.
Class for storing timed-decay value.
int events(void) const
Which events to trace.
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.
Base class for Variable type disposer.
GPI::Info & gpi(void)
Provide access to global propagator information.
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.