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 CpltSet {
00039
00040 template <class View1, class View2>
00041 forceinline
00042 Singleton<View1, View2>::Singleton(Space* home, View1& x0, View2& s0)
00043 : Propagator(home), x(x0), s(s0) {
00044 force(home);
00045 x.subscribe(home, this, Gecode::Int::PC_INT_DOM);
00046 s.subscribe(home, this, PC_CPLTSET_DOM);
00047 }
00048
00049 template <class View1, class View2>
00050 forceinline
00051 Singleton<View1, View2>::Singleton(Space* home, bool share, Singleton& p)
00052 : Propagator(home,share,p) {
00053 x.update(home, share, p.x);
00054 s.update(home, share, p.s);
00055 }
00056
00057 template <class View1, class View2>
00058 forceinline PropCost
00059 Singleton<View1, View2>::cost(ModEventDelta) const {
00060 return PC_BINARY_LO;
00061 }
00062
00063 template <class View1, class View2>
00064 Support::Symbol
00065 Singleton<View1,View2>::ati(void) {
00066 return Reflection::mangle<View1,View2>("Gecode::CpltSet::Singleton");
00067 }
00068
00069 template <class View1, class View2>
00070 Reflection::ActorSpec
00071 Singleton<View1,View2>::spec(const Space*, Reflection::VarMap&) const {
00072 throw Reflection::ReflectionException("Not implemented");
00073 }
00074
00075 template <class View1, class View2>
00076 size_t
00077 Singleton<View1, View2>::dispose(Space* home) {
00078 unforce(home);
00079 if (!home->failed()) {
00080 x.cancel(home, this, Gecode::Int::PC_INT_DOM);
00081 s.cancel(home, this, PC_CPLTSET_DOM);
00082 }
00083 Propagator::dispose(home);
00084 return sizeof(*this);
00085 }
00086
00087 template <class View1, class View2>
00088 forceinline ExecStatus
00089 Singleton<View1, View2>::post(Space* home, View1& x0, View2& s0) {
00090 (void) new (home) Singleton(home, x0, s0);
00091 return ES_OK;
00092 }
00093
00094 template <class View1, class View2>
00095 forceinline Actor*
00096 Singleton<View1, View2>::copy(Space* home, bool share) {
00097 return new (home) Singleton(home, share, *this);
00098 }
00099
00100 template <class View1, class View2>
00101 forceinline ExecStatus
00102 Singleton<View1, View2>::propagate(Space* home, ModEventDelta) {
00103 if (x.assigned()) {
00104 GECODE_ME_CHECK(s.eq(home, x.val()));
00105 return ES_SUBSUMED(this, home);
00106 } else {
00107
00108 Gecode::Int::ViewRanges<View1> dom(x);
00109 Set::LubRanges<View2> lub(s);
00110 Iter::Ranges::Inter<Gecode::Int::ViewRanges<View1>,
00111 Set::LubRanges<View2> > common(dom, lub);
00112 if (!common()) {
00113 return ES_FAILED;
00114 }
00115 Iter::Ranges::Cache<
00116 Iter::Ranges::Inter<Gecode::Int::ViewRanges<View1>,
00117 Set::LubRanges<View2> > > cache_inter(common);
00118
00119 GECODE_ME_CHECK(x.inter_r(home, cache_inter));
00120 cache_inter.reset();
00121 GECODE_ME_CHECK(s.intersectI(home, cache_inter));
00122 return ES_FIX;
00123 }
00124 }
00125
00126
00127
00128 }}
00129
00130