00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 namespace Gecode { namespace Set { namespace RelOp {
00045
00046 template<class View0, class View1, class View2>
00047 forceinline
00048 SuperOfInter<View0,View1,View2>::SuperOfInter
00049 (Home home, View0 y0, View1 y1, View2 y2)
00050 : MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY,
00051 View2,PC_SET_CLUB>(home,y0,y1,y2) {}
00052
00053 template<class View0, class View1, class View2>
00054 forceinline
00055 SuperOfInter<View0,View1,View2>::SuperOfInter
00056 (Space& home, bool share, SuperOfInter<View0,View1,View2>& p)
00057 : MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY,
00058 View2,PC_SET_CLUB>(home,share,p) {}
00059
00060 template<class View0, class View1, class View2>
00061 ExecStatus
00062 SuperOfInter<View0,View1,View2>::post(Home home,
00063 View0 x0, View1 x1, View2 x2) {
00064 (void) new (home) SuperOfInter<View0,View1,View2>(home, x0, x1, x2);
00065 return ES_OK;
00066 }
00067
00068 template<class View0, class View1, class View2>
00069 Actor*
00070 SuperOfInter<View0,View1,View2>::copy(Space& home, bool share) {
00071 return new (home) SuperOfInter(home,share,*this);
00072 }
00073
00074 template<class View0, class View1, class View2>
00075 ExecStatus
00076 SuperOfInter<View0,View1,View2>::propagate(Space& home, const ModEventDelta& med) {
00077
00078 bool allassigned = x0.assigned() && x1.assigned() && x2.assigned();
00079
00080 ModEvent me0 = View0::me(med);
00081 ModEvent me1 = View1::me(med);
00082 ModEvent me2 = View2::me(med);
00083
00084 bool modified = false;
00085
00086 do {
00087
00088 if ( modified || Rel::testSetEventLB(me0,me1)) {
00089 GlbRanges<View0> lb0(x0);
00090 GlbRanges<View1> lb1(x1);
00091 Iter::Ranges::Inter<GlbRanges<View0>,GlbRanges<View1> >
00092 is(lb0, lb1);
00093
00094 GECODE_ME_CHECK_MODIFIED(modified,x2.includeI(home,is));
00095 }
00096
00097
00098
00099 if ( modified || Rel::testSetEventAnyB(me0,me1,me2)) {
00100 modified = false;
00101 GlbRanges<View1> lb12(x1);
00102 LubRanges<View2> ub22(x2);
00103 Iter::Ranges::Diff<GlbRanges<View1>, LubRanges<View2> >
00104 diff1(lb12, ub22);
00105
00106 GECODE_ME_CHECK_MODIFIED(modified, x0.excludeI(home,diff1));
00107
00108 GlbRanges<View0> lb01(x0);
00109 LubRanges<View2> ub23(x2);
00110 Iter::Ranges::Diff<GlbRanges<View0>, LubRanges<View2> >
00111 diff2(lb01, ub23);
00112
00113 GECODE_ME_CHECK_MODIFIED(modified, x1.excludeI(home,diff2));
00114 } else {
00115 modified = false;
00116 }
00117
00118
00119 if ( modified ||
00120 Rel::testSetEventCard(me0,me1,me2) ||
00121 Rel::testSetEventUB(me0,me1)
00122 ) {
00123
00124 LubRanges<View0> ub0(x0);
00125 LubRanges<View1> ub1(x1);
00126 Iter::Ranges::Union<LubRanges<View0>, LubRanges<View1> > u(ub0,ub1);
00127
00128 unsigned int m = Iter::Ranges::size(u);
00129
00130 if (m < x0.cardMin() + x1.cardMin()) {
00131 GECODE_ME_CHECK_MODIFIED(modified,
00132 x2.cardMin( home,
00133 x0.cardMin()+x1.cardMin() - m ) );
00134 }
00135 if (m + x2.cardMax() > x1.cardMin()) {
00136 GECODE_ME_CHECK_MODIFIED(modified,
00137 x0.cardMax( home,
00138 m+x2.cardMax()-x1.cardMin() ) );
00139 }
00140 if (m + x2.cardMax() > x0.cardMin()) {
00141 GECODE_ME_CHECK_MODIFIED(modified,
00142 x1.cardMax( home,
00143 m+x2.cardMax()-x0.cardMin() ) );
00144 }
00145 }
00146 } while (modified);
00147
00148
00149 if (shared(x0,x1,x2)) {
00150 if (allassigned) {
00151 return home.ES_SUBSUMED(*this);
00152 } else {
00153 return ES_NOFIX;
00154 }
00155 } else {
00156 if (x0.assigned() + x1.assigned() + x2.assigned() >= 2) {
00157 return home.ES_SUBSUMED(*this);
00158 } else {
00159 return ES_FIX;
00160 }
00161 }
00162
00163 }
00164
00165 }}}
00166
00167