44 #ifndef __GECODE_SET_RELOP_COMM_ICC__ 45 #define __GECODE_SET_RELOP_COMM_ICC__ 49 template<
class View0,
class View1>
57 viewarrayshared<Set::SingletonView,Set::SetView>
64 viewarrayshared<Set::ComplementView<Set::SingletonView>,
Set::SetView>
72 viewarrayshared<Set::ComplementView<Set::SingletonView>,
74 (
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
80 namespace Set {
namespace RelOp {
86 template<
class View0,
class View1,
class View2>
92 template<
class View0,
class View1,
class View2>
94 bool& retmodified, View0& x0, View1& x1, View2& x2) {
95 bool modified =
false;
97 retmodified |= modified;
107 if (x0.cardMin() + x1.cardMin() > s1) {
109 x2.cardMin(home, x0.cardMin()+x1.cardMin()-s1));
128 x0.cardMax()+x1.cardMax()-s1));
131 if (x2.cardMax() < x1.cardMin())
136 if (x2.cardMax() < x0.cardMin())
142 x0.cardMin(home,x2.cardMin()));
144 x1.cardMin(home,x2.cardMin()));
148 template<
class View0,
class View1,
class View2>
150 bool& retmodified, View0& x0, View1& x1, View2& x2) {
151 bool modified =
false;
153 retmodified |= modified;
161 unsigned int res =
std::max(x0.cardMin()+
163 0 : x1.cardMin()-s1),
176 std::min(x0.cardMax()+x1.cardMax(),s1)));
179 if (x2.cardMin() > x1.cardMax())
181 x0.cardMin(home,x2.cardMin() - x1.cardMax()));
183 if (x2.cardMin() > x0.cardMax())
185 x1.cardMin(home,x2.cardMin() - x0.cardMax()));
188 x0.cardMax(home,x2.cardMax()));
190 x1.cardMax(home,x2.cardMax()));
195 template<
class View0,
class View1>
199 int xsize = x.
size();
202 unsigned int cardMaxSum=unionOfDets.
size();
203 bool maxValid =
true;
204 for (
int i=xsize;
i--; ) {
205 cardMaxSum+=x[
i].cardMax();
206 if (cardMaxSum < x[
i].cardMax()) { maxValid =
false; }
221 unsigned int* rightSum = r.
alloc<
unsigned int>(xsize);
224 for (
int i=x.
size()-1;
i--;) {
225 rightSum[
i] = rightSum[
i+1] + x[
i+1].cardMax();
226 if (rightSum[
i] < rightSum[
i+1]) {
228 for (
int j=
i; j>0;j--) {
236 unsigned int leftAcc=unionOfDets.
size();
238 for (
int i=0;
i<xsize;
i++) {
239 unsigned int jsum = leftAcc+rightSum[
i];
241 if (jsum >= leftAcc && jsum < y.cardMin()) {
244 leftAcc += x[
i].cardMax();
254 new (&rightUnion[xsize-1])
GLBndSet(home);
255 for (
int i=xsize-1;
i--;) {
266 leftAcc.
update(home,unionOfDets);
267 for (
int i=0;
i<xsize;
i++) {
271 BndSetRanges> iter(left, right);
273 if (y.cardMin() > unionSize) {
275 x[i].cardMin(home, y.cardMin() - unionSize) );
281 for (
int i=xsize;
i--;)
282 rightUnion[
i].dispose(home);
296 template<
class View0,
class View1>
301 int xsize = x.
size();
302 for (
int i=xsize;
i--; ) {
310 template<
class View0,
class View1>
315 unsigned int cardMinSum=unionOfDets.
size();
316 unsigned int cardMaxSum=unionOfDets.
size();
317 int xsize = x.
size();
318 for (
int i=xsize;
i--; ) {
319 cardMinSum+=x[
i].cardMin();
320 if (cardMinSum < x[
i].cardMin()) {
326 for (
int i=xsize;
i--; ) {
327 cardMaxSum+=x[
i].cardMax();
328 if (cardMaxSum < x[
i].cardMax()) {
344 unsigned int* rightMinSum = r.
alloc<
unsigned int>(xsize);
345 unsigned int* rightMaxSum = r.
alloc<
unsigned int>(xsize);
346 rightMinSum[xsize-1]=0;
347 rightMaxSum[xsize-1]=0;
349 for (
int i=x.
size()-1;
i--;) {
350 rightMaxSum[
i] = rightMaxSum[
i+1] + x[
i+1].cardMax();
351 if (rightMaxSum[
i] < rightMaxSum[
i+1]) {
353 for (
int j=
i; j>0;j--) {
359 for (
int i=x.
size()-1;
i--;) {
360 rightMinSum[
i] = rightMinSum[
i+1] + x[
i+1].cardMin();
361 if (rightMinSum[
i] < rightMinSum[
i+1]) {
366 unsigned int leftMinAcc=unionOfDets.
size();
367 unsigned int leftMaxAcc=unionOfDets.
size();
369 for (
int i=0;
i<xsize;
i++) {
370 unsigned int maxSum = leftMaxAcc+rightMaxSum[
i];
371 unsigned int minSum = leftMinAcc+rightMinSum[
i];
373 if (maxSum >= leftMaxAcc && maxSum < y.cardMin()) {
378 if (minSum < leftMinAcc || y.cardMax() < minSum) {
385 leftMaxAcc += x[
i].cardMax();
386 if (leftMaxAcc < x[
i].cardMax())
388 leftMinAcc += x[
i].cardMin();
389 if (leftMinAcc < x[
i].cardMin())
399 template<
class View0,
class View1>
403 int xsize = x.
size();
413 for (
int i=xsize;
i--;) {
416 afterUB[
i].
update(home,sofarAfterUB);
417 afterLB[
i].
update(home,sofarAfterLB);
430 for (
int i=0;
i<xsize;
i++) {
435 BndSetRanges> xjlb(slb, afterlb);
438 BndSetRanges> > diff1(yub, xjlb);
442 BndSetRanges sub(sofarBeforeUB);
443 BndSetRanges afterub(afterUB[i]);
445 BndSetRanges> xjub(sub, afterub);
448 BndSetRanges> > diff2(ylb, xjub);
460 for (
int i=xsize;
i--;) {
469 template<
class View0,
class View1>
474 int xsize = x.
size();
481 for (
int i=xsize;
i--;) {
483 afterLB[
i].
update(home,sofarAfterLB);
492 sofarBeforeLB.
update(home,unionOfDets);
493 for (
int i=0;
i<xsize;
i++) {
498 BndSetRanges> xjlb(slb, afterlb);
501 BndSetRanges> > diff1(yub, xjlb);
509 for (
int i=xsize;
i--;)
510 afterLB[
i].dispose(home);
515 template<
class View0,
class View1>
520 int xsize = x.
size();
527 for (
int i=xsize;
i--;) {
529 afterUB[
i].
update(home,sofarAfterUB);
539 sofarBeforeUB.
update(home,unionOfDets);
540 for (
int i=0;
i<xsize;
i++) {
545 BndSetRanges> xjub(sub, afterub);
548 BndSetRanges> > diff2(ylb, xjub);
556 for (
int i=xsize;
i--;)
557 afterUB[
i].dispose(home);
562 template<
class View0,
class View1>
568 int xsize = x.
size();
571 int nonEmptyCounter=0;
572 for (
int i = xsize;
i--; ) {
575 xLBs[nonEmptyCounter] =
r;
579 if (nonEmptyCounter !=0) {
589 template<
class View0,
class View1>
594 int xsize = x.
size();
597 int nonEmptyCounter=0;
598 for (
int i = xsize;
i--; ) {
601 xUBs[nonEmptyCounter] =
r;
605 if (nonEmptyCounter != 0) {
ExecStatus partitionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
ExecStatus partitionNYLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
const Gecode::ModEvent ME_SET_FAILED
Domain operation has resulted in failure.
const FloatNum max
Largest allowed float value.
ExecStatus unionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
ExecStatus partitionNXiLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
Range iterator for the greatest lower bound.
ExecStatus interCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
ExecStatus unionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
Propagation has computed fixpoint.
const unsigned int card
Maximum cardinality of an integer set.
#define GECODE_ME_CHECK_MODIFIED(modified, me)
Check whether me is failed or modified, and forward failure.
Range iterator for the least upper bound.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
unsigned int size(void) const
Return size.
bool overflow(Term *t, int n, FloatVal c)
Range iterator for computing intersection (binary)
Range iterator for union of iterators.
ExecStatus partitionNXi(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y)
unsigned int size(I &i)
Size of all ranges of range iterator i.
Range iterator for integer sets.
bool viewarrayshared(const ViewArray< View0 > &va, const View1 &y)
bool isConsistent(void) const
Check whether internal invariants hold.
ExecStatus partitionNYUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
bool shared(void) const
Test whether array contains shared views.
void update(Space &home, BndSet &x)
Update this set to be a clone of set x.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
bool includeI(Space &home, I &i)
Include the set represented by i in this set.
void dispose(Space &home)
Free memory used by this set.
bool shared(View0 v0, View1 v1, View2 v2)
Range iterator for computing union (binary)
Post propagator for SetVar SetOpType SetVar SetRelType r
Set view for set variables
Gecode::IntArgs v1(4, Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max)
Post propagator for SetVar SetOpType SetVar y
Growing sets of integers.
ExecStatus partitionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
Post propagator for SetVar x
Propagation has not computed fixpoint.
Gecode toplevel namespace
Range iterator for computing set difference.
int size(void) const
Return size of array (number of elements)
ExecStatus unionCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
void * ralloc(size_t s)
Allocate memory from region.
Gecode::IntArgs v2(4, Gecode::Int::Limits::min, 0, 1, Gecode::Int::Limits::max-4)