本文整理汇总了C++中XorClause::size方法的典型用法代码示例。如果您正苦于以下问题:C++ XorClause::size方法的具体用法?C++ XorClause::size怎么用?C++ XorClause::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XorClause
的用法示例。
在下文中一共展示了XorClause::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findSubsumed
void XorSubsumer::findSubsumed(XorClause& ps, vec<XorClauseSimp>& out_subsumed)
{
#ifdef VERBOSE_DEBUGSUBSUME0
cout << "findSubsumed: ";
for (uint32_t i = 0; i < ps.size(); i++) {
if (ps[i].sign()) printf("-");
printf("%d ", ps[i].var() + 1);
}
printf("0\n");
#endif
uint32_t min_i = 0;
for (uint32_t i = 1; i < ps.size(); i++) {
if (occur[ps[i].var()].size() < occur[ps[min_i].var()].size())
min_i = i;
}
vec<XorClauseSimp>& cs = occur[ps[min_i].var()];
for (XorClauseSimp *it = cs.getData(), *end = it + cs.size(); it != end; it++) {
if (it+1 != end) __builtin_prefetch((it+1)->clause);
if (it->clause != &ps && subsetAbst(ps.getAbst(), it->clause->getAbst()) && ps.size() <= it->clause->size() && subset(ps, *it->clause)) {
out_subsumed.push(*it);
#ifdef VERBOSE_DEBUGSUBSUME0
cout << "subsumed: ";
it->clause->plainPrint();
#endif
}
}
}
示例2: handleUpdatedClause
/**
@brief Helper function for replace_set()
*/
bool VarReplacer::handleUpdatedClause(XorClause& c, const Var origVar1, const Var origVar2)
{
uint32_t origSize = c.size();
std::sort(c.getData(), c.getDataEnd());
Lit p;
uint32_t i, j;
for (i = j = 0, p = lit_Undef; i != c.size(); i++) {
if (c[i].var() == p.var()) {
//added, but easily removed
j--;
p = lit_Undef;
if (!solver.assigns[c[i].var()].isUndef())
c.invert(solver.assigns[c[i].var()].getBool());
} else if (solver.assigns[c[i].var()].isUndef()) //just add
c[j++] = p = c[i];
else c.invert(solver.assigns[c[i].var()].getBool()); //modify xorEqualFalse instead of adding
}
c.shrink(i - j);
//Even if i==j, the clause *has* changed
c.setChanged();
#ifdef VERBOSE_DEBUG
cout << "xor-clause after replacing: ";
c.plainPrint();
#endif
switch (c.size()) {
case 0:
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
if (!c.xorEqualFalse()) {
solver.ok = false;
}
return true;
case 1:
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
solver.uncheckedEnqueue(Lit(c[0].var(), c.xorEqualFalse()));
solver.ok = (solver.propagate<false>().isNULL());
return true;
case 2: {
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
c[0] = c[0].unsign() ^ c.xorEqualFalse();
c[1] = c[1].unsign();
addBinaryXorClause(c[0], c[1]);
return true;
}
default:
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
solver.attachClause(c);
return false;
}
assert(false);
return false;
}
示例3: return
inline const bool MatrixFinder::firstPartOfSecond(const XorClause& c1, const XorClause& c2) const
{
uint32_t i1, i2;
for (i1 = 0, i2 = 0; i1 < c1.size() && i2 < c2.size();) {
if (c1[i1].var() != c2[i2].var())
i2++;
else {
i1++;
i2++;
}
}
return (i1 == c1.size());
}
示例4: cleanClause
inline bool ClauseCleaner::cleanClause(XorClause& c)
{
Lit* i, *j, *end;
Var origVar1 = c[0].var();
Var origVar2 = c[1].var();
uint32_t origSize = c.size();
for (i = j = c.getData(), end = i + c.size(); i != end; i++)
{
const lbool& val = solver.assigns[i->var()];
if (val.isUndef())
{
*j = *i;
j++;
}
else
c.invert(val.getBool());
}
c.shrink(i - j);
assert(c.size() != 1);
switch (c.size())
{
case 0:
{
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
return true;
}
case 2:
{
c[0] = c[0].unsign();
c[1] = c[1].unsign();
solver.varReplacer->replace(c, c.xor_clause_inverted(), c.getGroup());
solver.detachModifiedClause(origVar1, origVar2, origSize, &c);
return true;
}
default:
{
if (i - j > 0)
{
c.setStrenghtened();
solver.clauses_literals -= i - j;
}
return false;
}
}
assert(false);
return false;
}
示例5: getTwoLongXor
/**
@brief Returns the 2-long xor clause that has been made of the longer xor-clause under current assignement
We KNOW that the xorclause "c" passed as a parameter must be 2-long. We just
need it so that we can work with it. We KNOW it's 2-long because of the
data structures and functions in place
@p[in] c MUST be a 2-long xor clause under current assignement
*/
FailedLitSearcher::TwoLongXor FailedLitSearcher::getTwoLongXor(const XorClause& c) {
TwoLongXor tmp;
uint32_t num = 0;
tmp.inverted = c.xorEqualFalse();
for (const Lit *l = c.getData(), *end = l + c.size(); l != end; l++) {
if (solver.assigns[l->var()] == l_Undef) {
assert(num < 2);
tmp.var[num] = l->var();
num++;
} else {
tmp.inverted ^= (solver.assigns[l->var()] == l_True);
}
}
#ifdef VERBOSE_DEUBUG
if (num != 2) {
std::cout << "Num:" << num << std::endl;
c.plainPrint();
}
#endif
std::sort(&tmp.var[0], &tmp.var[0] + 2);
assert(num == 2);
return tmp;
}
示例6:
inline const Var MatrixFinder::fingerprint(const XorClause& c) const
{
Var fingerprint = 0;
for (const Lit* a = &c[0], *end = a + c.size(); a != end; a++)
fingerprint |= a->var();
return fingerprint;
}
示例7: linkInClause
XorClauseSimp XorSubsumer::linkInClause(XorClause& cl)
{
XorClauseSimp c(&cl, clauseID++);
clauses.push(c);
for (uint32_t i = 0; i < cl.size(); i++) {
occur[cl[i].var()].push(c);
}
return c;
}
示例8: addAllXorAsNorm
/**
@brief Utility function for addAllXorAsNorm() for converting 3-long xor clauses to normal clauses
\todo clean this up, it's ugly
*/
void XorFinder::addXorAsNormal3(XorClause& c)
{
assert(c.size() == 3);
Clause *tmp;
vec<Var> vars;
const bool inverted = c.xorEqualFalse();
for (uint32_t i = 0; i < c.size(); i++) {
vars.push(c[i].var());
}
vec<Lit> vars2;
vars2.growTo(3);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
tmp = solver.addClauseInt(vars2);
if (tmp) solver.clauses.push(tmp);
vars2.growTo(3);
vars2[0] = Lit(vars[0], true ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
tmp = solver.addClauseInt(vars2);
if (tmp) solver.clauses.push(tmp);
vars2.growTo(3);
vars2[0] = Lit(vars[0], true ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
tmp = solver.addClauseInt(vars2);
if (tmp) solver.clauses.push(tmp);
vars2.growTo(3);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
tmp = solver.addClauseInt(vars2);
if (tmp) solver.clauses.push(tmp);
}
示例9: findSubsumed
// Will put NULL in 'cs' if clause removed.
void XorSubsumer::subsume0(XorClauseSimp ps)
{
#ifdef VERBOSE_DEBUGSUBSUME0
cout << "subsume0 orig clause:";
ps.clause->plainPrint();
#endif
vec<Lit> unmatchedPart;
vec<XorClauseSimp> subs;
findSubsumed(*ps.clause, subs);
for (uint32_t i = 0; i < subs.size(); i++){
XorClause* tmp = subs[i].clause;
findUnMatched(*ps.clause, *tmp, unmatchedPart);
if (unmatchedPart.size() == 0) {
#ifdef VERBOSE_DEBUGSUBSUME0
cout << "subsume0 removing:";
subs[i].clause->plainPrint();
#endif
clauses_subsumed++;
assert(tmp->size() == ps.clause->size());
if (ps.clause->xor_clause_inverted() == tmp->xor_clause_inverted()) {
unlinkClause(subs[i]);
solver.clauseAllocator.clauseFree(tmp);
} else {
solver.ok = false;
return;
}
} else {
assert(unmatchedPart.size() > 0);
clauses_cut++;
#ifdef VERBOSE_DEBUG
std::cout << "Cutting xor-clause:";
subs[i].clause->plainPrint();
#endif //VERBOSE_DEBUG
XorClause *c = solver.addXorClauseInt(unmatchedPart, tmp->xor_clause_inverted() ^ !ps.clause->xor_clause_inverted(), tmp->getGroup());
if (c != NULL)
linkInClause(*c);
unlinkClause(subs[i]);
if (!solver.ok) return;
}
unmatchedPart.clear();
}
}
示例10: assert
void XorFinder::addXorAsNormal4(XorClause& c)
{
assert(c.size() == 4);
Clause *tmp;
vec<Var> vars;
vec<Lit> vars2(c.size());
const bool inverted = !c.xor_clause_inverted();
for (uint32_t i = 0; i < c.size(); i++) {
vars.push(c[i].var());
}
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
vars2[3] = Lit(vars[3], true ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
vars2[3] = Lit(vars[3], false ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
vars2[3] = Lit(vars[3], false ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
vars2[3] = Lit(vars[3], true ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], false ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
vars2[3] = Lit(vars[3], true ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], true ^ inverted);
vars2[1] = Lit(vars[1], false ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
vars2[3] = Lit(vars[3], true ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], true ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], false ^ inverted);
vars2[3] = Lit(vars[3], true ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
vars2[0] = Lit(vars[0], true ^ inverted);
vars2[1] = Lit(vars[1], true ^ inverted);
vars2[2] = Lit(vars[2], true ^ inverted);
vars2[3] = Lit(vars[3], false ^ inverted);
tmp = solver.addClauseInt(vars2, c.getGroup());
if (tmp) solver.clauses.push(tmp);
}