nosubset.hpp
Go to the documentation of this file.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 namespace Gecode { namespace Set { namespace Rel {
00039
00040
00041
00042
00043
00044
00045 template<class View0, class View1>
00046 forceinline
00047 NoSubset<View0,View1>::NoSubset(Home home, View0 y0, View1 y1)
00048 : MixBinaryPropagator<View0,PC_SET_CLUB,
00049 View1,PC_SET_CGLB>(home,y0,y1) {}
00050
00051 template<class View0, class View1>
00052 forceinline
00053 NoSubset<View0,View1>::NoSubset(Space& home, NoSubset<View0,View1>& p)
00054 : MixBinaryPropagator<View0,PC_SET_CLUB,
00055 View1,PC_SET_CGLB>(home,p) {}
00056
00057 template<class View0, class View1>
00058 ExecStatus
00059 NoSubset<View0,View1>::post(Home home, View0 x, View1 y) {
00060 if (same(x,y))
00061 return ES_FAILED;
00062 if (me_failed(x.cardMin(home,1)))
00063 return ES_FAILED;
00064 (void) new (home) NoSubset<View0,View1>(home,x,y);
00065 return ES_OK;
00066 }
00067
00068 template<class View0, class View1>
00069 Actor*
00070 NoSubset<View0,View1>::copy(Space& home) {
00071 return new (home) NoSubset<View0,View1>(home,*this);
00072 }
00073
00074 template<class View0, class View1>
00075 ExecStatus
00076 NoSubset<View0,View1>::propagate(Space& home, const ModEventDelta&) {
00077 GlbRanges<View0> x0lb(x0);
00078 LubRanges<View1> x1ub(x1);
00079 if (!Iter::Ranges::subset(x0lb, x1ub))
00080 return home.ES_SUBSUMED(*this);
00081 if (x0.cardMin()>x1.cardMax()) { return home.ES_SUBSUMED(*this); }
00082 LubRanges<View0> x0ub(x0);
00083 GlbRanges<View1> x1lb(x1);
00084 Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> >
00085 breakers(x0ub,x1lb);
00086 if (!breakers()) { return ES_FAILED; }
00087 if (breakers.min() == breakers.max()) {
00088 int b1 = breakers.min();
00089 ++breakers;
00090 if (breakers()) { return ES_FIX; }
00091
00092 GECODE_ME_CHECK( x0.include(home,b1) );
00093 GECODE_ME_CHECK( x1.exclude(home,b1) );
00094 return home.ES_SUBSUMED(*this);
00095 }
00096 return ES_FIX;
00097 }
00098
00099 }}}
00100
00101