/** @brief Helper function for replace_set() */ bool VarReplacer::handleUpdatedClause(Clause& c, const Lit origLit1, const Lit origLit2, const Lit origLit3) { bool satisfied = false; std::sort(c.getData(), c.getData() + c.size()); Lit p; uint32_t i, j; const uint32_t origSize = c.size(); for (i = j = 0, p = lit_Undef; i != origSize; i++) { if (solver.value(c[i]) == l_True || c[i] == ~p) { satisfied = true; break; } else if (solver.value(c[i]) != l_False && c[i] != p) c[j++] = p = c[i]; } c.shrink(i - j); c.setChanged(); solver.detachModifiedClause(origLit1, origLit2, origLit3, origSize, &c); #ifdef VERBOSE_DEBUG cout << "clause after replacing: "; c.plainPrint(); #endif if (satisfied) return true; switch(c.size()) { case 0: solver.ok = false; return true; case 1 : solver.uncheckedEnqueue(c[0]); solver.ok = (solver.propagate<false>().isNULL()); return true; case 2: solver.attachBinClause(c[0], c[1], c.learnt()); solver.numNewBin++; solver.dataSync->signalNewBinClause(c); return true; default: solver.attachClause(c); return false; } assert(false); return false; }
/** @brief Helper function for replace_set() */ const bool VarReplacer::handleUpdatedClause(Clause& c, const Lit origLit1, const Lit origLit2, const Lit origLit3) { bool satisfied = false; std::sort(c.getData(), c.getData() + c.size()); Lit p; uint32_t i, j; const uint32_t origSize = c.size(); for (i = j = 0, p = lit_Undef; i != origSize; i++) { if (solver.value(c[i]) == l_True || c[i] == ~p) { satisfied = true; break; } else if (solver.value(c[i]) != l_False && c[i] != p) c[j++] = p = c[i]; } c.shrink(i - j); c.setStrenghtened(); solver.detachModifiedClause(origLit1, origLit2, origLit3, origSize, &c); if (satisfied) return true; switch(c.size()) { case 0: solver.ok = false; return true; case 1 : solver.uncheckedEnqueue(c[0]); solver.ok = (solver.propagate().isNULL()); return true; default: solver.attachClause(c); return false; } assert(false); return false; }
/** @brief Helper function for replace_set() */ bool VarReplacer::handleUpdatedClause( Clause& c , const Lit origLit1 , const Lit origLit2 ) { bool satisfied = false; std::sort(c.begin(), c.end()); Lit p; uint32_t i, j; const uint32_t origSize = c.size(); for (i = j = 0, p = lit_Undef; i != origSize; i++) { assert(solver->varData[c[i].var()].removed == Removed::none); if (solver->value(c[i]) == l_True || c[i] == ~p) { satisfied = true; break; } else if (solver->value(c[i]) != l_False && c[i] != p) c[j++] = p = c[i]; } c.shrink(i - j); c.setChanged(); solver->detachModifiedClause(origLit1, origLit2, origSize, &c); #ifdef VERBOSE_DEBUG cout << "clause after replacing: " << c << endl; #endif if (satisfied) { (*solver->drup) << findelay; return true; } (*solver->drup) << c << fin << findelay; switch(c.size()) { case 0: solver->ok = false; return true; case 1 : solver->enqueue(c[0]); #ifdef STATS_NEEDED solver->propStats.propsUnit++; #endif solver->ok = (solver->propagate().isNULL()); runStats.removedLongLits += origSize; return true; case 2: solver->attachBinClause(c[0], c[1], c.red()); runStats.removedLongLits += origSize; return true; case 3: solver->attachTriClause(c[0], c[1], c[2], c.red()); runStats.removedLongLits += origSize; return true; default: solver->attachClause(c); runStats.removedLongLits += origSize - c.size(); return false; } assert(false); return false; }