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