119 int*
count =
r.alloc<
int>(
k.size());
120 for (
int i =
k.size(); i--; )
125 for (
int i =
y.size(); i--; )
126 if (
y[i].assigned()) {
132 if (Card::propagate && (
k[idx].
max() == 0))
136 if (noa ==
y.size()) {
138 for (
int i =
k.size(); i--; ) {
149 if (Card::propagate) {
151 for (
int i =
k.size(); i--; )
152 if (!
k[i].assigned()) {
163 for (
int j =
k.size(); j--; )
164 if ((
k[j].
min() >
k[j].counter()) || (
k[j].
max() <
k[j].counter()))
167 }
else if ((
x.size() == 1) && (
x[0].assigned())) {
172 for (
int j =
k.size(); j--; )
173 if ((
k[j].
min() >
k[j].counter()) || (
k[j].
max() <
k[j].counter()))
181 for (
int i=
k.size(); i--; )
182 if (
k[i].counter() >
k[i].
max() ) {
185 smax += (
k[i].max() -
k[i].counter());
186 if (
k[i].counter() <
k[i].
min())
187 smin += (
k[i].min() -
k[i].counter());
190 if ((
x.size() < smin) || (smax <
x.size()))
202 vvg->template free_alternating_paths<UBC>();
203 vvg->template strongly_connected_components<UBC>();
211 vvg->template free_alternating_paths<LBC>();
212 vvg->template strongly_connected_components<LBC>();
218 bool card_assigned =
true;
219 if (Card::propagate) {
221 card_assigned =
k.assigned();
226 for (
int j=
k.size(); j--; )
227 if ((
k[j].
min() >
k[j].counter()) ||
228 (
k[j].
max() <
k[j].counter()))
231 }
else if ((
x.size() == 1) &&
x[0].assigned()) {
237 for (
int j =
k.size(); j--; )
238 if ((
k[j].
min() >
k[j].counter()) ||
239 (
k[j].
max() <
k[j].counter()))
246 for (
int i =
k.size(); i--; )
249 bool all_assigned =
true;
251 for (
int i =
y.size(); i--; )
252 if (
y[i].assigned()) {
257 if (Card::propagate && (
k[idx].
max() == 0))
260 all_assigned =
false;
267 for (
int i =
k.size(); i--; ) {
277 if (Card::propagate) {
278 int ysmax =
y.size();
279 for (
int i=
k.size(); i--; )
282 bool card_ass =
true;
283 for (
int i =
k.size(); i--; ) {
287 if (!
k[i].assigned())
290 if (card_ass && (smax !=
y.size()))
307 for (
int i =
k.size(); i--; )
308 if (!
k[i].assigned()) {
309 cardfix =
false;
break;
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 views x.
bool card_fixed
Stores whether cardinalities are all assigned.
virtual size_t dispose(Space &home)
Destructor.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
VarValGraph< Card > * vvg
Propagation is performed on a variable-value graph (used as cache)
virtual Actor * copy(Space &home)
Copy propagator during cloning.
ViewArray< IntView > y
Views used to channel information between x and k ( ).
ViewArray< IntView > x
Views on which to perform domain-propagation.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Dom(Space &home, Dom< Card > &p)
Constructor for cloning p.
ViewArray< Card > k
Array containing either fixed cardinalities or CardViews.
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< IntView > &x, ViewArray< Card > &k)
Post propagator for views x and cardinalities k.
Variable-value-graph used during propagation.
static PropCost cubic(PropCost::Mod m, unsigned int n)
Cubic complexity for modifier m and size measure n.
Propagator(Home home)
Constructor for posting.
bool card_consistent(ViewArray< IntView > &x, ViewArray< Card > &k)
Consistency check, whether the cardinality values are feasible.
ExecStatus prop_card(Space &home, ViewArray< IntView > &x, ViewArray< Card > &k)
Bounds consistency check for cardinality variables.
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.
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_DOM
Propagate when domain changes.
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_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 .