Ejemplo n.º 1
0
 /** In case of a EQ, due to the instantion to one variable to val */
 public void filterOnInst(IntVar v, int val) throws ContradictionException {
   if (!v.contains(val + cste)) {
     v.instantiateTo(val - cste, this);
   } else if (!v.contains(val - cste)) {
     v.instantiateTo(val + cste, this);
   } else {
     if (v.hasEnumeratedDomain()) {
       DisposableRangeIterator rit = v.getRangeIterator(true);
       try {
         while (rit.hasNext()) {
           int from = rit.min();
           int to = rit.max();
           for (int value = from; value <= to; value++) {
             if (value != (val - cste) && value != (val + cste)) {
               v.removeValue(value, this);
             }
           }
           rit.next();
         }
       } finally {
         rit.dispose();
       }
     } else {
       v.updateBounds(val - cste, val + cste, this);
     }
   }
 }
Ejemplo n.º 2
0
 private void backPropRemPoss() throws ContradictionException {
   ISetIterator iter = poss.iterator();
   while (iter.hasNext()) {
     int i = iter.nextInt();
     IntVar v = vars[i];
     if (v.hasEnumeratedDomain()) {
       for (int value : values) {
         v.removeValue(value, this);
       }
       poss.remove(i);
     } else {
       int newLB = v.getLB();
       int newUB = v.getUB();
       for (int val = v.getLB(); val <= newUB; val = v.nextValue(val)) {
         if (setValues.contains(val)) {
           newLB = val + 1;
         } else {
           break;
         }
       }
       for (int val = newUB; val >= newLB; val = v.previousValue(val)) {
         if (setValues.contains(val)) {
           newUB = val - 1;
         } else {
           break;
         }
       }
       v.updateBounds(newLB, newUB, this);
       if (newLB > values[values.length - 1] || newUB < values[0]) {
         poss.remove(i);
       }
     }
   }
 }
Ejemplo n.º 3
0
 /** In case of a LT, due to a modification on v0 domain */
 public void filterLTonVar(IntVar v0, IntVar v1) throws ContradictionException {
   v1.updateBounds(v0.getLB() - cste + 1, v0.getUB() + cste - 1, this);
 }