Exemplo n.º 1
0
 @Override
 public void propagateOnRequest(IRequest<V> request, int idxVarInProp, int mask)
     throws ContradictionException {
   super.propagateOnRequest(request, idxVarInProp, mask);
   if (k.instantiated()) {
     if (nbInKer.get() == nbInEnv.get()) {
       setPassive();
     } else {
       IActiveNodes env = g.getEnvelopGraph().getActiveNodes();
       INeighbors nei;
       if (nbInEnv.get() == k.getValue()) {
         for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
           nei = g.getEnvelopGraph().getSuccessorsOf(i);
           for (int j = nei.getFirstElement(); j >= 0; j = nei.getNextElement()) {
             g.enforceArc(i, j, this, false);
           }
         }
         setPassive();
       } else if (nbInKer.get() == k.getValue()) {
         INeighbors kernei;
         for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
           nei = g.getEnvelopGraph().getSuccessorsOf(i);
           kernei = g.getKernelGraph().getSuccessorsOf(i);
           for (int j = nei.getFirstElement(); j >= 0; j = nei.getNextElement()) {
             if (!kernei.contain(j)) {
               g.removeArc(i, j, this, false);
             }
           }
         }
         setPassive();
       }
     }
   }
 }
Exemplo n.º 2
0
 @Override
 public void propagate() throws ContradictionException {
   int min = 0;
   int max = 0;
   IActiveNodes ker = g.getKernelGraph().getActiveNodes();
   IActiveNodes env = g.getEnvelopGraph().getActiveNodes();
   INeighbors nei;
   for (int i = ker.getFirstElement(); i >= 0; i = ker.getNextElement()) {
     min += g.getKernelGraph().getSuccessorsOf(i).neighborhoodSize();
   }
   for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
     max += g.getEnvelopGraph().getSuccessorsOf(i).neighborhoodSize();
   }
   k.updateLowerBound(min, this, false);
   k.updateUpperBound(max, this, false);
   nbInEnv.set(max);
   nbInKer.set(min);
   if (k.instantiated()) {
     if (min == max) {
       setPassive();
     } else {
       if (max == k.getValue()) {
         for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
           nei = g.getEnvelopGraph().getSuccessorsOf(i);
           for (int j = nei.getFirstElement(); j >= 0; j = nei.getNextElement()) {
             g.enforceArc(i, j, this, false);
           }
         }
         setPassive();
       } else if (min == k.getValue()) {
         INeighbors kernei;
         for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
           nei = g.getEnvelopGraph().getSuccessorsOf(i);
           kernei = g.getKernelGraph().getSuccessorsOf(i);
           for (int j = nei.getFirstElement(); j >= 0; j = nei.getNextElement()) {
             if (!kernei.contain(j)) {
               g.removeArc(i, j, this, false);
             }
           }
         }
         setPassive();
       }
     }
   }
 }
Exemplo n.º 3
0
 @Override
 public ESat isEntailed() {
   int min = 0;
   int max = 0;
   IActiveNodes ker = g.getKernelGraph().getActiveNodes();
   IActiveNodes env = g.getEnvelopGraph().getActiveNodes();
   for (int i = ker.getFirstElement(); i >= 0; i = ker.getNextElement()) {
     min += g.getKernelGraph().getSuccessorsOf(i).neighborhoodSize();
   }
   for (int i = env.getFirstElement(); i >= 0; i = env.getNextElement()) {
     max += g.getEnvelopGraph().getSuccessorsOf(i).neighborhoodSize();
   }
   if (k.getLB() > max || k.getUB() < min) {
     return ESat.FALSE;
   }
   if (min != max || !k.instantiated()) {
     return ESat.UNDEFINED;
   }
   return ESat.TRUE;
 }