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 "test/set.hh"
00039
00040 using namespace Gecode;
00041
00042 namespace Test { namespace Set {
00043
00045 namespace Rel {
00046
00052
00053 static IntSet ds_33(-3,3);
00054
00056 class RelBin : public SetTest {
00057 private:
00058 Gecode::SetRelType srt;
00059 bool shared;
00060 public:
00062 RelBin(Gecode::SetRelType srt0, bool shared0)
00063 : SetTest("Rel::Bin::"+str(srt0)+"::S"+(shared0 ? "1":"0"),
00064 shared ? 1 : 2,ds_33,true)
00065 , srt(srt0), shared(shared0){}
00067 bool solution(const SetAssignment& x) const {
00068 int x1 = shared ? x[0] : x[1];
00069 CountableSetRanges xr0(x.lub, x[0]);
00070 CountableSetRanges xr1(x.lub, x1);
00071 switch (srt) {
00072 case SRT_EQ: return Iter::Ranges::equal(xr0, xr1);
00073 case SRT_NQ: return !Iter::Ranges::equal(xr0, xr1);
00074 case SRT_SUB: return Iter::Ranges::subset(xr0, xr1);
00075 case SRT_SUP: return Iter::Ranges::subset(xr1, xr0);
00076 case SRT_DISJ:
00077 {
00078 Iter::Ranges::Inter<CountableSetRanges,CountableSetRanges>
00079 inter(xr0,xr1);
00080 return !inter();
00081 }
00082 case SRT_CMPL:
00083 {
00084 Gecode::Set::RangesCompl<CountableSetRanges> rc(xr0);
00085 return Iter::Ranges::equal(rc,xr1);
00086 }
00087 default:
00088 GECODE_NEVER;
00089 }
00090 GECODE_NEVER;
00091 return false;
00092 }
00094 void post(Space* home, SetVarArray& x, IntVarArray&) {
00095 if (!shared)
00096 Gecode::rel(home, x[0], srt, x[1]);
00097 else
00098 Gecode::rel(home, x[0], srt, x[0]);
00099 }
00101 void post(Space* home, SetVarArray& x, IntVarArray&, BoolVar b) {
00102 if (!shared)
00103 Gecode::rel(home, x[0], srt, x[1], b);
00104 else
00105 Gecode::rel(home, x[0], srt, x[0], b);
00106 }
00107 };
00108 RelBin _relbin_eq(Gecode::SRT_EQ,false);
00109 RelBin _relbin_nq(Gecode::SRT_NQ,false);
00110 RelBin _relbin_sub(Gecode::SRT_SUB,false);
00111 RelBin _relbin_sup(Gecode::SRT_SUP,false);
00112 RelBin _relbin_disj(Gecode::SRT_DISJ,false);
00113 RelBin _relbin_cmpl(Gecode::SRT_CMPL,false);
00114 RelBin _relbin_shared_eq(Gecode::SRT_EQ,true);
00115 RelBin _relbin_shared_nq(Gecode::SRT_NQ,true);
00116 RelBin _relbin_shared_sub(Gecode::SRT_SUB,true);
00117 RelBin _relbin_shared_sup(Gecode::SRT_SUP,true);
00118 RelBin _relbin_shared_disj(Gecode::SRT_DISJ,true);
00119 RelBin _relbin_shared_cmpl(Gecode::SRT_CMPL,true);
00120
00122
00123 }}}
00124
00125