40#ifndef GECODE_SET_RELOP_COMM_ICC
41#define GECODE_SET_RELOP_COMM_ICC
45 template<
class View0,
class View1>
62 (
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
63 const Set::SetView&) {
84 template<
class View0,
class View1,
class View2>
86 shared(View0 v0, View1 v1, View2 v2) {
90 template<
class View0,
class View1,
class View2>
92 bool& retmodified, View0& x0, View1& x1, View2& x2) {
93 bool modified =
false;
95 retmodified |= modified;
105 if (x0.cardMin() + x1.cardMin() > s1) {
107 x2.cardMin(home, x0.cardMin()+x1.cardMin()-s1));
126 x0.cardMax()+x1.cardMax()-s1));
129 if (x2.cardMax() < x1.cardMin())
134 if (x2.cardMax() < x0.cardMin())
140 x0.cardMin(home,x2.cardMin()));
142 x1.cardMin(home,x2.cardMin()));
146 template<
class View0,
class View1,
class View2>
148 bool& retmodified, View0& x0, View1& x1, View2& x2) {
149 bool modified =
false;
151 retmodified |= modified;
159 unsigned int res = std::max(x0.cardMin()+
161 0 : x1.cardMin()-s1),
162 std::max(x0.cardMin(),
174 std::min(x0.cardMax()+x1.cardMax(),s1)));
177 if (x2.cardMin() > x1.cardMax())
179 x0.cardMin(home,x2.cardMin() - x1.cardMax()));
181 if (x2.cardMin() > x0.cardMax())
183 x1.cardMin(home,x2.cardMin() - x0.cardMax()));
186 x0.cardMax(home,x2.cardMax()));
188 x1.cardMax(home,x2.cardMax()));
193 template<
class View0,
class View1>
197 int xsize = x.
size();
200 unsigned int cardMaxSum=unionOfDets.
size();
201 bool maxValid =
true;
202 for (
int i=xsize; i--; ) {
203 cardMaxSum+=x[i].cardMax();
204 if (cardMaxSum < x[i].cardMax()) { maxValid =
false; }
219 unsigned int* rightSum = r.
alloc<
unsigned int>(xsize);
222 for (
int i=x.
size()-1;i--;) {
223 rightSum[i] = rightSum[i+1] + x[i+1].cardMax();
224 if (rightSum[i] < rightSum[i+1]) {
226 for (
int j=i; j>0;j--) {
234 unsigned int leftAcc=unionOfDets.
size();
236 for (
int i=0; i<xsize;i++) {
237 unsigned int jsum = leftAcc+rightSum[i];
239 if (jsum >= leftAcc && jsum < y.cardMin()) {
242 leftAcc += x[i].cardMax();
252 new (&rightUnion[xsize-1])
GLBndSet(home);
253 for (
int i=xsize-1;i--;) {
258 new (&rightUnion[i])
GLBndSet(home);
264 leftAcc.
update(home,unionOfDets);
265 for (
int i=0; i<xsize; i++) {
271 if (y.cardMin() > unionSize) {
273 x[i].cardMin(home, y.cardMin() - unionSize) );
279 for (
int i=xsize; i--;)
280 rightUnion[i].dispose(home);
294 template<
class View0,
class View1>
299 int xsize = x.
size();
300 for (
int i=xsize; i--; ) {
308 template<
class View0,
class View1>
313 unsigned int cardMinSum=unionOfDets.
size();
314 unsigned int cardMaxSum=unionOfDets.
size();
315 int xsize = x.
size();
316 for (
int i=xsize; i--; ) {
317 cardMinSum+=x[i].cardMin();
318 if (cardMinSum < x[i].cardMin()) {
324 for (
int i=xsize; i--; ) {
325 cardMaxSum+=x[i].cardMax();
326 if (cardMaxSum < x[i].cardMax()) {
342 unsigned int* rightMinSum = r.
alloc<
unsigned int>(xsize);
343 unsigned int* rightMaxSum = r.
alloc<
unsigned int>(xsize);
344 rightMinSum[xsize-1]=0;
345 rightMaxSum[xsize-1]=0;
347 for (
int i=x.
size()-1;i--;) {
348 rightMaxSum[i] = rightMaxSum[i+1] + x[i+1].cardMax();
349 if (rightMaxSum[i] < rightMaxSum[i+1]) {
351 for (
int j=i; j>0;j--) {
357 for (
int i=x.
size()-1;i--;) {
358 rightMinSum[i] = rightMinSum[i+1] + x[i+1].cardMin();
359 if (rightMinSum[i] < rightMinSum[i+1]) {
364 unsigned int leftMinAcc=unionOfDets.
size();
365 unsigned int leftMaxAcc=unionOfDets.
size();
367 for (
int i=0; i<xsize;i++) {
368 unsigned int maxSum = leftMaxAcc+rightMaxSum[i];
369 unsigned int minSum = leftMinAcc+rightMinSum[i];
371 if (maxSum >= leftMaxAcc && maxSum < y.cardMin()) {
376 if (minSum < leftMinAcc || y.cardMax() < minSum) {
383 leftMaxAcc += x[i].cardMax();
384 if (leftMaxAcc < x[i].cardMax())
386 leftMinAcc += x[i].cardMin();
387 if (leftMinAcc < x[i].cardMin())
397 template<
class View0,
class View1>
401 int xsize = x.
size();
411 for (
int i=xsize; i--;) {
414 afterUB[i].
update(home,sofarAfterUB);
415 afterLB[i].
update(home,sofarAfterLB);
428 for (
int i=0; i<xsize; i++) {
458 for (
int i=xsize;i--;) {
467 template<
class View0,
class View1>
472 int xsize = x.
size();
479 for (
int i=xsize; i--;) {
481 afterLB[i].
update(home,sofarAfterLB);
490 sofarBeforeLB.
update(home,unionOfDets);
491 for (
int i=0; i<xsize; i++) {
507 for (
int i=xsize; i--;)
508 afterLB[i].dispose(home);
513 template<
class View0,
class View1>
518 int xsize = x.
size();
525 for (
int i=xsize; i--;) {
527 afterUB[i].
update(home,sofarAfterUB);
537 sofarBeforeUB.
update(home,unionOfDets);
538 for (
int i=0; i<xsize; i++) {
554 for (
int i=xsize;i--;)
555 afterUB[i].dispose(home);
560 template<
class View0,
class View1>
566 int xsize = x.
size();
569 int nonEmptyCounter=0;
570 for (
int i = xsize; i--; ) {
573 xLBs[nonEmptyCounter] = r;
577 if (nonEmptyCounter !=0) {
587 template<
class View0,
class View1>
592 int xsize = x.
size();
595 int nonEmptyCounter=0;
596 for (
int i = xsize; i--; ) {
599 xUBs[nonEmptyCounter] = r;
603 if (nonEmptyCounter != 0) {
Range iterator for computing set difference.
Range iterator for computing intersection (binary).
Range iterator for union of iterators.
Range iterator for computing union (binary).
void * ralloc(size_t s)
Allocate memory from region.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Range iterator for integer sets.
bool isConsistent(void) const
Check whether internal invariants hold.
unsigned int size(void) const
Return size.
void update(Space &home, BndSet &x)
Update this set to be a clone of set x.
void dispose(Space &home)
Free memory used by this set.
Growing sets of integers.
bool includeI(Space &home, I &i)
Include the set represented by i in this set.
Range iterator for the greatest lower bound.
Range iterator for the least upper bound.
Set view for set variables
int size(void) const
Return size of array (number of elements).
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_ME_CHECK_MODIFIED(modified, me)
Check whether me is failed or modified, and forward failure.
unsigned int size(I &i)
Size of all ranges of range iterator i.
const unsigned int card
Maximum cardinality of an integer set.
Standard set operation propagators.
ExecStatus interCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
ExecStatus partitionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
bool shared(View0 v0, View1 v1, View2 v2)
ExecStatus partitionNYLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
ExecStatus unionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
ExecStatus partitionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
ExecStatus partitionNXi(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y)
ExecStatus unionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &)
ExecStatus unionCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
ExecStatus partitionNXiLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
ExecStatus partitionNYUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
const Gecode::ModEvent ME_SET_FAILED
Domain operation has resulted in failure.
Gecode toplevel namespace
bool viewarrayshared(const ViewArray< View0 > &va, const View1 &y)
bool viewarrayshared< Set::SingletonView, Set::SetView >(const ViewArray< Set::SingletonView > &, const Set::SetView &)
@ ES_FIX
Propagation has computed fixpoint.
@ ES_NOFIX
Propagation has not computed fixpoint.
bool shared(ViewArray< ViewX > x, ViewArray< ViewY > y)