Ejemplo n.º 1
0
 @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)) ;
 }
Ejemplo n.º 2
0
 @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();
     }
   }
 }
Ejemplo n.º 3
0
 @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;
         }
       }
     }
   }
 }
Ejemplo n.º 4
0
 /** In case of a EQ, due to a modification of the lower bound of v0 */
 public void filterOnInf(IntVar v0, IntVar v1) throws ContradictionException {
   if (v1.hasEnumeratedDomain()) {
     int end = v0.getLB() + cste;
     for (int val = v0.getLB(); val <= end; val = v1.nextValue(val)) {
       if (!v0.contains(val - cste) && !v0.contains(val + cste)) {
         v1.removeValue(val, this);
       }
     }
   } else {
     v1.updateLowerBound(v0.getLB() - cste, this);
   }
 }
 @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);
     }
   }
 }
Ejemplo n.º 6
0
 @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);
   }
 }