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); } } } }
@Override public void propagate(int vidx, int evtmask) throws ContradictionException { if (vidx != nb_vars && poss.contains(vidx)) { IntVar var = vars[vidx]; int nb = 0; for (int j : values) { if (var.contains(j)) { nb++; } } if (nb == var.getDomainSize()) { nbSure.add(1); poss.remove(vidx); vars[nb_vars].updateLowerBound(nbSure.get(), this); } else if (nb == 0) { poss.remove(vidx); vars[nb_vars].updateUpperBound(poss.size() + nbSure.get(), this); } } forcePropagate(PropagatorEventType.CUSTOM_PROPAGATION); }