62 value = (
r->min < lower) ? lower :
r->min;
113 View x,
int variable0)
130 unsigned long long product = 1ULL;
131 for (
int i=0; i<x.
size(); i++) {
134 const unsigned long long size =
135 static_cast<unsigned long long>(x[i].
size());
136 if ((product > limit) ||
137 ((size > 0ULL) && (product > limit / size)))
150 template<
class Derived,
class View>
161 const unsigned int*
tv;
165 return static_cast<Derived&
>(*this);
170 const unsigned long long index =
171 static_cast<unsigned long long>(tid) *
172 static_cast<unsigned long long>(
arity);
178 const unsigned int gid =
tuple_gids(tid)[variable];
193 const unsigned int last_tid =
active_ids[last];
202 const unsigned int* begin =
nullptr;
203 const unsigned int* end =
nullptr;
204 unsigned int gid = 0U;
207 for (
const unsigned int* tuple=begin; tuple<end; tuple++)
208 derived().deactivate_tuple(*tuple);
213 unsigned int position = 0U;
215 const unsigned int tid =
active_ids[position];
216 const unsigned int gid =
tuple_gid(tid,variable);
218 derived().deactivate_tuple(tid);
226 const Delta& delta) {
227 if (view.assigned() || view.any(delta)) {
232 unsigned int scanned = 0U;
235 if (scanned == scan_limit) {
240 const int value =
values.val();
241 if (!view.in(value)) {
251 unsigned int position = 0U;
253 const unsigned int tid =
active_ids[position];
256 for (
int variable=0; variable<
arity; variable++)
257 if (!x[variable].in(
gid_val[row[variable]])) {
264 derived().deactivate_tuple(tid);
270 n_tuples(static_cast<unsigned int>(ts0.tuples())),
277 assert(
tv !=
nullptr);
278 for (
unsigned int i=0U; i<
n_tuples; i++) {
282 for (
unsigned int i=0U; i<
n_vals; i++)
284 for (
int variable=0; variable<x.
size(); variable++)
287 unsigned int gid = 0U;
290 int value =
range->min;
294 if (value ==
range->max)
309 for (
unsigned int i=0U; i<
n_tuples; i++) {
313 for (
unsigned int i=0U; i<
n_vals; i++)
318 template<
class View,
bool pos>
358 for (
unsigned int i=0U; i<
n_vals; i++)
360 for (
int a=0; a<
x.size(); a++) {
362 unsigned int gid = 0U;
380 assert(
tv !=
nullptr);
382 if (offsets !=
nullptr) {
383 for (
unsigned int i=0U; i<
n_vals; i++)
386 for (
unsigned int i=0U; i<
n_vals; i++)
388 const unsigned long long n_tv =
389 static_cast<unsigned long long>(
n_tuples) *
390 static_cast<unsigned long long>(
arity);
391 for (
unsigned long long i=0ULL; i<n_tv; i++) {
392 const unsigned int gid =
tv[i];
405 for (
int a=0; a<
arity; a++) {
406 const unsigned int gid = row[a];
427 const int arity =
x.size();
428 unsigned int* n_rm = r.alloc<
unsigned int>(
arity);
429 unsigned int* p_rm = r.alloc<
unsigned int>(
arity);
430 int** rm = r.alloc<
int*>(
arity);
431 for (
int i=0; i<
arity; i++) {
442 if ((a < 0) || (a >=
arity))
448 for (
int i=0; i<
arity; i++)
450 rm[i] = r.alloc<
int>(n_rm[i]);
456 if ((a < 0) || (a >=
arity))
459 rm[a][p_rm[a]++] =
gid_val[gid];
464 for (
int i=0; i<
arity; i++) {
475 for (
unsigned int k=1U; k<p_rm[i]; k++)
476 if (rm[i][k] != rm[i][j-1U])
477 rm[i][j++] = rm[i][k];
508 for (
unsigned int i=0U; i<
n_vals; i++)
514 for (
int i=0; i<
arity; i++)
515 if (!
x[i].assigned())
531 for (
unsigned int i=0U; i<
n_vals; i++) {
542 bool assigned =
true;
543 for (
int i=0; i<
x.size(); i++)
544 if (!
x[i].assigned()) {
549 bool in_table =
false;
550 for (
int t=0; t<
ts.tuples() && !in_table; t++) {
553 for (
int i=0; i<
x.size(); i++)
554 if (tuple[i] !=
x[i].val()) {
568 if (
ts.tuples() == 0)
571 for (
int i=0; i<
x.size(); i++) {
576 if ((
x.size() <= 1) || (
ts.tuples() <= 1))
588 if (
ts.tuples() == 0)
617 return sizeof(*this);
640 const unsigned long long cap_all =
648 for (
int i=0; i<
x.size(); i++) {
651 const unsigned long long cap =
657 int* rm = r.alloc<
int>(
x[i].size());
658 unsigned int n_rm = 0U;
660 unsigned int gid = 0U;
668 static_cast<unsigned int>(other)))
709 const int i = sa.
index();
725 template<
class View,
class CtrlView, ReifyMode rm>
772 for (
int i=0; i<
arity; i++)
773 if (!
x[i].assigned())
826 return sizeof(*this);
850 const unsigned long long cap_all =
853 if (all == cap_all) {
871 const int i = sa.
index();
891 case EPK_DENSE_COMPRESSED:
913 template<
class View,
class CtrlView>
929 template<
class View,
class CtrlView>
942 template<
class View,
class CtrlView>
958 template<
class View,
class CtrlView>
967 case EPK_DENSE_COMPRESSED:
1007 using namespace Int;
1016 if (x.
size() == 0) {
1036 using namespace Int;
1046 const bool value = (x.
size() == 0) ?
1050 (home,control,r.mode(),value)));
1058 (home,views,t,control,r.mode())));
1062 (home,views,t,control,
1070 using namespace Int;
1075 if ((t.
min() < 0) || (t.
max() > 1))
1081 if (x.
size() == 0) {
1101 using namespace Int;
1106 if ((t.
min() < 0) || (t.
max() > 1))
1113 const bool value = (x.
size() == 0) ?
1117 (home,control,r.mode(),value)));
1125 (home,views,t,control,r.mode())));
1129 (home,views,t,control,
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.
int size(void) const
Return size of array (number of elements).
Passing Boolean variables.
Generic domain change information to be supplied to advisors.
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
void fail(void)
Mark space as failed.
Passing integer variables.
Exception: Arguments contain same variable multiply
Exception: Arguments are of different size
Boolean view for Boolean variables.
Advisor shared by the sparse positive, negative, and reified actors.
void dispose(Space &home, Council< SparseAdvisor > &c)
SparseAdvisor(Space &home, SparseAdvisor &advisor)
SparseAdvisor(Space &home, Propagator &p, Council< SparseAdvisor > &c, View x, int variable0)
Iterate table values in a delta interval.
void set_range(int lower)
const TupleSet::Range * r
const TupleSet::Range * e
bool operator()(void) const
SparseDeltaValues(const TupleSet &ts, int i, int lower, int upper0)
const unsigned int * tuple_gids(unsigned int tid) const
void enqueue_zero(unsigned int gid)
void deactivate_removed_values(int variable, const View &view, const Delta &delta)
void init_support_counts(void)
bool support_active(unsigned int gid) const
virtual void reschedule(Space &home)
Schedule function.
virtual PropCost cost(const Space &, const ModEventDelta &) const
Cost function.
ExecStatus process_zero_queue(Space &home)
SparseTupleState< SparseInc< View, pos >, View > State
Extensional::SparseAdvisor< View > SparseAdvisor
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts)
void deactivate_tuple(unsigned int tid)
virtual ExecStatus propagate(Space &home, const ModEventDelta &)
Propagation function.
virtual size_t dispose(Space &home)
Delete actor and return its size.
unsigned int * support_count
unsigned int active_limit
virtual ExecStatus advise(Space &home, Advisor &a0, const Delta &d)
Advise function.
bool atmostone(void) const
void deactivate_for_all_domains(const ViewArray< View > &x)
void deactivate_for_domain(int variable, const View &view)
bool remove_tuple(unsigned int tid)
unsigned int zero_queue_size
Council< SparseAdvisor > c
SparseInc(Space &home, SparseInc< View, pos > &p)
unsigned int * zero_queue
virtual Actor * copy(Space &home)
Create copy.
SparseInc(Home home, ViewArray< View > &x0, const TupleSet &ts0)
void deactivate_for_all_domains(const ViewArray< View > &x)
unsigned int active_limit
virtual Actor * copy(Space &home)
Create copy.
void deactivate_tuple(unsigned int tid)
virtual void reschedule(Space &home)
Schedule function.
virtual size_t dispose(Space &home)
Delete actor and return its size.
bool support_active(unsigned int) const
static ExecStatus post_neg(Home home, ViewArray< View > &x, const TupleSet &ts)
virtual ExecStatus advise(Space &home, Advisor &a0, const Delta &d)
Advise function.
Council< SparseAdvisor > c
bool remove_tuple(unsigned int tid)
virtual PropCost cost(const Space &, const ModEventDelta &) const
Cost function.
void deactivate_removed_values(int variable, const View &view, const Delta &delta)
SparseReifInc(Space &home, SparseReifInc< View, CtrlView, rm > &p)
void deactivate_for_domain(int variable, const View &view)
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
SparseTupleState< SparseReifInc< View, CtrlView, rm >, View > State
Extensional::SparseAdvisor< View > SparseAdvisor
virtual ExecStatus propagate(Space &home, const ModEventDelta &)
Propagation function.
static ExecStatus post_pos(Home home, ViewArray< View > &x, const TupleSet &ts)
SparseReifInc(Home home, ViewArray< View > &x0, const TupleSet &ts0, CtrlView b0)
unsigned int * active_ids
unsigned int tuple_gid(unsigned int tid, int variable) const
unsigned int active_limit
bool remove_tuple(unsigned int tid)
void deactivate_removed_values(int variable, const View &view, const Delta &delta)
SparseTupleState(Space &home, const SparseTupleState &state)
void deactivate_for_all_domains(const ViewArray< View > &x)
void deactivate_value_support(int variable, int value)
const unsigned int * tuple_gids(unsigned int tid) const
SparseTupleState(Home home, ViewArray< View > &x, const TupleSet &ts0)
void deactivate_for_domain(int variable, const View &view)
unsigned int * pos_in_active
Internal access to finalized tuple-set support representations.
static bool support_id(const TupleSet &ts, int p, int n, unsigned int &gid)
Return support id for position/value.
static bool sparse_support(const TupleSet &ts, int p, int n, const unsigned int *&b, const unsigned int *&e, unsigned int &gid)
Return sparse support tuple id range for position/value.
static const unsigned int * sparse_support_offsets(const TupleSet &ts)
Return sparse support offsets.
Exception: Tuple set not yet finalized
Exception: Not 0/1 integer
Exception: Unknown reification mode passed as argument
Value iterator for array of integers
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
bool disabled(void) const
Whether propagator is currently disabled.
Propagator(Home home)
Constructor for posting.
Reification specification.
Class representing a set of tuples.
int tuples(void) const
Number of tuples.
int max(void) const
Return maximal value in all tuples.
bool finalized(void) const
Is tuple set successfully finalized.
ExtensionalPropKind representation(void) const
Return materialized tuple-set representation.
int * Tuple
Type of a tuple.
int min(void) const
Return minimal value in all tuples.
int arity(void) const
Arity of tuple set.
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.
int size(void) const
Return size of array (number of elements).
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
#define GECODE_POST
Check for failure in a constraint post function.
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.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
@ AP_DISPOSE
Actor must always be disposed.
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
ReifyMode
Mode for reification.
IntPropLevel
Propagation levels for integer propagators.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default).
ExecStatus post_reified_tuple_set(Home home, ViewArray< View > &x, const TupleSet &t, CtrlView b, ReifyMode mode)
unsigned long long domain_product(const ViewArray< View > &x, unsigned long long limit, int excluded=-1)
Return the domain-size product, saturated just above limit.
ExecStatus postnegcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for compact table propagator.
ExecStatus post_reified_constant(Home home, BoolView b, ReifyMode mode, bool value)
ExecStatus postposcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table propagator.
ExecStatus postrecompact(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for compact table propagator.
ExecStatus postposcompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table with compressed supports.
ExecStatus post_compressed_reified(Home home, ViewArray< View > &x, const TupleSet &t, CtrlView b, ReifyMode mode)
ExecStatus post_dense_reified(Home home, ViewArray< View > &x, const TupleSet &t, CtrlView b, ReifyMode mode)
ExecStatus post_tuple_set(Home home, ViewArray< View > &x, const TupleSet &t, bool pos)
ReifyMode negated_reify_mode(ReifyMode mode)
ExecStatus postnegcompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for negative compact table with compressed supports.
ExecStatus postrecompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for reified compact table with compressed supports.
ExecStatus post_sparse_reified(Home home, ViewArray< View > &x, const TupleSet &t, CtrlView b, ReifyMode mode)
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value).
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Gecode toplevel namespace
void range(Home home, const IntVarArgs &x, SetVar y, SetVar z)
Post constraint .
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl=IPL_DEF)
Post constraint .
@ 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.
#define GECODE_NEVER
Assert that this command is never executed.
#define GECODE_ASSUME(p)
Assert certain property.