@SuppressWarnings("StatementWithEmptyBody") private void updateBounds() throws ContradictionException { while (x.updateLowerBound(y.getLB() + cste, aCause) | y.updateLowerBound(x.getLB() - cste, aCause)) ; while (x.updateUpperBound(y.getUB() + cste, aCause) | y.updateUpperBound(x.getUB() - cste, aCause)) ; }
@Override public void propagate(int evtmask) throws ContradictionException { int remainingCapacity = capacity.getUB(); int maxPower = 0; for (int i = 0; i < n; i++) { remainingCapacity -= weigth[i] * vars[i].getLB(); maxPower += energy[i] * vars[i].getLB(); } power.updateLowerBound(maxPower, this); if (remainingCapacity < 0) { fails(); } else { int idx; for (int i = 0; i < n; i++) { assert remainingCapacity >= 0; idx = order[i]; if (vars[idx].getUB() - vars[idx].getLB() > 0) { int delta = weigth[idx] * (vars[idx].getUB() - vars[idx].getLB()); if (delta <= remainingCapacity) { maxPower += energy[idx] * (vars[idx].getUB() - vars[idx].getLB()); remainingCapacity -= delta; if (remainingCapacity == 0) { power.updateUpperBound(maxPower, this); return; } } else { int deltaPow = (int) Math.ceil((double) remainingCapacity * ratio[idx]); power.updateUpperBound(maxPower + deltaPow, this); return; } } } } }
@Override public void propagate(int evtmask) throws ContradictionException { int min = 0; int max = 0; ISet nodes = g.getPotentialNodes(); for (int i = nodes.getFirstElement(); i >= 0; i = nodes.getNextElement()) { if (g.getMandSuccOrNeighOf(i).contain(i)) { min++; max++; } else if (g.getPotSuccOrNeighOf(i).contain(i)) { max++; } } k.updateLowerBound(min, aCause); k.updateUpperBound(max, aCause); if (min == max) { setPassive(); } else if (k.isInstantiated()) { if (k.getValue() == max) { for (int i = nodes.getFirstElement(); i >= 0; i = nodes.getNextElement()) { if (g.getPotSuccOrNeighOf(i).contain(i)) { g.enforceArc(i, i, aCause); } } setPassive(); } else if (k.getValue() == min) { for (int i = nodes.getFirstElement(); i >= 0; i = nodes.getNextElement()) { if (!g.getMandSuccOrNeighOf(i).contain(i)) { g.removeArc(i, i, aCause); } } setPassive(); } } }
@Override public void propagate(int evtmask) throws ContradictionException { for (int i = 0; i < n; i++) { IntVar intVar = intVars[i]; RealVar realVar = realVars[i]; realVar.updateBounds( (double) intVar.getLB() - epsilon, (double) intVar.getUB() + epsilon, aCause); intVar.updateLowerBound((int) Math.ceil(realVar.getLB() - epsilon), aCause); intVar.updateUpperBound((int) Math.floor(realVar.getUB() + epsilon), aCause); if (intVar.hasEnumeratedDomain()) { realVar.updateBounds( (double) intVar.getLB() - epsilon, (double) intVar.getUB() + epsilon, aCause); } } }
/** In case of a EQ, due to a modification of the upper bound of v0 */ public void filterOnSup(IntVar v0, IntVar v1) throws ContradictionException { if (v1.hasEnumeratedDomain()) { int initval; if (v0.getUB() - cste > v1.getLB()) { initval = v1.nextValue(v0.getUB() - cste - 1); } else { initval = v1.getLB(); } int val = initval; do { if (!v0.contains(val - cste) && !v0.contains(val + cste)) { v1.removeValue(val, this); } val = v1.nextValue(val); } while (val <= v1.getUB() && val > initval); // todo : pourquoi besoin du deuxieme currentElement ? } else { v1.updateUpperBound(v0.getUB() + cste, this); } }
@Override public void propagate(int evtmask) throws ContradictionException { for (int j = set.getKernelFirst(); j != SetVar.END; j = set.getKernelNext()) { min.updateUpperBound(get(j), this); } int minVal = Integer.MAX_VALUE; int lb = min.getLB(); for (int j = set.getEnvelopeFirst(); j != SetVar.END; j = set.getEnvelopeNext()) { int k = get(j); if (k < lb) { set.removeFromEnvelope(j, this); } else { if (minVal > k) { minVal = k; } } } if (notEmpty || set.getKernelSize() > 0) { min.updateLowerBound(minVal, this); } }