card.icc
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(Space* home, View y0, Gecode::Int::IntView y1)
00050 : IntSetPropagator<View,PC_SET_CARD,
00051 Gecode::Int::PC_INT_BND> (home, y0, y1) {}
00052
00053 template <class View>
00054 forceinline ExecStatus
00055 Card<View>::post(Space* 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 : IntSetPropagator<View,PC_SET_CARD,
00066 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 Support::Symbol
00076 Card<View>::ati(void) {
00077 return Reflection::mangle<View>("Gecode::Set::Int::Card");
00078 }
00079
00080 template <class View>
00081 Reflection::ActorSpec
00082 Card<View>::spec(const Space* home, Reflection::VarMap& m) const {
00083 return IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>
00084 ::spec(home, m, ati());
00085 }
00086
00087 template <class View>
00088 ExecStatus
00089 Card<View>::propagate(Space* home, ModEventDelta) {
00090 int x1min, x1max;
00091 do {
00092 x1min = x1.min();
00093 x1max = x1.max();
00094 GECODE_ME_CHECK(x0.cardMin(home,x1min));
00095 GECODE_ME_CHECK(x0.cardMax(home,x1max));
00096 GECODE_ME_CHECK(x1.gq(home,(int)x0.cardMin()));
00097 GECODE_ME_CHECK(x1.lq(home,(int)x0.cardMax()));
00098 } while (x1.min() > x1min || x1.max() < x1max);
00099 if (x1.assigned())
00100 return ES_SUBSUMED(this,home);
00101 return ES_FIX;
00102 }
00103
00104 template <class View>
00105 void
00106 Card<View>::post(Space* home, Reflection::VarMap& vars,
00107 const Reflection::ActorSpec& spec) {
00108 spec.checkArity(2);
00109 View x0(home, vars, spec[0]);
00110 Gecode::Int::IntView x1(home, vars, spec[1]);
00111 (void) new (home) Card<View>(home,x0,x1);
00112 }
00113
00114 }}}
00115
00116