Beispiel #1
0
 /// %Test whether \a x is solution
 bool solution(const SetAssignment& x) const {
   int x1 = shared ? x[0] : x[1];
   CountableSetRanges xr0(x.lub, x[0]);
   CountableSetRanges xr1(x.lub, x1);
   switch (srt) {
   case SRT_EQ: return Iter::Ranges::equal(xr0, xr1);
   case SRT_NQ: return !Iter::Ranges::equal(xr0, xr1);
   
   case SRT_LQ: return (!xr0()) || in(minSymDiff(x),xr1,true);
   case SRT_LE: return xr0() ? in(minSymDiff(x),xr1) : xr1();
   case SRT_GQ: return (!xr1()) || in(minSymDiff(x),xr0,true);
   case SRT_GR: return xr1() ? in(minSymDiff(x),xr0) : xr0();
   
   case SRT_SUB: return Iter::Ranges::subset(xr0, xr1);
   case SRT_SUP: return Iter::Ranges::subset(xr1, xr0);
   case SRT_DISJ:
     {
       Iter::Ranges::Inter<CountableSetRanges,CountableSetRanges>
         inter(xr0,xr1);
       return !inter();
     }
   case SRT_CMPL:
     {
       Gecode::Set::RangesCompl<CountableSetRanges> rc(xr0);
       return Iter::Ranges::equal(rc,xr1);
     }
   default:
     GECODE_NEVER;
   }
   GECODE_NEVER;
   return false;
 }
 /// %Test whether \a x is solution
 virtual bool solution(const SetAssignment& x) const {
   CountableSetRanges xr0(x.lub, x[0]);
   if (!xr0())
     return true;
   ++xr0;
   if (!xr0())
     return true;
   return false;
 }
      /// %Test whether \a x is solution
      virtual bool solution(const SetAssignment& x) const {
        CountableSetRanges xr0(x.lub, x[0]);
        CountableSetRanges xr1(x.lub, x[1]);

        if (!xr0())
          return !xr1();

        int x0min = xr0.min();
        int x0max = xr0.max();
        ++xr0;
        if (!xr0()) {
          if (!xr1()) return false;
          if (x0min != xr1.min()) return false;
          int x1max = Gecode::Set::Limits::min;
          while (xr1()) { x1max = xr1.max(); ++xr1;}
          if (x0max != x1max) return false;
          return true;
        }
        return false;
      }