44 #ifndef __GECODE_SET_RELOP_COMM_ICC__ 45 #define __GECODE_SET_RELOP_COMM_ICC__ 49 template<
class View0,
class View1>
58 viewarrayshared<Set::SingletonView,Set::SetView>
65 viewarrayshared<Set::ComplementView<Set::SingletonView>,Set::SetView>
66 (
const Space&,
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
67 const Set::SetView&) {
73 viewarrayshared<Set::ComplementView<Set::SingletonView>,
74 Set::ComplementView<Set::SetView> >
75 (
const Space&,
const ViewArray<Set::ComplementView<Set::SingletonView> >&,
76 const Set::ComplementView<Set::SetView>&) {
81 namespace Set {
namespace RelOp {
87 template<
class View0,
class View1,
class View2>
93 template<
class View0,
class View1,
class View2>
95 bool& retmodified, View0& x0, View1& x1, View2& x2) {
96 bool modified =
false;
98 retmodified |= modified;
108 if (x0.cardMin() + x1.cardMin() > s1) {
110 x2.cardMin(home, x0.cardMin()+x1.cardMin()-s1));
129 x0.cardMax()+x1.cardMax()-s1));
132 if (x2.cardMax() < x1.cardMin())
137 if (x2.cardMax() < x0.cardMin())
143 x0.cardMin(home,x2.cardMin()));
145 x1.cardMin(home,x2.cardMin()));
149 template<
class View0,
class View1,
class View2>
151 bool& retmodified, View0& x0, View1& x1, View2& x2) {
152 bool modified =
false;
154 retmodified |= modified;
162 unsigned int res =
std::max(x0.cardMin()+
164 0 : x1.cardMin()-s1),
177 std::min(x0.cardMax()+x1.cardMax(),s1)));
180 if (x2.cardMin() > x1.cardMax())
182 x0.cardMin(home,x2.cardMin() - x1.cardMax()));
184 if (x2.cardMin() > x0.cardMax())
186 x1.cardMin(home,x2.cardMin() - x0.cardMax()));
189 x0.cardMax(home,x2.cardMax()));
191 x1.cardMax(home,x2.cardMax()));
196 template<
class View0,
class View1>
200 int xsize =
x.size();
203 unsigned int cardMaxSum=unionOfDets.
size();
204 bool maxValid =
true;
205 for (
int i=xsize;
i--; ){
207 if (cardMaxSum <
x[
i].cardMax()) { maxValid =
false; }
222 unsigned int* rightSum =
r.alloc<
unsigned int>(xsize);
225 for (
int i=
x.size()-1;
i--;) {
227 if (rightSum[
i] < rightSum[
i+1]) {
229 for (
int j=
i; j>0;j--) {
237 unsigned int leftAcc=unionOfDets.
size();
239 for (
int i=0;
i<xsize;
i++) {
240 unsigned int jsum = leftAcc+rightSum[
i];
242 if (jsum >= leftAcc && jsum <
y.
cardMin()) {
254 static_cast<GLBndSet*>(
r.ralloc(
sizeof(
GLBndSet)*xsize));
255 new (&rightUnion[xsize-1])
GLBndSet(home);
256 for (
int i=xsize-1;
i--;){
267 leftAcc.
update(home,unionOfDets);
268 for (
int i=0;
i<xsize;
i++) {
276 x[
i].cardMin(home,
y.
cardMin() - unionSize) );
282 for (
int i=xsize;
i--;)
283 rightUnion[
i].dispose(home);
297 template<
class View0,
class View1>
302 int xsize =
x.size();
303 for (
int i=xsize;
i--; ) {
311 template<
class View0,
class View1>
316 unsigned int cardMinSum=unionOfDets.
size();
317 unsigned int cardMaxSum=unionOfDets.
size();
318 int xsize =
x.size();
319 for (
int i=xsize;
i--; ) {
321 if (cardMinSum <
x[
i].cardMin()) {
327 for (
int i=xsize;
i--; ) {
329 if (cardMaxSum <
x[
i].cardMax()) {
345 unsigned int* rightMinSum =
r.alloc<
unsigned int>(xsize);
346 unsigned int* rightMaxSum =
r.alloc<
unsigned int>(xsize);
347 rightMinSum[xsize-1]=0;
348 rightMaxSum[xsize-1]=0;
350 for (
int i=
x.size()-1;
i--;) {
351 rightMaxSum[
i] = rightMaxSum[
i+1] +
x[
i+1].
cardMax();
352 if (rightMaxSum[
i] < rightMaxSum[
i+1]) {
354 for (
int j=
i; j>0;j--) {
360 for (
int i=
x.size()-1;
i--;) {
361 rightMinSum[
i] = rightMinSum[
i+1] +
x[
i+1].
cardMin();
362 if (rightMinSum[
i] < rightMinSum[
i+1]) {
367 unsigned int leftMinAcc=unionOfDets.
size();
368 unsigned int leftMaxAcc=unionOfDets.
size();
370 for (
int i=0;
i<xsize;
i++) {
371 unsigned int maxSum = leftMaxAcc+rightMaxSum[
i];
372 unsigned int minSum = leftMinAcc+rightMinSum[
i];
374 if (maxSum >= leftMaxAcc && maxSum <
y.
cardMin()) {
379 if (minSum < leftMinAcc ||
y.
cardMax() < minSum) {
387 if (leftMaxAcc <
x[
i].cardMax())
390 if (leftMinAcc <
x[
i].cardMin())
400 template<
class View0,
class View1>
404 int xsize =
x.size();
407 static_cast<GLBndSet*>(
r.ralloc(
sizeof(
GLBndSet)*xsize));
409 static_cast<GLBndSet*>(
r.ralloc(
sizeof(
GLBndSet)*xsize));
414 for (
int i=xsize;
i--;) {
417 afterUB[
i].
update(home,sofarAfterUB);
418 afterLB[
i].update(home,sofarAfterLB);
431 for (
int i=0;
i<xsize;
i++) {
461 for (
int i=xsize;
i--;) {
463 afterLB[
i].dispose(home);
470 template<
class View0,
class View1>
475 int xsize =
x.size();
478 static_cast<GLBndSet*>(
r.ralloc(
sizeof(
GLBndSet)*xsize));
482 for (
int i=xsize;
i--;) {
484 afterLB[
i].
update(home,sofarAfterLB);
493 sofarBeforeLB.
update(home,unionOfDets);
494 for (
int i=0;
i<xsize;
i++) {
510 for (
int i=xsize;
i--;)
511 afterLB[
i].dispose(home);
516 template<
class View0,
class View1>
521 int xsize =
x.size();
524 static_cast<GLBndSet*>(
r.ralloc(
sizeof(
GLBndSet)*xsize));
528 for (
int i=xsize;
i--;) {
530 afterUB[
i].
update(home,sofarAfterUB);
540 sofarBeforeUB.
update(home,unionOfDets);
541 for (
int i=0;
i<xsize;
i++) {
557 for (
int i=xsize;
i--;)
558 afterUB[
i].dispose(home);
563 template<
class View0,
class View1>
569 int xsize =
x.size();
572 int nonEmptyCounter=0;
573 for (
int i = xsize;
i--; ) {
576 xLBs[nonEmptyCounter] =
r;
580 if (nonEmptyCounter !=0) {
590 template<
class View0,
class View1>
595 int xsize =
x.size();
598 int nonEmptyCounter=0;
599 for (
int i = xsize;
i--; ) {
602 xUBs[nonEmptyCounter] =
r;
606 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)
bool shared(const Space &home) const
Test whether array contains shared views.
unsigned int size(void) const
Return size.
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 cardMin(void) const
Return cardinality minimum.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Range iterator for integer sets.
bool isConsistent(void) const
Check whether internal invariants hold.
ExecStatus partitionNYUB(Space &home, bool &modified, ViewArray< View0 > &x, View1 &y, GLBndSet &unionOfDets)
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.
unsigned int cardMax(void) const
Return cardinality maximum.
Gecode toplevel namespace
Range iterator for computing set difference.
ExecStatus unionCard(Space &home, bool &retmodified, View0 &x0, View1 &x1, View2 &x2)
Gecode::IntArgs v2(4, Gecode::Int::Limits::min, 0, 1, Gecode::Int::Limits::max-4)
bool viewarrayshared(const Space &home, const ViewArray< View0 > &va, const View1 &y)