val.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 namespace Gecode { namespace Int { namespace Circuit {
00035
00036
00037
00038
00039
00040 template<class View, class Offset>
00041 forceinline
00042 Val<View,Offset>::Val(Home home, ViewArray<View>& x, Offset& o)
00043 : Base<View,Offset>(home,x,o) {}
00044
00045 template<class View, class Offset>
00046 forceinline
00047 Val<View,Offset>::Val(Space& home, Val<View,Offset>& p)
00048 : Base<View,Offset>(home,p) {}
00049
00050 template<class View, class Offset>
00051 Actor*
00052 Val<View,Offset>::copy(Space& home) {
00053 return new (home) Val<View,Offset>(home,*this);
00054 }
00055
00056 template<class View, class Offset>
00057 PropCost
00058 Val<View,Offset>::cost(const Space&, const ModEventDelta&) const {
00059 return PropCost::linear(PropCost::HI, x.size());
00060 }
00061
00062 template<class View, class Offset>
00063 ExecStatus
00064 Val<View,Offset>::propagate(Space& home, const ModEventDelta&) {
00065 GECODE_ES_CHECK((Int::Distinct::prop_val<View,true>(home,y)));
00066 ExecStatus esc = connected(home);
00067 if (esc != ES_FIX)
00068 return esc;
00069
00070
00071
00072
00073 if (y.size() < 2)
00074 return home.ES_SUBSUMED(*this);
00075 return path(home);
00076 }
00077
00078 template<class View, class Offset>
00079 ExecStatus
00080 Val<View,Offset>::post(Home home, ViewArray<View>& x, Offset& o) {
00081 int n = x.size();
00082 if (n == 1) {
00083 GECODE_ME_CHECK(o(x[0]).eq(home,0));
00084 } else if (n == 2) {
00085 GECODE_ME_CHECK(o(x[0]).eq(home,1));
00086 GECODE_ME_CHECK(o(x[1]).eq(home,0));
00087 } else {
00088 for (int i=0; i<n; i++) {
00089 GECODE_ME_CHECK(o(x[i]).gq(home,0));
00090 GECODE_ME_CHECK(o(x[i]).le(home,n));
00091 GECODE_ME_CHECK(o(x[i]).nq(home,i));
00092 }
00093 (void) new (home) Val<View,Offset>(home,x,o);
00094 }
00095 return ES_OK;
00096 }
00097
00098 }}}
00099
00100
00101