57 Actor* Actor::sentinel;
96 std::ostream&)
const {
108 #ifdef GECODE_HAS_VAR_DISPOSE 114 #ifdef GECODE_HAS_VAR_DISPOSE 121 b_status = b_commit = Brancher::cast(&bl);
123 d_fst = d_cur = d_lst = NULL;
125 pc.p.active = &pc.p.queue[0]-1;
128 pc.p.queue[
i].init();
129 pc.p.bid = reserved_bid+1;
136 if (duplicate && (d_fst != NULL)) {
137 for (
Actor** f = d_fst; f < d_cur; f++)
141 if (d_cur == d_lst) {
145 d_fst = alloc<Actor*>(4);
150 unsigned int n =
static_cast<unsigned int>(d_lst - d_fst);
152 d_fst = realloc<Actor*>(d_fst,
n,2*
n);
213 #ifdef GECODE_HAS_VAR_DISPOSE 216 if (_vars_d[
i] != NULL)
241 if (pc.p.active >= &pc.p.queue[0]) {
249 pc.p.ei.propagator(*p);
267 assert(pc.p.active >= &pc.p.queue[0]);
270 if (pc.p.active != fst) {
271 p = Propagator::cast(fst);
284 p->unlink(); pl.
head(p);
288 assert(pc.p.active >= &pc.p.queue[0]);
291 if (pc.p.active != fst) {
292 p = Propagator::cast(fst);
295 }
while (--pc.p.active >= &pc.p.queue[0]);
296 assert(pc.p.active < &pc.p.queue[0]);
300 goto stable_or_unstable;
303 assert(p->u.
med != 0);
335 while (b_status != Brancher::cast(&bl))
336 if (b_status->
status(*
this)) {
341 b_status = Brancher::cast(b_status->next());
346 stat.
wmp = (wmp() > 0U);
357 if (
failed() || (b_status == Brancher::cast(&bl))) {
361 while (b != Brancher::cast(&bl)) {
363 b = Brancher::cast(b->next());
367 b_status = b_commit = Brancher::cast(&bl);
375 while (b != b_status) {
377 b = Brancher::cast(b->next());
383 return b_status->
choice(*
this);
388 unsigned int id; e >> id;
390 while (b_cur != Brancher::cast(&bl)) {
391 if (
id == b_cur->
id())
392 return b_cur->
choice(*
this,e);
393 b_cur = Brancher::cast(b_cur->next());
399 Space::_commit(
const Choice&
c,
unsigned int a) {
406 pc.p.ei.brancher(*
b);
418 Space::_trycommit(
const Choice& c,
unsigned int a) {
425 pc.p.ei.brancher(*
b);
441 return b->ngl(*
this,c,a);
453 if (
Brancher*
b = const_cast<Space&>(*this).brancher(c.bid)) {
455 b->print(*
this,c,a,o);
463 Space::kill_brancher(
unsigned int id) {
467 b != Brancher::cast(&bl);
b = Brancher::cast(
b->next()))
487 : sm(s.sm->
copy(share)),
490 d_fst(&
Actor::sentinel),
491 _wmp_afc(s._wmp_afc) {
492 #ifdef GECODE_HAS_VAR_DISPOSE 497 pc.c.vars_u[
i] = NULL;
498 pc.c.vars_noidx = NULL;
506 Actor* c = Actor::cast(a)->copy(*
this,share);
520 Actor* c = Actor::cast(a)->copy(*
this,share);
530 if (s.b_status == &s.bl) {
531 b_status = Brancher::cast(&bl);
533 b_status = Brancher::cast(s.b_status->prev());
535 if (s.b_commit == &s.bl) {
536 b_commit = Brancher::cast(&bl);
538 b_commit = Brancher::cast(s.b_commit->prev());
543 Space::_clone(
bool share_data,
bool share_info) {
552 if (c->d_fst != &Actor::sentinel)
557 unsigned int n =
static_cast<unsigned int>(d_cur - d_fst);
560 c->d_fst = c->d_cur = c->d_lst = NULL;
565 c->d_lst = c->d_fst+n+1;
566 for (
Actor** d_fst_iter = d_fst; d_fst_iter != d_cur; d_fst_iter++) {
567 if ((*d_fst_iter)->prev())
568 *(c->d_cur++) = Actor::cast((*d_fst_iter)->prev());
578 x->b.base = NULL; x->u.idx[0] = 0;
579 if (
sizeof(
ActorLink**) >
sizeof(
unsigned int))
580 *(1+&x->u.idx[0]) = 0;
600 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
608 c_a->
prev(p_a); p_a = c_a; c_a = c_a->
next();
621 c->pc.
p.active = &c->pc.
p.queue[0]-1;
623 c->pc.
p.queue[
i].init();
625 c->pc.
p.n_sub = pc.p.n_sub;
626 c->pc.
p.bid = pc.p.bid;
636 p->gpi_disabled = gpi;
640 c->pc.
p.ei.other(); pc.p.ei.other();
653 if (mi.
last() != NULL)
674 LocalObject::fwdcopy(
Space& home,
bool share) {
676 next(home.pc.
c.local);
677 home.pc.
c.local =
this;
689 if (gpi.
decay() != 1.0)
691 (
void) gpi.
afc(
p.propagator().gpi());
699 gpi.
set(
p.propagator().gpi(),
a);
733 if (gid == GROUPID_MAX)
740 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
742 if (g.
in(ps.propagator().group()))
743 ps.propagator().group(*
this);
749 if (
id() == GROUPID_ALL)
752 if (ps.propagator().id() == pid) {
753 ps.propagator().group(*
this);
767 if (in(ps.propagator().group()))
790 if (in(ps.propagator().group()))
791 ps.propagator().disable();
810 if (in(ps.propagator().group()))
811 ps.propagator().enable();
818 if ((
id() != GROUPID_ALL) && (
id() != g.
id()))
820 if (g.
in(bs.brancher().group()))
821 bs.brancher().group(*
this);
827 if (
id() == GROUPID_ALL)
830 if (bs.brancher().id() ==
bid) {
831 bs.brancher().group(*
this);
845 if (in(bs.brancher().group()))
Double-linked list for actors.
unsigned int alternatives(void) const
Return number of alternatives.
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)
unsigned int bid
Id of next brancher to be created.
static BrancherGroup all
Group of all branchers.
bool in(Group a) const
Check whether actor group a is included in this group.
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.
void kill(Space &home)
Kill all branchers in a group.
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 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.
Exception: Commit with illegal alternative
bool wmp
Whether a weakly monotonic propagator might have been executed.
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 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.
Base-class for both propagators and branchers.
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.
void decay(double d)
Set decay factor to d.
struct Gecode::@554::NNF::@60::@62 a
For atomic nodes.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
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
double afc_decay(void) const
Return AFC decay factor.
struct Gecode::Space::@55::@56 p
Data only available during propagation or branching.
void release(SharedMemory *sm)
Release all allocated heap chunks.
Execution has resulted in failure.
Exception: unknown propagator
Info * allocate(unsigned int gid)
Allocate new actor info.
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.
bool stable(void) const
Return if space is stable (at fixpoint or failed)
virtual const Choice * choice(Space &home)=0
Return choice.
void set(Info &c, double a)
Set failure count to a.
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.
double afc(Info &c)
Return failure count.
unsigned int id(void) const
Return brancher id.
static PropagatorGroup def
Group of propagators not in any user-defined group.
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.
unsigned int gid
Group identifier.
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
void enable(Space &home, bool s=true)
Enable all propagators in a group.
void enable(void)
Enable propagator.
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.
static NoGoods eng
Empty no-goods.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Internal: propagator has computed partial fixpoint, do not use.
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
static Group all
Group of all actors.
Class for storing timed-decay value.
ActorProperty
Actor properties.
virtual ~VarImpDisposerBase(void)
Destructor (not used)
const Choice * choice(void)
Create new choice for current brancher.
struct Gecode::@554::NNF::@60::@61 b
For binary nodes (and, or, eqv)
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.