106 static void*
operator new(
size_t s);
108 static void operator delete(
void*
p);
265 template<
class VarImp>
316 static const int idx_c = VIC::idx_c;
318 static const int idx_d = VIC::idx_d;
320 static const int free_bits = VIC::free_bits;
322 unsigned int entries;
324 unsigned int free_and_bits;
339 unsigned int idx[pc_max+1];
373 void resize(
Space& home);
389 #ifdef GECODE_HAS_VAR_DISPOSE
444 unsigned int degree(
void)
const;
451 double afc(
const Space& home)
const;
493 unsigned int bits(
void)
const;
496 unsigned int&
bits(
void);
506 static void*
operator new(size_t,
Space&);
509 static void operator delete(
void*,
Space&);
511 static void operator delete(
void*);
654 bool empty(
void)
const;
684 virtual Actor* copy(
Space& home,
bool share) = 0;
690 virtual size_t dispose(
Space& home);
692 static void*
operator new(
size_t s,
Space& home);
694 static void operator delete(
void*
p,
Space& home);
697 static void operator delete(
void*
p);
700 static void*
operator new(
size_t s);
708 static void operator delete(
void*
p);
731 operator Space&(void);
861 double afc(
const Space& home)
const;
887 bool empty(
void)
const;
932 bool disposed(
void)
const;
953 static void*
operator new(
size_t s,
Space& home);
955 static void operator delete(
void*
p,
Space& home);
959 static void operator delete(
void*
p);
962 static void*
operator new(
size_t s);
997 virtual NGL* copy(
Space& home,
bool share) = 0;
1000 virtual bool notice(
void)
const;
1002 virtual size_t dispose(
Space& home);
1005 bool leaf(
void)
const;
1008 NGL* next(
void)
const;
1018 static void*
operator new(
size_t s,
Space& home);
1021 static void operator delete(
void* s,
Space& home);
1023 static void operator delete(
void*
p);
1043 unsigned int id(
void)
const;
1049 unsigned int alternatives(
void)
const;
1053 virtual size_t size(
void)
const = 0;
1055 static void*
operator new(size_t);
1057 static void operator delete(
void*);
1090 unsigned int id(
void)
const;
1100 virtual bool status(
const Space& home)
const = 0;
1118 unsigned int a) = 0;
1145 std::ostream& o)
const;
1169 unsigned int id(
void)
const;
1243 unsigned long int n;
1251 unsigned long int ng(
void)
const;
1253 void ng(
unsigned long int n);
1268 const unsigned long int r;
1270 const unsigned long int s;
1272 const unsigned long int f;
1279 CRI(
unsigned long int r,
1280 unsigned long int s,
1281 unsigned long int f,
1285 unsigned long int restart(
void)
const;
1287 unsigned long int solution(
void)
const;
1289 unsigned long int fail(
void)
const;
1291 const Space* last(
void)
const;
1293 const NoGoods& nogoods(
void)
const;
1404 Brancher* brancher(
unsigned int id);
1407 void kill_brancher(
unsigned int id);
1409 static const unsigned reserved_branch_id = 0U;
1446 void enqueue(Propagator*
p);
1451 #ifdef GECODE_HAS_VAR_DISPOSE
1457 template<
class VIC> VarImpBase* vars_d(
void)
const;
1459 template<
class VIC>
void vars_d(VarImpBase*
x);
1461 void update(ActorLink** sub);
1483 unsigned int _wmp_afc;
1485 void afc_enable(
void);
1487 bool afc_enabled(
void)
const;
1489 void wmp(
unsigned int n);
1491 unsigned int wmp(
void)
const;
1553 void _commit(
const Choice&
c,
unsigned int a);
1586 void _trycommit(
const Choice&
c,
unsigned int a);
1616 virtual Space* copy(
bool share) = 0;
1643 virtual bool master(
const CRI& cri);
1663 virtual bool slave(
const CRI& cri);
1668 static void*
operator new(size_t);
1673 static void operator delete(
void*);
1693 SpaceStatus status(StatusStatistics& stat=unused_status);
1727 const Choice* choice(
void);
1739 const Choice* choice(Archive& e)
const;
1761 Space*
clone(
bool share=
true, CloneStatistics& stat=unused_clone)
const;
1797 void commit(
const Choice&
c,
unsigned int a,
1798 CommitStatistics& stat=unused_commit);
1831 void trycommit(
const Choice&
c,
unsigned int a,
1832 CommitStatistics& stat=unused_commit);
1852 NGL* ngl(
const Choice&
c,
unsigned int a);
1869 void print(
const Choice&
c,
unsigned int a, std::ostream& o)
const;
1917 ExecStatus ES_SUBSUMED_DISPOSED(Propagator&
p,
size_t s);
1977 ExecStatus ES_NOFIX_DISPOSE_FORCE(Council<A>&
c, A&
a);
1995 bool failed(
void)
const;
2000 bool stable(
void)
const;
2018 Home operator ()(Propagator&
p);
2034 T* alloc(
long unsigned int n);
2042 T* alloc(
long int n);
2050 T* alloc(
unsigned int n);
2069 void free(T*
b,
long unsigned int n);
2080 void free(T*
b,
long int n);
2091 void free(T*
b,
unsigned int n);
2102 void free(T*
b,
int n);
2115 T* realloc(T*
b,
long unsigned int n,
long unsigned int m);
2128 T* realloc(T*
b,
long int n,
long int m);
2141 T* realloc(T*
b,
unsigned int n,
unsigned int m);
2154 T* realloc(T*
b,
int n,
int m);
2163 T** realloc(T**
b,
long unsigned int n,
long unsigned int m);
2172 T** realloc(T**
b,
long int n,
long int m);
2181 T** realloc(T**
b,
unsigned int n,
unsigned int m);
2190 T** realloc(T**
b,
int n,
int m);
2192 void* ralloc(
size_t s);
2194 void rfree(
void*
p,
size_t s);
2196 void* rrealloc(
void*
b,
size_t n,
size_t m);
2198 template<
size_t>
void* fl_alloc(
void);
2204 template<
size_t>
void fl_dispose(FreeList* f, FreeList*
l);
2227 template<
class T,
typename A1>
2228 T& construct(A1
const& a1);
2234 template<
class T,
typename A1,
typename A2>
2235 T& construct(A1
const& a1, A2
const& a2);
2241 template<
class T,
typename A1,
typename A2,
typename A3>
2242 T& construct(A1
const& a1, A2
const& a2, A3
const& a3);
2248 template<
class T,
typename A1,
typename A2,
typename A3,
typename A4>
2249 T& construct(A1
const& a1, A2
const& a2, A3
const& a3, A4
const& a4);
2255 template<
class T,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
2256 T& construct(A1
const& a1, A2
const& a2, A3
const& a3, A4
const& a4, A5
const& a5);
2278 bool operator ()(
void)
const;
2280 void operator ++(
void);
2300 bool operator ()(
void)
const;
2302 void operator ++(
void);
2304 const Brancher& brancher(
void)
const;
2311 void afc_decay(
double d);
2313 double afc_decay(
void)
const;
2316 void afc_set(
double a);
2330 SharedHandle::Object::operator
new(
size_t s) {
2334 SharedHandle::Object::operator
delete(
void*
p) {
2339 Space::operator
new(
size_t s) {
2343 Space::operator
delete(
void*
p) {
2348 Choice::operator
delete(
void*
p) {
2352 Choice::operator
new(
size_t s) {
2360 return mm.
alloc(sm,s);
2364 return mm.
reuse(p,s);
2368 char*
b =
static_cast<char*
>(
_b);
2370 char*
p =
static_cast<char*
>(
ralloc(m));
2383 return mm.template fl_alloc<s>(sm);
2388 mm.template fl_dispose<s>(f,
l);
2398 T*
p =
static_cast<T*
>(
ralloc(
sizeof(T)*n));
2399 for (
long unsigned int i=n;
i--; )
2400 (
void)
new (p+
i) T();
2407 return alloc<T>(
static_cast<long unsigned int>(
n));
2412 return alloc<T>(
static_cast<long unsigned int>(
n));
2418 return alloc<T>(
static_cast<long unsigned int>(
n));
2424 for (
long unsigned int i=n;
i--; )
2426 rfree(b,n*
sizeof(T));
2432 free<T>(
b,
static_cast<long unsigned int>(
n));
2437 free<T>(
b,
static_cast<long unsigned int>(
n));
2443 free<T>(
b,
static_cast<long unsigned int>(
n));
2450 T*
p =
static_cast<T*
>(
ralloc(
sizeof(T)*m));
2451 for (
long unsigned int i=n;
i--; )
2452 (
void)
new (p+
i) T(b[
i]);
2453 for (
long unsigned int i=n; i<m; i++)
2454 (
void)
new (p+
i) T();
2465 assert((n >= 0) && (m >= 0));
2466 return realloc<T>(
b,
static_cast<long unsigned int>(
n),
2467 static_cast<long unsigned int>(m));
2472 return realloc<T>(
b,
static_cast<long unsigned int>(
n),
2473 static_cast<long unsigned int>(m));
2478 assert((n >= 0) && (m >= 0));
2479 return realloc<T>(
b,
static_cast<long unsigned int>(
n),
2480 static_cast<long unsigned int>(m));
2483 #define GECODE_KERNEL_REALLOC(T) \
2486 Space::realloc<T>(T* b, long unsigned int n, long unsigned int m) { \
2487 return static_cast<T*>(rrealloc(b,n*sizeof(T),m*sizeof(T))); \
2491 Space::realloc<T>(T* b, long int n, long int m) { \
2492 assert((n >= 0) && (m >= 0)); \
2493 return realloc<T>(b,static_cast<long unsigned int>(n), \
2494 static_cast<long unsigned int>(m)); \
2498 Space::realloc<T>(T* b, unsigned int n, unsigned int m) { \
2499 return realloc<T>(b,static_cast<long unsigned int>(n), \
2500 static_cast<long unsigned int>(m)); \
2504 Space::realloc<T>(T* b, int n, int m) { \
2505 assert((n >= 0) && (m >= 0)); \
2506 return realloc<T>(b,static_cast<long unsigned int>(n), \
2507 static_cast<long unsigned int>(m)); \
2522 #undef GECODE_KERNEL_REALLOC
2527 return static_cast<T**
>(
rrealloc(b,n*
sizeof(T),m*
sizeof(T*)));
2532 assert((n >= 0) && (m >= 0));
2533 return realloc<T*>(
b,
static_cast<long unsigned int>(
n),
2534 static_cast<long unsigned int>(m));
2539 return realloc<T*>(
b,
static_cast<long unsigned int>(
n),
2540 static_cast<long unsigned int>(m));
2545 assert((n >= 0) && (m >= 0));
2546 return realloc<T*>(
b,
static_cast<long unsigned int>(
n),
2547 static_cast<long unsigned int>(m));
2551 #ifdef GECODE_HAS_VAR_DISPOSE
2554 Space::vars_d(
void)
const {
2555 return _vars_d[VIC::idx_d];
2559 Space::vars_d(VarImpBase*
x) {
2560 _vars_d[VIC::idx_d] =
x;
2566 Actor::operator
delete(
void*) {}
2568 Actor::operator
delete(
void*,
Space&) {}
2570 Actor::operator
new(
size_t s,
Space& home) {
2571 return home.ralloc(s);
2583 return home.ralloc(s);
2588 Advisor::operator
delete(
void*) {}
2591 Advisor::operator
delete(
void*,
Space&) {}
2593 Advisor::operator
new(
size_t s,
Space& home) {
2594 return home.ralloc(s);
2598 NGL::operator
delete(
void*) {}
2602 NGL::operator
new(
size_t s,
Space& home) {
2603 return home.ralloc(s);
2612 : next(NULL), fwd(NULL), use_cnt(0) {}
2615 assert(use_cnt == 0);
2623 SharedHandle::subscribe(
void) {
2624 if (o != NULL) o->use_cnt++;
2627 SharedHandle::cancel(
void) {
2628 if ((o != NULL) && (--o->use_cnt == 0))
2635 cancel(); o=
n; subscribe();
2651 cancel(); o=sh.o; subscribe();
2661 }
else if (sh.o->fwd != NULL) {
2666 sh.o->next = home.pc.
c.shared;
2667 home.pc.
c.shared = sh.o;
2702 unsigned long int s0,
2703 unsigned long int f0,
2706 :
r(r0), s(s0), f(f0),
l(l0), ng(ng0) {}
2763 p->_next =
n; n->_prev =
p;
2768 _next =
this; _prev =
this;
2775 this->_next =
a; a->_prev =
this;
2776 a->_next =
n; n->_prev =
a;
2783 a->_next =
this; this->_prev =
a;
2784 p->_next =
a; a->_prev =
p;
2789 return _next ==
this;
2820 return static_cast<Actor*
>(&
t);
2824 Actor::cast(
const ActorLink* al) {
2828 return static_cast<const Actor*
>(&
t);
2832 Space::afc_enable(
void) {
2836 Space::afc_enabled(
void)
const {
2837 return (_wmp_afc & 1U) != 0U;
2840 Space::wmp(
unsigned int n) {
2841 _wmp_afc = (_wmp_afc & 1U) | (n << 1);
2844 Space::wmp(
void)
const {
2845 return _wmp_afc >> 1U;
2850 s.notice(a,p,duplicate);
2858 return const_cast<Space*
>(
this)->_clone(share);
2873 return gafc.
decay();
2878 return sizeof(*this);
2903 return Home(*
this,&p);
2923 Propagator::cast(
const ActorLink* al) {
2937 : gafc((home.propagator() != NULL) ?
2939 home.propagator()->gafc :
2941 static_cast<
Space&>(home).gafc.allocate()) {
2943 assert((u.med == 0) && (u.size == 0));
2944 static_cast<Space&
>(home).pl.head(
this);
2951 assert((u.med == 0) && (u.size == 0));
2963 return const_cast<Space&
>(home).gafc.afc(gafc);
2981 assert(p.u.
med != 0);
2988 assert(p.u.
med != 0);
3007 Brancher::cast(
const ActorLink* al) {
3011 return static_cast<const Brancher*
>(&
t);
3016 _id(static_cast<
Space&>(home).pc.
p.branch_id++) {
3017 if (static_cast<Space&>(home).pc.p.branch_id == 0U)
3020 if (static_cast<Space&>(home).b_status == &static_cast<Space&>(home).bl) {
3021 static_cast<Space&
>(home).b_status =
this;
3022 if (static_cast<Space&>(home).b_commit == &
static_cast<Space&
>(home).bl)
3023 static_cast<Space&
>(home).b_commit =
this;
3025 static_cast<Space&
>(home).bl.tail(
this);
3041 Space::brancher(
unsigned int id) {
3058 while (b_commit != Brancher::cast(&bl))
3059 if (
id != b_commit->
id())
3060 b_commit = Brancher::cast(b_commit->next());
3063 if (b_commit == Brancher::cast(&bl)) {
3065 b_commit = Brancher::cast(bl.
next());
3066 while (b_commit != b_old)
3067 if (
id != b_commit->
id())
3068 b_commit = Brancher::cast(b_commit->next());
3081 : _id(
Space::reserved_branch_id) {}
3095 return const_cast<Space&
>(home).brancher(_id) != NULL;
3099 home.kill_brancher(_id);
3137 fwdcopy(home,share);
3170 : _id(b.id()), _alt(a) {}
3178 Choice::id(
void)
const {
3225 return sizeof(*this);
3245 Advisor::disposed(
void)
const {
3246 return prev() == NULL;
3250 Advisor::cast(ActorLink* al) {
3251 return static_cast<Advisor*
>(al);
3255 Advisor::cast(
const ActorLink* al) {
3256 return static_cast<const Advisor*
>(al);
3261 assert(!disposed());
3268 assert(!disposed());
3272 if ((n != NULL) && n->disposed())
3316 while ((a != NULL) && static_cast<A*>(a)->disposed())
3328 while ((a != NULL) && static_cast<A*>(a)->disposed())
3333 if (c.advisors != NULL) {
3335 Propagator* p_f = &
static_cast<A*
>(c.advisors)->propagator();
3337 Propagator* p_t = Propagator::cast(p_f->prev());
3342 while (*a_f != NULL) {
3343 if (static_cast<A*>(*a_f)->disposed()) {
3344 *a_f = (*a_f)->next();
3347 A*
a =
new (home) A(home,share,*static_cast<A*>(*a_f));
3355 a_f = (*a_f)->next_ref();
3372 if (!static_cast<A*>(a)->disposed())
3373 static_cast<A*
>(
a)->dispose(home,*
this);
3388 while ((a != NULL) && static_cast<A*>(a)->disposed())
3403 }
while ((
a != NULL) && static_cast<A*>(
a)->disposed());
3409 return *
static_cast<A*
>(
a);
3423 if (c > pc.p.active)
3452 return ((pc.p.active < &pc.p.queue[0]) ||
3465 assert((pc >= 0) && (pc < pc_max+2));
3466 return (pc == 0) ?
b.base :
b.base+
u.idx[pc-1];
3471 VarImp<VIC>::actorNonZero(
PropCond pc) {
3472 assert((pc > 0) && (pc < pc_max+2));
3473 return b.base+
u.idx[pc-1];
3479 assert((pc > 0) && (pc < pc_max+2));
3486 assert((pc > 0) && (pc < pc_max+2));
3493 b.base = NULL; entries = 0;
3494 for (
PropCond pc=1; pc<pc_max+2; pc++)
3502 b.base = NULL; entries = 0;
3503 for (
PropCond pc=1; pc<pc_max+2; pc++)
3524 d += Propagator::cast(*a)->afc(home); a++;
3532 d += Advisor::cast(*a)->propagator().afc(home); a++;
3547 return free_and_bits;
3553 return free_and_bits;
3556 #ifdef GECODE_HAS_VAR_DISPOSE
3560 return static_cast<VarImp<VIC>*
>(home.vars_d<VIC>());
3565 VarImp<VIC>::vars_d(Space& home, VarImp<VIC>*
x) {
3566 home.vars_d<VIC>(
x);
3594 free_and_bits = x.free_and_bits & ((1 << free_bits) - 1);
3595 if (x.b.
base == NULL) {
3597 reg = &home.pc.
c.vars_noidx;
3600 reg = &home.pc.
c.vars_u[idx_c];
3604 entries = x.entries;
3605 for (
PropCond pc=1; pc<pc_max+2; pc++)
3606 idx(pc) = x.
idx(pc);
3617 return static_cast<ModEvent>((med & VIC::med_mask) >> VIC::med_fst);
3629 return VIC::me_combine(me1,me2);
3636 if (VIC::med_update(p.u.
med,me) || force)
3646 schedule(home,*Propagator::cast(*p),me);
3652 assert(pc <= pc_max);
3654 home.pc.
p.n_sub += 1;
3655 if ((free_and_bits >> free_bits) == 0)
3657 free_and_bits -= 1 << free_bits;
3660 b.base[entries] = *actorNonZero(pc_max+1);
3662 for (
PropCond j = pc_max; j > pc; j--) {
3663 *actorNonZero(j+1) = *actorNonZero(j);
3666 *actorNonZero(pc+1) = *actor(pc);
3671 ActorLink** f = actor(pc);
3672 while (f < (pc == pc_max+1 ?
b.base+entries : actorNonZero(pc+1)))
3684 VarImp<VIC>::enter(Space& home, Advisor*
a) {
3686 home.pc.p.n_sub += 1;
3687 if ((free_and_bits >> free_bits) == 0)
3689 free_and_bits -= 1 << free_bits;
3692 b.base[entries++] = *actorNonZero(pc_max+1);
3693 *actorNonZero(pc_max+1) =
a;
3698 VarImp<VIC>::resize(Space& home) {
3699 if (
b.base == NULL) {
3700 assert((free_and_bits >> free_bits) == 0);
3702 free_and_bits += 4 << free_bits;
3703 b.base = home.alloc<ActorLink*>(4);
3704 for (
int i=0;
i<pc_max+1;
i++)
3708 unsigned int n = degree();
3712 ActorLink** s =
static_cast<ActorLink**
>(home.mm.subscriptions());
3714 ((s <=
b.base) && (
b.base < s+home.pc.p.n_sub)) ?
3715 (n+4) : ((n+1)*3>>1);
3716 ActorLink** prop = home.alloc<ActorLink*>(m);
3717 free_and_bits += (m-
n) << free_bits;
3719 Heap::copy<ActorLink*>(prop,
b.base,
n);
3720 home.free<ActorLink*>(
b.base,
n);
3751 assert(pc <= pc_max);
3756 while (f < actorNonZero(pc+1))
3764 while (*f != a) f++;
3767 *f = *(actorNonZero(pc+1)-1);
3768 for (
PropCond j = pc+1; j< pc_max+1; j++) {
3769 *(actorNonZero(j)-1) = *(actorNonZero(j+1)-1);
3772 *(actorNonZero(pc_max+1)-1) =
b.base[entries-1];
3775 free_and_bits += 1 << free_bits;
3776 home.pc.
p.n_sub -= 1;
3781 VarImp<VIC>::remove(Space& home, Advisor* a) {
3783 ActorLink** f = actorNonZero(pc_max+1);
3785 while (f <
b.base+entries)
3793 while (*f != a) f++;
3796 *f =
b.base[--entries];
3797 free_and_bits += 1 << free_bits;
3798 home.pc.p.n_sub -= 1;
3818 unsigned int n_sub = degree();
3819 home.pc.
p.n_sub -= n_sub;
3820 unsigned int n = (free_and_bits >> VIC::free_bits) + n_sub;
3836 ActorLink** la = actorNonZero(pc_max+1);
3845 Advisor* a = Advisor::cast(*la);
3846 assert(!a->disposed());
3848 switch (p.advise(home,*a,d)) {
3852 if (home.afc_enabled())
3853 home.gafc.
fail(p.gafc);
3856 schedule(home,p,me);
3859 schedule(home,p,me,
true);
3864 }
while (++la < le);
3875 x->u.
idx[0] =
u.idx[0];
3876 if (pc_max > 0 &&
sizeof(
ActorLink**) >
sizeof(
unsigned int))
3877 x->u.
idx[1] =
u.idx[1];
3880 unsigned int n = x->
degree();
3887 t[0]=f[0]->
prev(); t[1]=f[1]->
prev();
3888 t[2]=f[2]->
prev(); t[3]=f[3]->
prev();
3893 t[0]=f[0]->
prev(); t[1]=f[1]->
prev();
3903 VarImp<VIC>::update(Space& home, ActorLink**& sub) {
3904 VarImp<VIC>* x =
static_cast<VarImp<VIC>*
>(home.pc.c.vars_u[idx_c]);
3906 VarImp<VIC>* n = x->
next(); x->forward()->update(x,sub); x =
n;
3916 template<
class VarImp>
3918 #ifdef GECODE_HAS_VAR_DISPOSE
3919 Space::vd[VarImp::idx_d] =
this;
3923 template<
class VarImp>
3928 x->dispose(home); x =
static_cast<VarImp*
>(x->next_d());
3929 }
while (x != NULL);
4010 return (m ==
LO) ? lo : hi;
4020 return crazy(m,static_cast<unsigned int>(n));
4029 return cubic(m,static_cast<unsigned int>(n));
4038 return quadratic(m,static_cast<unsigned int>(n));
4047 return linear(m,static_cast<unsigned int>(n));
4068 : home(home0), q(home.pc.p.active) {
4069 while (q >= &home.pc.p.queue[0]) {
4070 if (q->
next() != q) {
4071 c = q->
next(); e = q; q--;
4077 if (!home.pl.empty()) {
4078 c = Propagator::cast(home.pl.next());
4079 e = Propagator::cast(&home.pl);
4095 while (q >= &home.pc.p.queue[0]) {
4096 if (q->next() != q) {
4097 c = q->
next(); e = q; q--;
4103 if (!home.pl.empty()) {
4104 c = Propagator::cast(home.pl.next());
4105 e = Propagator::cast(&home.pl);
4114 return *Propagator::cast(c);
4119 : c(
Brancher::cast(home.bl.next())), e(&home.bl) {}
4130 return *Brancher::cast(c);
4142 template<
class T,
typename A1>
4145 T& t = *
static_cast<T*
>(
ralloc(
sizeof(T)));
4149 template<
class T,
typename A1,
typename A2>
4152 T& t = *
static_cast<T*
>(
ralloc(
sizeof(T)));
4156 template<
class T,
typename A1,
typename A2,
typename A3>
4159 T& t = *
static_cast<T*
>(
ralloc(
sizeof(T)));
4160 new (&
t) T(a1,a2,a3);
4163 template<
class T,
typename A1,
typename A2,
typename A3,
typename A4>
4166 T& t = *
static_cast<T*
>(
ralloc(
sizeof(T)));
4167 new (&
t) T(a1,a2,a3,a4);
4170 template<
class T,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
4173 T& t = *
static_cast<T*
>(
ralloc(
sizeof(T)));
4174 new (&
t) T(a1,a2,a3,a4,a5);
static const int med_lst
End of bits for modification event delta.
virtual Object * copy(void) const =0
Return fresh copy for update.
bool failed(void) const
Check whether corresponding space is failed.
Double-linked list for actors.
unsigned long int ng(void) const
Return number of no-goods posted.
void reset(void)
Reset information.
bool operator()(void) const
Test whether there are branchers left.
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
bool marked(void *p)
Check whether p is marked.
void init(void)
Initialize links (self-linked)
SharedHandle(void)
Create shared handle with no object pointing to.
Base-class for variable implementations.
Space must be branched (at least one brancher left)
ActorLink ** next_ref(void)
Routines for double-linked list.
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
ActorLink * prev(void) const
Routines for double-linked list.
Three variables, expensive.
Propagators(const Space &home)
Initialize.
unsigned int branch_id
Id of next brancher to be created.
void unlink(void)
Remove from predecessor and successor.
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
LocalObject(Home home)
Constructor for creation.
const Propagator & propagator(void) const
Return propagator.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
VarImp(void)
Creation of static instances.
ExecStatus ES_SUBSUMED(Propagator &p)
void update(Space &home, bool share, Council< A > &c)
Update during cloning (copies all advisors)
VarImpDisposer(void)
Constructor (registers disposer with kernel)
VarImp< VIC > * next
During cloning, points to the next copied variable.
unsigned long int fail(void) const
Return number of failures since last restart.
NGL * next(void) const
Return pointer to next literal.
void rfree(void *p)
Free memory block starting at p.
Actor must always be disposed.
double afc(const Space &home) const
Return accumulated failure count (plus degree)
Gecode::ActorLink * advisors
A list of advisors (used during cloning)
NGL(void)
Constructor for creation.
void cancel(Space &home, Propagator &p, IntSet &y)
static const int free_bits
Freely available bits.
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
double afc_decay(void) const
Return AFC decay factor.
ExecStatus ES_NOFIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has not computed partial fixpoint
Branchers(const Space &home)
Initialize.
T * realloc(T *b, long unsigned int n, long unsigned int m)
Reallocate block of n objects starting at b to m objects of type T from the space heap...
Quadratic complexity, expensive.
Statistics for execution of commit
const ModEvent ME_GEN_ASSIGNED
Generic modification event: variable is assigned a value.
Local (space-shared) object.
Status
The status of a no-good literal.
A & advisor(void) const
Return advisor.
int ModEvent
Type for modification events.
static void schedule(Space &home, Propagator &p, ModEvent me, bool force=false)
Schedule propagator p with modification event me.
static ModEvent modevent(const Delta &d)
Return modification event.
Base-class for propagators.
Internal: propagator is subsumed, do not use.
virtual ~Choice(void)
Destructor.
void * ralloc(size_t s)
Allocate s bytes from heap.
T & construct(void)
Construction routines.
Quadratic complexity, cheap.
static const int idx_d
Index for disposal.
bool wmp
Whether a weakly monotonic propagator might have been executed.
static ModEventDelta med(ModEvent me)
Translate modification event me into modification event delta.
LocalObject * object(void) const
Access to the local object.
ActorLink ** base
Subscribed actors.
ExecStatus ES_NOFIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be run
unsigned int idx[pc_max+1]
Indices of subscribed actors.
Class to iterate over advisors of a council.
unsigned int alternatives(void) const
Return number of alternatives.
void reuse(void *p, size_t s)
Store for reusal, if of sufficient size for free list.
void * mark(void *p)
Return marked pointer for p.
Base-class for variable implementations.
ActorLink * next(void) const
Routines for double-linked list.
LocalObject * local
Linked list of local objects.
unsigned long int propagate
Number of propagator executions.
Propagation has computed fixpoint.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const =0
Cost function.
const Space * l
Last solution found.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Current restart information during search.
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
LocalHandle & operator=(const LocalHandle &lh)
Assignment operator.
bool failed(void) const
Check whether space is failed.
void * rrealloc(void *b, size_t n, size_t m)
Reallocate memory block starting at b from size n to size s.
Linear complexity, expensive.
Base-class for both propagators and branchers.
Statistics for execution of status
void cancel(Space &home)
Cancel all subscriptions when variable implementation is assigned.
Heap heap
The single global heap.
void fail(Counter &c)
Increment failure count.
void * funmark(void *p)
Return unmarked pointer for a possibly marked pointer p.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
unsigned int id(void) const
Return brancher id.
CloneStatistics operator+(const CloneStatistics &s)
Return sum with s.
bool operator()(const Space &home) const
Check whether brancher is still active.
const unsigned long int r
Number of restarts.
void head(ActorLink *al)
Insert al directly after this.
Gecode::FloatVal c(-8, 8)
bool operator()(void) const
Test whether there are propagators left.
Exponential complexity, cheap.
Configuration class for variable implementations without index structure.
int p
Number of positive literals for node type.
Handles for local (space-shared) objects.
Class to iterate over branchers of a space.
double afc(const Space &home) const
Return the accumlated failure count.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
const Space * last(void) const
Return last solution found (possibly NULL)
Class for AFC (accumulated failure count) management.
bool copied(void) const
Is variable already copied.
Propagator * fwd(void) const
Return forwarding pointer during copying.
int n
Number of negative literals for node type.
CloneStatistics & operator+=(const CloneStatistics &s)
Increment by statistics s.
void reset(void)
Reset information.
unsigned long int solution(void) const
Return number of solutions since last restart.
void reset(void)
Reset information.
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
static LocalObject * cast(ActorLink *al)
Static cast for a non-null pointer (to give a hint to optimizer)
Execution has resulted in failure.
StatusStatistics(void)
Initialize.
Statistics for execution of clone
int PropCond
Type for propagation conditions.
void subscribe(Space &home, Propagator &p, IntSet &y)
virtual ~NoGoods(void)
Destructor.
SharedHandle & operator=(const SharedHandle &sh)
Assignment operator maintaining reference count.
const unsigned long int f
Number of failures since last restart.
ModEventDelta med
A set of modification events (used during propagation)
void commit(const Choice &c, unsigned int a, CommitStatistics &stat=unused_commit)
Commit choice c for alternative a.
unsigned int n_sub
Number of subscriptions.
void fail(void)
Fail space.
static const int idx_c
Index for update.
static Gecode::ModEvent me_combine(ModEvent me1, ModEvent me2)
Combine modification events me1 and me2.
static const int med_mask
Bitmask for modification event delta.
unsigned int size(I &i)
Size of all ranges of range iterator i.
ExecStatus ES_SUBSUMED_DISPOSED(Propagator &p, size_t s)
Propagator p is subsumed
CloneStatistics(void)
Initialize.
LocalHandle(void)
Create local handle pointing to NULL object.
const PropCond PC_GEN_ASSIGNED
Propagation condition for an assigned variable.
bool stable(void) const
Return if space is stable (at fixpoint or failed)
virtual void dispose(Space &home, VarImpBase *x)
Dispose list of variable implementations starting at x.
Propagator & propagator(void) const
Return the advisor's propagator.
size_t size
The size of the propagator (used during subsumption)
bool operator()(void) const
Test whether there advisors left.
struct Gecode::Space::@52::@53 p
Data only available during propagation.
Council(void)
Default constructor.
Only single variable, expensive.
LocalObject * fwd(Space &home, bool share)
Return forwarding pointer.
#define GECODE_KERNEL_EXPORT
ExecStatus ES_FIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed
void * alloc(SharedMemory *sm, size_t s)
Allocate memory of size s.
void * unmark(void *p)
Return unmarked pointer for a marked pointer p.
Home & operator=(const Home &h)
Assignment operator.
Class for storing timed-decay value.
ModEventDelta modeventdelta(void) const
Return the modification event delta.
unsigned long int restart(void) const
Return number of restarts.
Choice(const Brancher &b, const unsigned int a)
Initialize for particular brancher b and alternatives a.
Exception: too many branchers
ExecStatus ES_FIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has computed partial fixpoint
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
const unsigned long int s
Number of solutions since last restart.
bool empty(void) const
Test whether actor link is empty (points to itself)
struct Gecode::Space::@52::@54 c
Data available only during copying.
~SharedHandle(void)
Destructor that maintains reference count.
void update(Space &home, bool share, LocalHandle &lh)
Updating during cloning.
Advisor forces rescheduling of propagator.
void free(T *b, long unsigned int n)
Delete n objects allocated from space heap starting at b.
Class to iterate over propagators of a space.
Mod
Propagation cost modifier.
union Gecode::@518::NNF::@57 u
Union depending on nodetype t.
Globally shared object for propagator information.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
void update(Space &home, bool share, BrancherHandle &bh)
Update during cloning.
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
void * ralloc(size_t s)
Allocate memory on space heap.
Linear complexity, cheap.
bool empty(void) const
Test whether council has advisor left.
ActualCost ac
Actual cost.
Home operator()(Propagator &p)
Return a home extended by propagator to be rewritten.
static PropCost cubic(PropCost::Mod m, unsigned int n)
Cubic complexity for modifier m and size measure n.
CommitStatistics operator+(const CommitStatistics &s)
Return sum with s.
Node * x
Pointer to corresponding Boolean expression node.
const NoGoods & ng
No-goods from restart.
Generic domain change information to be supplied to advisors.
Brancher(Home home)
Constructor for creation.
static const int idx_c
Index for cloning.
Home operator()(Propagator &p)
Return a home for this space with the information that p is being rewritten.
virtual ~Object(void)
Delete shared object.
VarImp * next(void) const
Return next copied variable.
Choice for performing commit
Cubic complexity, expensive.
No-goods recorded from restarts.
SharedHandle::Object * object(void) const
Access to the shared object.
virtual size_t dispose(Space &home)
Delete actor and return its size.
void dispose(Space &home, Council< A > &c)
Dispose the advisor.
void operator++(void)
Move iterator to next advisor.
#define GECODE_KERNEL_REALLOC(T)
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
static ActorLink * cast(T *a)
Static cast for a non-null pointer (to give a hint to optimizer)
static ModEventDelta med_combine(ModEventDelta med1, ModEventDelta med2)
Combine modification event delta med1 with med2.
CommitStatistics & operator+=(const CommitStatistics &s)
Increment by statistics s.
bool assigned(View x, int v)
Whether x is assigned to value v.
void operator++(void)
Move iterator to next propagator.
CRI(unsigned long int r, unsigned long int s, unsigned long int f, const Space *l, NoGoods &ng)
Constructor.
const Brancher & brancher(void) const
Return propagator.
static PropCost crazy(PropCost::Mod m, unsigned int n)
Exponential complexity for modifier m and size measure n.
Two variables, expensive.
SharedHandle::Object * shared
Linked list of shared objects.
Space & s
The space where the propagator is to be posted.
static NoGoods eng
Empty no-goods.
static const PropCond pc_max
Maximal propagation condition.
void operator++(void)
Move iterator to next brancher.
Base-class for freelist-managed objects.
void trycommit(const Choice &c, unsigned int a, CommitStatistics &stat=unused_commit)
If possible, commit choice c for alternative a.
Advisors(const Council< A > &c)
Initialize.
Internal: propagator has computed partial fixpoint, do not use.
Variable implementation disposer
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
const ModEvent ME_GEN_NONE
Generic modification event: no modification.
void * fmark(void *p)
Return marked pointer for p (possibly already marked)
VarImp< VIC > * fwd
Forwarding pointer.
virtual size_t dispose(Space &home)
Dispose.
Propagation has not computed fixpoint.
Propagator * p
A propagator (possibly) that is currently being rewritten.
void fail(void)
Mark space as failed.
NGL * add(NGL *n, bool l)
Add node n and mark it as leaf l and return n.
unsigned int bits(void) const
Provide access to free bits.
Propagator * propagator(void) const
Return propagator (or NULL) for currently rewritten propagator.
StatusStatistics operator+(const StatusStatistics &s)
Return sum with s.
#define GECODE_NOT_NULL(p)
Assert that a pointer is never NULL.
static PropCost ternary(PropCost::Mod m)
Three variables for modifier pcm.
unsigned int id(void) const
Return unsigned brancher id.
const NoGoods & nogoods(void) const
Return no-goods recorded from restart.
Propagator(Home home)
Constructor for posting.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
static ModEvent me_combine(ModEvent me1, ModEvent me2)
Combine modifications events me1 and me2.
bool leaf(void) const
Test whether literal is a leaf.
BrancherHandle(void)
Create handle as unitialized.
ActorLink * active
Cost level with next propagator to be executed.
#define GECODE_VTABLE_EXPORT
VarImpBase * vars_noidx
Keep variables during copying without index structure.
ActualCost
The actual cost values that are used.
ActorProperty
Actor properties.
Only single variable, cheap.
unsigned long int n
Number of no-goods.
void * fl_alloc(void)
Allocate from freelist-managed memory.
int ModEventDelta
Modification event deltas.
static const int idx_d
Index for dispose.
Home class for posting propagators
void dispose(Space &home)
Dispose council.
static const int med_fst
Start of bits for modification event delta.
void kill(Space &home)
Kill the brancher.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Shared object for several memory areas.
#define GECODE_NEVER
Assert that this command is never executed.
static bool med_update(ModEventDelta &med, ModEvent me)
Update modification even delta med by me, return true on change.
StatusStatistics & operator+=(const StatusStatistics &s)
Increment by statistics s.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
bool advise(Space &home, ModEvent me, Delta &d)
Run advisors when variable implementation has been modified with modification event me and domain cha...
CommitStatistics(void)
Initialize.
VarImp * forward(void) const
Use forward pointer if variable already copied.
const ModEvent ME_GEN_FAILED
Generic modification event: failed variable.
Base class for Variable type disposer.
ExecStatus ES_NOFIX_DISPOSE_FORCE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be forcefully rescheduled
const bool clone
Whether engines create a clone when being initialized.
void rfree(void *p, size_t s)
Free memory previously allocated with alloc (might be reused later)
Home(Space &s, Propagator *p=NULL)
Initialize the home with space s and propagator p.
void tail(ActorLink *al)
Insert al directly before this.
void subscribe(Space &home, Propagator &p, PropCond pc, bool assigned, ModEvent me, bool schedule)
Subscribe propagator p with propagation condition pc.
void decay(double d)
Set decay factor to d.
Exponential complexity, expensive.
Space is solved (no brancher left)
No-good literal recorded during search.
~LocalHandle(void)
Destructor.