/** * Main filtering algorithm: TODO 2) Implement filtering procedure of PropKCC (see isEntail) * * @param evtmask (useless for the exam) * @throws ContradictionException (when a fail occurs) */ public void propagate(int evtmask) throws ContradictionException { for (int i = 0; i < n; i++) { g.getNeighborsOf(i).clear(); } for (int i = 0; i < n; i++) { for (int j = succs[i].getLB(); j <= succs[i].getUB(); j = succs[i].nextValue(j)) { g.addEdge(i, j); } } ccf.findAllCC(); nb.updateLowerBound(ccf.getNBCC(), aCause); for (int i = 0; i < n; i++) { g.getNeighborsOf(i).clear(); } for (int i = 0; i < n; i++) { if (succs[i].instantiated()) { g.addEdge(i, succs[i].getValue()); } } ccf.findAllCC(); nb.updateUpperBound(ccf.getNBCC(), aCause); }
/** * Entailment checker * * @return ESat.FALSE if the propagator is violated ESat.TRUE if the propagator is satisfied for * sure, no matter what happens next ESat.UNDEFINED otherwise */ public ESat isEntailed() { // estimates the minimum number of cc of the solution by // computing cc of the graph induced by variable domains for (int i = 0; i < n; i++) { g.getNeighborsOf(i).clear(); } for (int i = 0; i < n; i++) { for (int j = succs[i].getLB(); j <= succs[i].getUB(); j = succs[i].nextValue(j)) { g.addEdge(i, j); } } ccf.findAllCC(); if (nb.getUB() < ccf.getNBCC()) { // too many CC return ESat.FALSE; } // estimates the maximum number of cc of the solution by // computing cc of the graph induced by instantiated variable values for (int i = 0; i < n; i++) { g.getNeighborsOf(i).clear(); } for (int i = 0; i < n; i++) { if (succs[i].instantiated()) { g.addEdge(i, succs[i].getValue()); } } ccf.findAllCC(); if (nb.getLB() > ccf.getNBCC()) { // not enough CC return ESat.FALSE; } // if all variables are instantiated then this propagator is entailed if (isCompletelyInstantiated()) { return ESat.TRUE; } else { return ESat.UNDEFINED; } }