Go to the documentation of this file.
40 #ifndef __GECODE_SET_RELOP_COMM_ICC__
41 #define __GECODE_SET_RELOP_COMM_ICC__
45 template<
class View0,
class View1>
53 viewarrayshared<Set::SingletonView,Set::SetView>
60 viewarrayshared<Set::ComplementView<Set::SingletonView>,Set::SetView>
61 (
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
62 const Set::SetView&) {
68 viewarrayshared<Set::ComplementView<Set::SingletonView>,
69 Set::ComplementView<Set::SetView> >
70 (
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
71 const Set::ComplementView<Set::SetView>&) {
76 namespace Set {
namespace RelOp {
82 template<
class View0,
class View1,
class View2>
88 template<
class View0,
class View1,
class View2>
90 bool& retmodified, View0& x0, View1& x1, View2& x2) {
91 bool modified =
false;
93 retmodified |= modified;
103 if (x0.cardMin() + x1.cardMin() > s1) {
105 x2.cardMin(home, x0.cardMin()+x1.cardMin()-s1));
124 x0.cardMax()+x1.cardMax()-s1));
127 if (x2.cardMax() < x1.cardMin())
132 if (x2.cardMax() < x0.cardMin())
138 x0.cardMin(home,x2.cardMin()));
140 x1.cardMin(home,x2.cardMin()));
144 template<
class View0,
class View1,
class View2>
146 bool& retmodified, View0& x0, View1& x1, View2& x2) {
147 bool modified =
false;
149 retmodified |= modified;
157 unsigned int res =
std::max(x0.cardMin()+
159 0 : x1.cardMin()-s1),
172 std::min(x0.cardMax()+x1.cardMax(),s1)));
175 if (x2.cardMin() > x1.cardMax())
177 x0.cardMin(home,x2.cardMin() - x1.cardMax()));
179 if (x2.cardMin() > x0.cardMax())
181 x1.cardMin(home,x2.cardMin() - x0.cardMax()));
184 x0.cardMax(home,x2.cardMax()));
186 x1.cardMax(home,x2.cardMax()));
191 template<
class View0,
class View1>
195 int xsize =
x.size();
198 unsigned int cardMaxSum=unionOfDets.
size();
199 bool maxValid =
true;
200 for (
int i=xsize;
i--; ) {
202 if (cardMaxSum <
x[
i].cardMax()) { maxValid =
false; }
217 unsigned int* rightSum =
r.alloc<
unsigned int>(xsize);
220 for (
int i=
x.size()-1;
i--;) {
222 if (rightSum[
i] < rightSum[
i+1]) {
224 for (
int j=
i; j>0;j--) {
232 unsigned int leftAcc=unionOfDets.
size();
234 for (
int i=0;
i<xsize;
i++) {
235 unsigned int jsum = leftAcc+rightSum[
i];
237 if (jsum >= leftAcc && jsum <
y.
cardMin()) {
250 new (&rightUnion[xsize-1])
GLBndSet(home);
251 for (
int i=xsize-1;
i--;) {
262 leftAcc.
update(home,unionOfDets);
263 for (
int i=0;
i<xsize;
i++) {
271 x[
i].cardMin(home,
y.
cardMin() - unionSize) );
277 for (
int i=xsize;
i--;)
278 rightUnion[
i].dispose(home);
292 template<
class View0,
class View1>
297 int xsize =
x.size();
298 for (
int i=xsize;
i--; ) {
306 template<
class View0,
class View1>
311 unsigned int cardMinSum=unionOfDets.
size();
312 unsigned int cardMaxSum=unionOfDets.
size();
313 int xsize =
x.size();
314 for (
int i=xsize;
i--; ) {
316 if (cardMinSum <
x[
i].cardMin()) {
322 for (
int i=xsize;
i--; ) {
324 if (cardMaxSum <
x[
i].cardMax()) {
340 unsigned int* rightMinSum =
r.alloc<
unsigned int>(xsize);
341 unsigned int* rightMaxSum =
r.alloc<
unsigned int>(xsize);
342 rightMinSum[xsize-1]=0;
343 rightMaxSum[xsize-1]=0;
345 for (
int i=
x.size()-1;
i--;) {
346 rightMaxSum[
i] = rightMaxSum[
i+1] +
x[
i+1].
cardMax();
347 if (rightMaxSum[
i] < rightMaxSum[
i+1]) {
349 for (
int j=
i; j>0;j--) {
355 for (
int i=
x.size()-1;
i--;) {
356 rightMinSum[
i] = rightMinSum[
i+1] +
x[
i+1].
cardMin();
357 if (rightMinSum[
i] < rightMinSum[
i+1]) {
362 unsigned int leftMinAcc=unionOfDets.
size();
363 unsigned int leftMaxAcc=unionOfDets.
size();
365 for (
int i=0;
i<xsize;
i++) {
366 unsigned int maxSum = leftMaxAcc+rightMaxSum[
i];
367 unsigned int minSum = leftMinAcc+rightMinSum[
i];
369 if (maxSum >= leftMaxAcc && maxSum <
y.
cardMin()) {
374 if (minSum < leftMinAcc ||
y.
cardMax() < minSum) {
382 if (leftMaxAcc <
x[
i].cardMax())
385 if (leftMinAcc <
x[
i].cardMin())
395 template<
class View0,
class View1>
399 int xsize =
x.size();
409 for (
int i=xsize;
i--;) {
412 afterUB[
i].
update(home,sofarAfterUB);
413 afterLB[
i].
update(home,sofarAfterLB);
426 for (
int i=0;
i<xsize;
i++) {
456 for (
int i=xsize;
i--;) {
465 template<
class View0,
class View1>
470 int xsize =
x.size();
477 for (
int i=xsize;
i--;) {
479 afterLB[
i].
update(home,sofarAfterLB);
488 sofarBeforeLB.
update(home,unionOfDets);
489 for (
int i=0;
i<xsize;
i++) {
505 for (
int i=xsize;
i--;)
506 afterLB[
i].dispose(home);
511 template<
class View0,
class View1>
516 int xsize =
x.size();
523 for (
int i=xsize;
i--;) {
525 afterUB[
i].
update(home,sofarAfterUB);
535 sofarBeforeUB.
update(home,unionOfDets);
536 for (
int i=0;
i<xsize;
i++) {
552 for (
int i=xsize;
i--;)
553 afterUB[
i].dispose(home);
558 template<
class View0,
class View1>
564 int xsize =
x.size();
567 int nonEmptyCounter=0;
568 for (
int i = xsize;
i--; ) {
571 xLBs[nonEmptyCounter] =
r;
575 if (nonEmptyCounter !=0) {
585 template<
class View0,
class View1>
590 int xsize =
x.size();
593 int nonEmptyCounter=0;
594 for (
int i = xsize;
i--; ) {
597 xUBs[nonEmptyCounter] =
r;
601 if (nonEmptyCounter != 0) {
Post propagator for SetVar x
Post propagator for SetVar SetOpType SetVar y
#define GECODE_ME_CHECK_MODIFIED(modified, me)
Check whether me is failed or modified, and forward failure.
ExecStatus partitionNXiLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
bool includeI(Space &home, I &i)
Include the set represented by i in this set.
unsigned int size(I &i)
Size of all ranges of range iterator i.
ExecStatus partitionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
Gecode::IntArgs v2({Gecode::Int::Limits::min, 0, 1, Gecode::Int::Limits::max-4})
Gecode::IntArgs v1({Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max})
unsigned int cardMin(void) const
Return cardinality minimum.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
bool shared(View0 v0, View1 v1, View2 v2)
const FloatNum min
Smallest allowed float value.
bool viewarrayshared(const ViewArray< View0 > &va, const View1 &y)
ExecStatus partitionNYUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
Gecode toplevel namespace
const unsigned int card
Maximum cardinality of an integer set.
ExecStatus partitionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
unsigned int size(void) const
Return size.
bool isConsistent(void) const
Check whether internal invariants hold.
Range iterator for computing intersection (binary)
Post propagator for SetVar SetOpType SetVar SetRelType r
Range iterator for computing set difference.
void update(Space &home, BndSet &x)
Update this set to be a clone of set x.
unsigned int cardMax(void) const
Return cardinality maximum.
Range iterator for the greatest lower bound.
ExecStatus unionNCard(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
const Gecode::ModEvent ME_SET_FAILED
Domain operation has resulted in failure.
Range iterator for union of iterators.
ExecStatus unionCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
void dispose(Space &home)
Free memory used by this set.
Range iterator for computing union (binary)
bool overflow(Term *t, int n, FloatVal c)
Set view for set variables
bool shared(ViewArray< ViewX > x, ViewArray< ViewY > y)
ExecStatus partitionNXi(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y)
ExecStatus partitionNYLB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
@ ES_FIX
Propagation has computed fixpoint.
Range iterator for the least upper bound.
Range iterator for integer sets.
Growing sets of integers.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
ExecStatus interCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
@ ES_NOFIX
Propagation has not computed fixpoint.
Gecode::IntArgs i({1, 2, 3, 4})
const FloatNum max
Largest allowed float value.
ExecStatus unionNXiUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &)