card.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
00039
00040
00041
00042 #include <gecode/set.hh>
00043 #include <gecode/int.hh>
00044
00045 namespace Gecode { namespace Set { namespace Int {
00046
00047 template<class View>
00048 forceinline
00049 Card<View>::Card(Home home, View y0, Gecode::Int::IntView y1)
00050 : MixBinaryPropagator<View,PC_SET_CARD,
00051 Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, y0, y1) {}
00052
00053 template<class View>
00054 forceinline ExecStatus
00055 Card<View>::post(Home home, View x0, Gecode::Int::IntView x1) {
00056 GECODE_ME_CHECK(x1.gq(home,0));
00057 GECODE_ME_CHECK(x0.cardMax(home, Gecode::Int::Limits::max));
00058 (void) new (home) Card(home,x0,x1);
00059 return ES_OK;
00060 }
00061
00062 template<class View>
00063 forceinline
00064 Card<View>::Card(Space& home, bool share, Card& p)
00065 : MixBinaryPropagator<View,PC_SET_CARD,
00066 Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, share, p) {}
00067
00068 template<class View>
00069 Actor*
00070 Card<View>::copy(Space& home, bool share) {
00071 return new (home) Card(home,share,*this);
00072 }
00073
00074 template<class View>
00075 ExecStatus
00076 Card<View>::propagate(Space& home, const ModEventDelta&) {
00077 int x1min, x1max;
00078 do {
00079 x1min = x1.min();
00080 x1max = x1.max();
00081 GECODE_ME_CHECK(x0.cardMin(home,static_cast<unsigned int>(x1min)));
00082 GECODE_ME_CHECK(x0.cardMax(home,static_cast<unsigned int>(x1max)));
00083 GECODE_ME_CHECK(x1.gq(home,static_cast<int>(x0.cardMin())));
00084 GECODE_ME_CHECK(x1.lq(home,static_cast<int>(x0.cardMax())));
00085 } while (x1.min() > x1min || x1.max() < x1max);
00086 if (x1.assigned())
00087 return home.ES_SUBSUMED(*this);
00088 return ES_FIX;
00089 }
00090
00091 }}}
00092
00093