本文整理汇总了C++中XorClause::shrink方法的典型用法代码示例。如果您正苦于以下问题:C++ XorClause::shrink方法的具体用法?C++ XorClause::shrink怎么用?C++ XorClause::shrink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XorClause
的用法示例。
在下文中一共展示了XorClause::shrink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}