예제 #1
0
파일: MaxView.java 프로젝트: d3alek/Galak
 @Override
 public boolean removeValue(int value, ICause cause, boolean informCause)
     throws ContradictionException {
   ICause antipromo = cause;
   if (informCause) {
     cause = Cause.Null;
   }
   int inf = getLB();
   int sup = getUB();
   if (value == inf && value == sup) {
     this.contradiction(cause, AbstractVariable.MSG_REMOVE);
   } else if (inf == value || value == sup) {
     EventType e;
     if (value == inf) {
       // todo: delta...
       LB.set(value + 1);
       e = EventType.INCLOW;
       if (cause.reactOnPromotion()) {
         cause = Cause.Null;
       }
       if (A.getLB() > B.getUB()) {
         A.updateLowerBound(value + 1, this, false);
       }
       if (B.getLB() > A.getUB()) {
         B.updateLowerBound(value + 1, this, false);
       }
     } else {
       // todo: delta...
       UB.set(value - 1);
       e = EventType.DECUPP;
       if (cause.reactOnPromotion()) {
         cause = Cause.Null;
       }
       A.updateUpperBound(value - 1, this, false);
       B.updateUpperBound(value - 1, this, false);
     }
     if (SIZE.get() > 0) {
       if (this.instantiated()) {
         e = EventType.INSTANTIATE;
         if (cause.reactOnPromotion()) {
           cause = Cause.Null;
         }
       }
       this.notifyPropagators(e, cause);
     } else if (SIZE.get() == 0) {
       this.contradiction(cause, MSG_EMPTY);
     }
     return true;
   }
   return false;
 }
예제 #2
0
파일: MaxView.java 프로젝트: d3alek/Galak
  @Override
  public boolean updateLowerBound(int aValue, ICause cause, boolean informCause)
      throws ContradictionException {
    ICause antipromo = cause;
    if (informCause) {
      cause = Cause.Null;
    }
    int old = this.getLB();
    if (old < aValue) {
      if (this.getUB() < aValue) {
        this.contradiction(cause, MSG_LOW);
      } else {
        EventType e = EventType.INCLOW;
        // todo delta
        SIZE.add(old - aValue);
        LB.set(aValue);

        if (A.getLB() > B.getUB()) {
          A.updateLowerBound(aValue, this, false);
        }
        if (B.getLB() > A.getUB()) {
          B.updateLowerBound(aValue, this, false);
        }

        if (instantiated()) {
          e = EventType.INSTANTIATE;
          if (cause.reactOnPromotion()) {
            cause = Cause.Null;
          }
        }
        this.notifyPropagators(e, cause);
        return true;
      }
    }
    return false;
  }