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 #include "gecode/int/dom.hh"
00040
00041 namespace Gecode {
00042
00043 using namespace Int;
00044
00045 void
00046 dom(Space* home, IntVar x, int min, int max, IntConLevel, PropKind) {
00047 Limits::check(min,"Int::dom");
00048 Limits::check(max,"Int::dom");
00049 if (home->failed()) return;
00050 IntView xv(x);
00051 GECODE_ME_FAIL(home,xv.gq(home,min));
00052 GECODE_ME_FAIL(home,xv.lq(home,max));
00053 }
00054
00055 void
00056 dom(Space* home, const IntVarArgs& x, int min, int max, IntConLevel, PropKind) {
00057 Limits::check(min,"Int::dom");
00058 Limits::check(max,"Int::dom");
00059 if (home->failed()) return;
00060 for (int i=x.size(); i--; ) {
00061 IntView xv(x[i]);
00062 GECODE_ME_FAIL(home,xv.gq(home,min));
00063 GECODE_ME_FAIL(home,xv.lq(home,max));
00064 }
00065 }
00066
00067 void
00068 dom(Space* home, IntVar x, const IntSet& is, IntConLevel, PropKind) {
00069 Limits::check(is.min(),"Int::dom");
00070 Limits::check(is.max(),"Int::dom");
00071 if (home->failed()) return;
00072 IntView xv(x);
00073 IntSetRanges ris(is);
00074 GECODE_ME_FAIL(home,xv.inter_r(home,ris,false));
00075 }
00076
00077 void
00078 dom(Space* home, const IntVarArgs& x, const IntSet& is, IntConLevel, PropKind) {
00079 Limits::check(is.min(),"Int::dom");
00080 Limits::check(is.max(),"Int::dom");
00081 if (home->failed()) return;
00082 for (int i = x.size(); i--; ) {
00083 IntSetRanges ris(is);
00084 IntView xv(x[i]);
00085 GECODE_ME_FAIL(home,xv.inter_r(home,ris,false));
00086 }
00087 }
00088
00089 void
00090 dom(Space* home, IntVar x, int min, int max, BoolVar b, IntConLevel,
00091 PropKind) {
00092 Limits::check(min,"Int::dom");
00093 Limits::check(max,"Int::dom");
00094 if (home->failed()) return;
00095 GECODE_ES_FAIL(home,Dom::ReRange<IntView>::post(home,x,min,max,b));
00096 }
00097
00098
00099 void
00100 dom(Space* home, IntVar x, const IntSet& is, BoolVar b, IntConLevel,
00101 PropKind) {
00102 Limits::check(is.min(),"Int::dom");
00103 Limits::check(is.max(),"Int::dom");
00104 if (home->failed()) return;
00105 GECODE_ES_FAIL(home,Dom::ReIntSet<IntView>::post(home,x,is,b));
00106 }
00107
00108 namespace {
00109 GECODE_REGISTER1(Dom::ReRange<IntView>);
00110 GECODE_REGISTER1(Dom::ReIntSet<IntView>);
00111 }
00112
00113 }
00114
00115
00116