コード例 #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
ファイル: BitsetXYSumView.java プロジェクト: d3alek/Galak
  @Override
  public boolean updateLowerBound(int value, ICause cause, boolean informCause)
      throws ContradictionException {
    ICause antipromo = cause;
    if (informCause) {
      cause = Cause.Null;
    }
    boolean change;
    int lb = this.getLB();
    if (lb < value) {
      if (this.getUB() < value) {
        this.contradiction(cause, MSG_LOW);
      } else {
        EventType e = EventType.INCLOW;

        int aValue = value - OFFSET;
        // todo delta
        VALUES.clear(lb - OFFSET, aValue);
        lb = VALUES.nextSetBit(aValue) + OFFSET;
        LB.set(lb);
        int _size = SIZE.get();
        int card = VALUES.cardinality();
        SIZE.set(card);
        change = _size - card > 0;

        filterOnGeq(cause, lb);

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

        return change;
      }
    }
    return false;
  }
コード例 #3
0
ファイル: BitsetXYSumView.java プロジェクト: d3alek/Galak
  @Override
  public boolean updateUpperBound(int value, ICause cause, boolean informCause)
      throws ContradictionException {
    ICause antipromo = cause;
    if (informCause) {
      cause = Cause.Null;
    }
    boolean change;
    int ub = this.getUB();
    if (ub > value) {
      if (this.getLB() > value) {
        this.contradiction(cause, MSG_UPP);
      } else {
        EventType e = EventType.DECUPP;
        int aValue = value - OFFSET;
        // todo delta
        VALUES.clear(aValue + 1, ub - OFFSET + 1);
        ub = VALUES.prevSetBit(aValue) + OFFSET;
        UB.set(ub);

        int _size = SIZE.get();
        int card = VALUES.cardinality();
        SIZE.set(card);
        change = _size - card > 0;

        filterOnLeq(cause, ub);

        if (card == 1) {
          e = EventType.INSTANTIATE;
          if (cause.reactOnPromotion()) {
            cause = Cause.Null;
          }
        }
        this.notifyPropagators(e, cause);
        return change;
      }
    }
    return false;
  }
コード例 #4
0
ファイル: BitsetXYSumView.java プロジェクト: d3alek/Galak
 @Override
 public int getDomainSize() {
   return SIZE.get();
 }