Skip to content

Commit 1c59f46

Browse files
committed
Make n-ary union propagator idempotent (as promised)
git-svn-id: file:///Volumes/GecodeGitMigration/gecode-svn-mirror/gecode/trunk@15224 e85b7adc-8362-4630-8c63-7469d557c915
1 parent 76fdbeb commit 1c59f46

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

gecode/set/rel-op/union.hpp

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ namespace Gecode { namespace Set { namespace RelOp {
267267

268268
template<class View0, class View1>
269269
ExecStatus
270-
UnionN<View0,View1>::propagate(Space& home, const ModEventDelta& med) {
270+
UnionN<View0,View1>::propagate(Space& home, const ModEventDelta& med) {
271271
ModEvent me0 = View0::me(med);
272272
ModEvent me1 = View1::me(med);
273273
bool ubevent = Rel::testSetEventUB(me0, me1);
@@ -279,28 +279,33 @@ namespace Gecode { namespace Set { namespace RelOp {
279279
bool oldModified = false;
280280

281281
do {
282-
oldModified = modified;
283-
modified = false;
284-
if (modified || oldModified || ubevent)
285-
GECODE_ES_CHECK(unionNXiUB(home, modified, x, y,unionOfDets));
286-
if (modified || oldModified || ubevent)
287-
GECODE_ES_CHECK(partitionNYUB(home, modified, x, y,unionOfDets));
288-
if (modified || oldModified || anybevent)
289-
GECODE_ES_CHECK(partitionNXiLB(home, modified, x, y,unionOfDets));
290-
if (modified || oldModified || lbevent)
291-
GECODE_ES_CHECK(partitionNYLB(home, modified, x, y,unionOfDets));
292-
if (modified || oldModified || cardevent || ubevent)
293-
GECODE_ES_CHECK(unionNCard(home, modified, x, y, unionOfDets));
294-
} while (modified);
282+
do {
283+
oldModified = modified;
284+
modified = false;
285+
if (modified || oldModified || ubevent)
286+
GECODE_ES_CHECK(unionNXiUB(home, modified, x, y,unionOfDets));
287+
if (modified || oldModified || ubevent)
288+
GECODE_ES_CHECK(partitionNYUB(home, modified, x, y,unionOfDets));
289+
if (modified || oldModified || anybevent)
290+
GECODE_ES_CHECK(partitionNXiLB(home, modified, x, y,unionOfDets));
291+
if (modified || oldModified || lbevent)
292+
GECODE_ES_CHECK(partitionNYLB(home, modified, x, y,unionOfDets));
293+
if (modified || oldModified || cardevent || ubevent) {
294+
GECODE_ES_CHECK(unionNCard(home, modified, x, y, unionOfDets));
295+
}
296+
} while (modified);
295297

296-
for(int i=0;i<x.size();i++){
297-
//Do not reverse! Eats away the end of the array!
298-
while (i<x.size() && x[i].assigned()) {
299-
GlbRanges<View0> det(x[i]);
300-
unionOfDets.includeI(home,det);
301-
x.move_lst(i);
298+
for(int i=0;i<x.size();i++){
299+
//Do not reverse! Eats away the end of the array!
300+
while (i<x.size() && x[i].assigned()) {
301+
GlbRanges<View0> det(x[i]);
302+
unionOfDets.includeI(home,det);
303+
x.move_lst(i);
304+
modified = true;
305+
}
302306
}
303-
}
307+
308+
} while (modified);
304309
// When we run out of variables, make a final check and disolve:
305310
if (x.size()==0) {
306311
BndSetRanges all1(unionOfDets);

test/set/element.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ namespace Test { namespace Set {
6060
public:
6161
/// Create and register test
6262
ElementUnion(const char* t)
63-
: SetTest(t,5,ds_12,false) {
64-
disabled = false;
65-
}
63+
: SetTest(t,5,ds_12,false) {}
6664
/// %Test whether \a x is solution
6765
virtual bool solution(const SetAssignment& x) const {
6866
int selected = 0;

test/set/rel-op.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ namespace Test { namespace Set {
187187
shared0 == 0 ? n0+1 : (shared0 <= 2 ? 3 : 2),ds_12,false)
188188
, sot(sot0), n(n0), shared(shared0), withConst(withConst0)
189189
, is(0,1) {
190-
if (sot == Gecode::SOT_UNION)
191-
disabled = false;
192190
}
193191
/// %Test whether \a x is solution
194192
bool solution(const SetAssignment& x) const {
@@ -382,8 +380,6 @@ namespace Test { namespace Set {
382380
1,ds_12,false,n0)
383381
, sot(sot0), n(n0), withConst(withConst0)
384382
, is(0,1) {
385-
if (sot == Gecode::SOT_UNION)
386-
disabled = false;
387383
}
388384
/// %Test whether \a x is solution
389385
bool solution(const SetAssignment& x) const {

0 commit comments

Comments
 (0)