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