Exemplo n.º 1
0
 @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);
 }
Exemplo n.º 2
0
 @Override
 public void propagate(int evtmask) throws ContradictionException {
   if (PropagatorEventType.isFullPropagation(evtmask)) {
     poss.clear();
     int nbMandForSure = 0;
     for (int i = 0; i < nb_vars; i++) {
       IntVar var = vars[i];
       int nb = 0;
       for (int j : values) {
         if (var.contains(j)) {
           nb++;
         }
       }
       if (nb == var.getDomainSize()) {
         nbMandForSure++;
       } else if (nb > 0) {
         poss.add(i);
       }
     }
     nbSure.set(nbMandForSure);
   }
   filter();
 }
Exemplo n.º 3
0
 @Override
 public ESat isEntailed() {
   int min = 0;
   int max = 0;
   int nbInst = vars[nb_vars].isInstantiated() ? 1 : 0;
   for (int i = 0; i < nb_vars; i++) {
     IntVar var = vars[i];
     if (var.isInstantiated()) {
       nbInst++;
       if (setValues.contains(var.getValue())) {
         min++;
         max++;
       }
     } else {
       int nb = 0;
       for (int j : values) {
         if (var.contains(j)) {
           nb++;
         }
       }
       if (nb == var.getDomainSize()) {
         min++;
         max++;
       } else if (nb > 0) {
         max++;
       }
     }
   }
   if (min > vars[nb_vars].getUB() || max < vars[nb_vars].getLB()) {
     return ESat.FALSE;
   }
   if (nbInst == nb_vars + 1) {
     return ESat.TRUE;
   }
   return ESat.UNDEFINED;
 }
Exemplo n.º 4
0
 @Override
 public double evaluate(IntVar variable) {
   return -variable.getDomainSize();
 }