45 template<
class View,
bool pos>
51 assert((
_fst->min <= n) && (n <= _lst->
max));
54 assert((
_fst->min <= n) && (n <= _lst->
max));
58 assert((
_fst->min <= n) && (n <= _lst->
max));
61 assert((
_fst->min <= n) && (n <= _lst->
max));
77 template<
class View,
bool pos>
86 template<
class View,
bool pos>
91 template<
class View,
bool pos>
97 template<
class View,
bool pos>
103 template<
class View,
bool pos>
114 template<
class View,
bool pos>
117 assert((n > a.fst()->
max) && (n < a.lst()->
min));
119 const Range* f=a.fst()+1;
120 const Range* l=a.lst()-1;
122 assert(!pos || (f<=l));
125 const Range* m = f + ((l-f) >> 1);
128 }
else if (n > m->
max) {
136 assert((f->min <= n) && (n <= f->
max));
139 if ((f <= l) && (f->min <= n) && (n <= f->
max))
146 template<
class View,
bool pos>
150 const Range* fst=a.fst();
151 const Range* lst=a.lst();
155 }
else if (n >= lst->
min) {
161 if ((n < fst->
min) || (n > lst->
max))
165 }
else if (n >= lst->
min) {
173 assert((fnd->
min <= n) && (n <= fnd->
max));
177 template<
class View,
bool pos>
183 while (
xr() && (
n >
xr.max()))
188 assert(
n <=
xr.max());
189 n = std::max(
n,
xr.min());
191 while ((
sr <=
lst) && (
n >
sr->max))
196 assert(n <= sr->
max);
197 n = std::max(
n,
sr->min);
199 if ((
xr.min() <=
n) && (
n <=
xr.max())) {
207 template<
class View,
bool pos>
222 template<
class View,
bool pos>
237 template<
class View,
bool pos>
243 assert(n <= sr->
max);
245 }
else if (
n <=
max) {
252 assert((
xr.min() <=
n) && (
n <=
xr.max()));
253 assert((
sr->min <=
n) && (n <= sr->
max));
254 assert(
sr->min <=
xr.min());
257 if ((n <= sr->
max) && (
n <=
xr.max())) {
259 }
else if (
n <=
max) {
264 template<
class View,
bool pos>
269 template<
class View,
bool pos>
275 template<
class View,
bool pos>
285 template<
class View,
bool pos>
294 l = std::max(
l,
r->min);
297 template<
class View,
bool pos>
301 while ((
l <=
h) && (
l >
r->max)) {
302 r++;
l=
r->min;
s=
r->s;
305 template<
class View,
bool pos>
310 template<
class View,
bool pos>
313 assert((
l >=
r->min) && (l <= r->
max));
318 template<
class View,
bool pos>
324 template<
class View,
bool pos>
328 if (!as())
return true;
333 template<
class View,
bool pos>
340 template<
class View,
bool pos>
347 template<
class View,
bool pos>
348 template<
class Table>
356 for (
int i=0; i<
x.size(); i++) {
357 table.clear_mask(mask);
359 table.add_to_mask(vs.supports(),mask);
360 table.template intersect_with_mask<false>(mask);
366 for (
int i=0; i<
x.size(); i++)
367 if (!
x[i].assigned())
373 View::schedule(home,*
this,me);
376 template<
class View,
bool pos>
377 template<
class Table>
380 unsigned long long int s = 1U;
382 s *=
static_cast<unsigned long long int>(as.advisor().view().
size());
383 if (
s > table.bits())
386 return s == table.ones();
389 template<
class View,
bool pos>
400 template<
class View,
bool pos>
407 return sizeof(*this);
415 template<
class View,
class Table>
419 template<
class View,
class Table>
423 template<
class View,
class Table>
426 return static_cast<StatusType
>(
s & 3);
428 template<
class View,
class Table>
436 template<
class View,
class Table>
442 template<
class View,
class Table>
447 template<
class View,
class Table>
457 template<
class View,
class Table>
458 template<
class TableProp>
462 assert(!table.empty());
465 template<
class View,
class Table>
469 if (
table.words() <= 4U) {
470 switch (
table.width()) {
485 if (std::is_same<Table,BitSet<unsigned char>>::value) {
505 return new (home) PosCompact<View,BitSet<unsigned char>>(home,*
this);
507 return new (home) PosCompact<View,BitSet<unsigned short int>>(home,*
this);
509 return new (home) PosCompact<View,BitSet<unsigned int>>(home,*
this);
512 template<
class View,
class Table>
520 template<
class View,
class Table>
525 assert((
x.size() > 1) && (
ts.tuples() > 1));
529 template<
class View,
class Table>
533 return sizeof(*this);
536 template<
class View,
class Table>
545 template<
class View,
class Table>
565 if (touched.
single(a) ||
x.assigned())
577 int* nq =
r.alloc<
int>(
x.size());
578 unsigned int n_nq = 0;
580 int last_support = 0;
582 if (!
table.intersects(vs.supports()))
583 nq[n_nq++] = vs.val();
585 last_support = vs.val();
590 }
else if (n_nq ==
x.size() - 1U) {
608 assert(!
table.empty());
613 template<
class View,
class Table>
641 if (!
x.any(d) && (
x.min(d) ==
x.max(d))) {
644 }
else if (!
x.any(d) && (
x.width(d) <=
x.size())) {
647 table.nand_with_mask(ls.supports());
663 table.clear_mask(mask);
665 table.add_to_mask(vs.supports(),mask);
666 table.template intersect_with_mask<false>(mask);
690 for (
int i=0; i<
x.size(); i++) {
695 if ((
x.size() <= 1) || (ts.
tuples() <= 1))
699 switch (ts.
words()) {
733 template<
class View,
class Table>
734 template<
class TableProp>
738 assert(!
table.empty());
741 template<
class View,
class Table>
745 if (
table.words() <= 4U) {
746 switch (
table.width()) {
788 template<
class View,
class Table>
796 template<
class View,
class Table>
804 template<
class View,
class Table>
808 return sizeof(*this);
811 template<
class View,
class Table>
817 template<
class View,
class Table>
821 if (!
table.empty()) {
834 unsigned long long int x_size = 1U;
835 unsigned long long int x_max = 1U;
840 unsigned long long int n = as.advisor().view().size();
842 x_size *= x_max; x_max = n;
846 if (x_size >
table.bits())
849 if (x_size >
table.ones())
859 assert(!
table.empty());
864 x_size /=
static_cast<unsigned long long int>(
x.size());
866 if ((x_size <=
table.bits()) && (x_size <=
table.ones())) {
868 int* nq =
r.alloc<
int>(
x.size());
869 unsigned int n_nq = 0U;
872 if (x_size ==
table.ones(vs.supports()))
873 nq[n_nq++] = vs.val();
891 x_size *=
static_cast<unsigned long long int>(
x.size());
895 if (
table.ones() == x_size)
902 template<
class View,
class Table>
918 table.template intersect_with_mask<true>(s);
934 table.clear_mask(mask);
939 table.template intersect_with_mask<false>(mask);
960 for (
int i=0; i<
x.size(); i++) {
968 switch (ts.
words()) {
1002 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1003 template<
class TableProp>
1009 assert(!
table.empty());
1012 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1016 if (
table.words() <= 4U) {
1017 switch (
table.width()) {
1066 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1075 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1093 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1098 return sizeof(*this);
1101 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1107 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1124 if (
table.empty()) {
1138 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
1145 if (
table.empty() ||
b.assigned())
1155 table.template intersect_with_mask<true>(s);
1171 table.clear_mask(mask);
1176 table.template intersect_with_mask<false>(mask);
1190 template<
class View,
class CtrlView, ReifyMode rm>
1196 if (
x.size() != 0) {
1206 for (
int i=0; i<
x.size(); i++) {
1216 switch (ts.
words()) {
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Class to iterate over advisors of a council.
Generic domain change information to be supplied to advisors.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Advisor for updating current table.
const Range * lst(void) const
Return lasst range of support data structure.
const Range * _lst
Last range of support data structure.
const Range * fst(void) const
Return first range of support data structure.
void adjust(void)
Adjust supports.
void dispose(Space &home, Council< CTAdvisor > &c)
Dispose advisor.
CTAdvisor(Space &home, Propagator &p, Council< CTAdvisor > &c, const TupleSet &ts, View x0, int i)
Initialise from parameters.
const Range * _fst
First range of support data structure.
const BitSetData * s
The lost value's support.
bool operator()(void) const
Whether iterator is done.
const BitSetData * supports(void) const
Provide access to corresponding supports.
void operator++(void)
Move iterator to next value.
LostSupports(const Compact< View, pos > &p, CTAdvisor &a, int l, int h)
Initialize iterator for values between l and h.
const Range * r
Range information.
const unsigned int n_words
Number of words.
Iterator over valid supports.
bool operator()(void) const
Whether there are still supports left.
const BitSetData * supports(void) const
Return supports.
const Range * lst
The last range.
void operator++(void)
Move to next supports.
ViewRanges< View > xr
Range iterator.
ValidSupports(const Compact< View, pos > &p, CTAdvisor &a)
Initialize from initialized propagator.
const Range * sr
Support iterator.
void find(void)
Find a new value (only for negative case)
const BitSetData * s
The value's support.
const unsigned int n_words
Number of words.
int val(void) const
Return supported value.
Compact(Space &home, Compact &p)
Constructor for cloning p.
size_t dispose(Space &home)
Delete propagator and return its size.
TupleSet ts
The tuple set.
const BitSetData * supports(CTAdvisor &a, int n)
Return supports for value n.
bool full(const Table &table) const
Check whether the table covers the whole Cartedion product.
void setup(Space &home, Table &table, ViewArray< View > &x)
Setup the actual table.
const unsigned int n_words
Number of words in supports.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
bool all(void) const
Whether all variables are assigned.
const Range * range(CTAdvisor &a, int n)
Find range for n.
bool atmostone(void) const
Whether at most one variable is unassigned.
TupleSet::Range Range
Range type for supports.
Council< CTAdvisor > c
The advisor council.
Domain consistent negative extensional propagator.
Compact< View, false >::ValidSupports ValidSupports
Compact< View, false >::CTAdvisor CTAdvisor
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Table table
Current table.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
NegCompact(Space &home, TableProp &p)
Constructor for cloning p.
size_t dispose(Space &home)
Delete propagator and return its size.
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts)
Post propagator for views x and table t.
void none(void)
Set status to NONE.
ptrdiff_t s
A tagged pointer for storing the status.
bool single(CTAdvisor &a) const
Check whether status is single and equal to a.
Status(StatusType t)
Initialize with type t (either NONE or SEVERAL)
void touched(CTAdvisor &a)
Set status to SINGLE or MULTIPLE depending on a.
StatusType type(void) const
Return status type.
void propagating(void)
Set status to PROPAGATING.
Domain consistent positive extensional propagator.
size_t dispose(Space &home)
Delete propagator and return its size.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Compact< View, true >::ValidSupports ValidSupports
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Table table
Current table.
Compact< View, true >::CTAdvisor CTAdvisor
Status status
Propagator status.
StatusType
Type of status.
@ NONE
No view has been touched.
@ PROPAGATING
The propagator is currently running.
@ SINGLE
A single view has been touched.
@ MULTIPLE
Multiple view have been touched.
Compact< View, true >::LostSupports LostSupports
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts)
Post propagator for views x and table t.
virtual void reschedule(Space &home)
Schedule function.
PosCompact(Space &home, TableProp &p)
Constructor for cloning p.
Domain consistent reified extensional propagator.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Table table
Current table.
ViewArray< View > y
The views (for rewriting)
Compact< View, false >::CTAdvisor CTAdvisor
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ReCompact(Space &home, TableProp &p)
Constructor for cloning p.
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post propagator for views x and table t.
CtrlView b
Boolean control view.
Compact< View, false >::ValidSupports ValidSupports
virtual void reschedule(Space &home)
Schedule function.
size_t dispose(Space &home)
Delete propagator and return its size.
Range iterator for integer views.
Value iterator for array of integers
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
size_t size
The size of the propagator (used during subsumption)
bool disabled(void) const
Whether propagator is currently disabled.
Propagator(Home home)
Constructor for posting.
const BitSetData * supports(unsigned int n_words, int n) const
Return the supports for value n.
Class represeting a set of tuples.
int tuples(void) const
Number of tuples.
unsigned int words(void) const
Return number of required bit set words.
Gecode::Support::BitSetData BitSetData
Import bit set data type.
ViewAdvisor(Space &home, Propagator &p, Council< A > &c, View x0)
Constructor for creation.
void dispose(Space &home, Council< A > &c)
Delete advisor.
View view(void) const
Access view.
ExecStatus ES_FIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed
ExecStatus ES_NOFIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be run
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
@ AP_DISPOSE
Actor must always be disposed.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
ExecStatus postnegcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for compact table propagator.
ExecStatus postposcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table propagator.
Gecode::Support::BitSetData BitSetData
Import type.
ExecStatus postrecompact(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for compact table propagator.
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
bool disjoint(I &i, J &j)
Check whether range iterators i and j are disjoint.
IntType u_type(unsigned int n)
Return type required to represent n.
@ IT_CHAR
char integer type
@ IT_SHRT
short integer type
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
int ModEvent
Type for modification events.
#define GECODE_NEVER
Assert that this command is never executed.
#define GECODE_ASSUME(p)
Assert certain property.