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