103 for (
int i=0; i<k.
size(); i++) {
104 removed += k[i].counter();
105 sum_min += k[i].min();
111 for (
int i=0; i<k.
size(); i++)
117 for (
int i=0; i<
x.size(); i++)
118 if (
x[i].assigned()) {
129 for (
int i=0; i<k.
size(); i++)
143 for (
int i = k.
size(); i--; ) {
144 int ci =
count[i] + k[i].counter();
160 if ((req == non) && (n_r == 1)) {
162 for (
int i =
x.size(); i--; ) {
164 if (!
x[i].assigned()) {
166 assert((single >= 0) && (single < k.
size()));
170 assert((single >= 0) && (single < k.
size()));
172 for (
int i = k.
size(); i--; )
180 for (
int i = k.
size(); i--; ) {
181 int ci =
count[i] + k[i].counter();
182 if (ci == k[i].
max()) {
184 rem.
set(
static_cast<unsigned int>(i));
189 if (ci > k[i].
max()) {
194 if (Card::propagate) {
196 int occupied = t_noa - ci;
207 for (
int i = n_x; i--; ) {
208 if (
x[i].assigned()) {
213 if (rem.
get(
static_cast<unsigned int>(idx)))
223 int* pr =
r.alloc<
int>(k.
size());
227 pr[n_pr++] = k[i.val()].card();
229 for (
int i =
x.size(); i--;) {
236 bool all_assigned =
true;
238 for (
int i =
x.size(); i--; ) {
239 if (
x[i].assigned()) {
246 all_assigned =
false;
251 for (
int i = k.
size(); i--; )
257 if (Card::propagate) {
261 for (
int i = k.
size(); i--; ) {
262 if (k[i].counter() > k[i].
max()) {
265 allmax += k[i].max() - k[i].counter();
266 if (k[i].counter() < k[i].
min())
267 reqmin += k[i].min() - k[i].counter();
271 if ((
x.size() < reqmin) || (allmax <
x.size())) {
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Home class for posting propagators
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
virtual void reschedule(Space &home)
Schedule function.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost funtion returning high linear.
static ExecStatus post(Home home, ViewArray< IntView > &x, ViewArray< Card > &k)
Post propagator for views x and cardinalities k.
ViewArray< Card > k
Array containing either fixed cardinalities or CardViews.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ViewArray< IntView > x
Views on which to perform value-propagation.
virtual size_t dispose(Space &home)
Destructor.
Val(Home home, ViewArray< IntView > &x, ViewArray< Card > &k)
Constructor for posting.
Value iterator for array of integers
Value iterator for values in a bitset.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Base-class for propagators.
Propagator(Home home)
Constructor for posting.
bool get(unsigned int i) const
Access value at bit i.
void set(unsigned int i)
Set bit i.
int size(void) const
Return size of array (number of elements)
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Global cardinality propagators (Counting)
bool isDistinct(ViewArray< IntView > &x, ViewArray< Card > &k)
Check if GCC is equivalent to distinct.
ExecStatus prop_val(Space &home, Propagator &p, ViewArray< IntView > &x, ViewArray< Card > &k)
bool lookupValue(T &a, int v, int &i)
Return index of v in array a.
ExecStatus postSideConstraints(Home home, ViewArray< IntView > &x, ViewArray< Card > &k)
Post side constraints for the GCC.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Post propagator for SetVar SetOpType SetVar SetRelType r
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
@ ES_OK
Execution is okay.
@ 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