Beispiel #1
0
 forceinline size_t
 ViewBase<VX,VY,VZ>::dispose(Space& home) {
   if (vtd(y) == VTD_INTSET)
     home.ignore(*this,AP_DISPOSE);
   x.cancel(home,*this,PC_INT_DOM);
   cancel(home,*this,y);
   z.cancel(home,*this,PC_INT_BND);
   (void) Propagator::dispose(home);
   return sizeof(*this);
 }
Beispiel #2
0
 forceinline
 ViewBase<VX,VY,VZ>::ViewBase(Home home,
                              ViewArray<VX>& x0, VY y0, VZ z0, int c0)
   : Propagator(home), x(x0), y(y0), z(z0), c(c0) {
   if (vtd(y) == VTD_INTSET)
     home.notice(*this,AP_DISPOSE);
   x.subscribe(home,*this,PC_INT_DOM);
   subscribe(home,*this,y);
   z.subscribe(home,*this,PC_INT_BND);
 }
Beispiel #3
0
 forceinline size_t
 IntBase<VX,VY>::dispose(Space& home) {
   if (vtd(y) == VTD_INTSET)
     home.ignore(*this,AP_DISPOSE);
   for (int i=n_s; i--; )
     x[i].cancel(home,*this,PC_INT_DOM);
   cancel(home,*this,y);
   (void) Propagator::dispose(home);
   return sizeof(*this);
 }
Beispiel #4
0
 forceinline
 IntBase<VX,VY>::IntBase(Home home,
                         ViewArray<VX>& x0, int n_s0, VY y0, int c0)
   : Propagator(home), x(x0), n_s(n_s0), y(y0), c(c0) {
   if (vtd(y) == VTD_INTSET)
     home.notice(*this,AP_DISPOSE);
   for (int i=n_s; i--; )
     x[i].subscribe(home,*this,PC_INT_DOM);
   subscribe(home,*this,y);
 }
Beispiel #5
0
  ExecStatus
  EqView<VX,VY,VZ,shr,dom>::propagate(Space& home, const ModEventDelta&) {
    count(home);

    GECODE_ME_CHECK(z.gq(home,atleast()));
    GECODE_ME_CHECK(z.lq(home,atmost()));

    if (z.assigned()) {
      if (z.val() == atleast()) {
        GECODE_ES_CHECK(post_false(home,x,y));
        return home.ES_SUBSUMED(*this);
      }
      if (z.val() == atmost()) {
        GECODE_ES_CHECK(post_true(home,x,y));
        return home.ES_SUBSUMED(*this);
      }
      if (!dom || (vtd(y) != VTD_VARVIEW)) {
        VY yc(y);
        GECODE_REWRITE(*this,(EqInt<VX,VY>
                              ::post(home(*this),x,yc,z.val()+c)));    
      }
    }


    if (dom && (vtd(y) == VTD_VARVIEW) && (z.min() > 0)) {
      /* 
       * Only if the propagator is at fixpoint here, continue
       * when things are shared: the reason is that prune
       * requires that the views in x overlap with y!
       */
      if (shr && (VX::me(Propagator::modeventdelta()) != ME_INT_NONE))
        return ES_NOFIX;

      GECODE_ES_CHECK(prune(home,x,y));

      return ES_NOFIX;
    }
    
    return shr ? ES_NOFIX : ES_FIX;
  }
Beispiel #6
0
 ExecStatus
 EqView<VX,VY,VZ,shr,dom>::post(Home home,
                            ViewArray<VX>& x, VY y, VZ z, int c) {
   GECODE_ME_CHECK(z.gq(home,-c));
   GECODE_ME_CHECK(z.lq(home,x.size()-c));
   if ((vtd(y) != VTD_VARVIEW) && z.assigned())
     return EqInt<VX,VY>::post(home,x,y,z.val()+c);
   if (sharing(x,y,z))
     (void) new (home) EqView<VX,VY,VZ,true,dom>(home,x,y,z,c);
   else
     (void) new (home) EqView<VX,VY,VZ,false,dom>(home,x,y,z,c);
   return ES_OK;
 }