}
@Override
public void instantiateTo(IntVar var, int val, ICause cause, int oldLB, int oldUB) {
AntiDomain invdom = getRemovedValues(var);
if (invdom.isEnumerated()) {
for (int v = oldLB; v < val; v++) {
if (!invdom.get(v)) {
explainValueRemoval(var, v, cause);
invdom.add(v);
}
}
for (int v = oldUB; v > val; v--) {
if (!invdom.get(v)) {
explainValueRemoval(var, v, cause);
invdom.add(v);
}
}
} else {
if (val < oldLB) {
// domain wipe out
explainValueRemoval(var, oldLB, cause);
invdom.updateUpperBound(oldUB, oldLB - 1);
} else if (val > oldUB) {
// domain wipe out
explainValueRemoval(var, oldUB, cause);
invdom.updateLowerBound(oldLB, oldUB + 1);
} else {
if (val > oldLB && !invdom.get(val)) {
explainValueRemoval(var, val - 1, cause);
invdom.updateLowerBound(oldLB, val);
}
if (val < oldUB && !invdom.get(val)) {
explainValueRemoval(var, val + 1, cause);
invdom.updateUpperBound(oldUB, val);
}
}
}
}