本文整理汇总了C++中XorClause::plainPrint方法的典型用法代码示例。如果您正苦于以下问题:C++ XorClause::plainPrint方法的具体用法?C++ XorClause::plainPrint怎么用?C++ XorClause::plainPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XorClause
的用法示例。
在下文中一共展示了XorClause::plainPrint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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: removeDependent
const bool XorSubsumer::removeDependent()
{
for (Var var = 0; var < occur.size(); var++) {
if (cannot_eliminate[var] || !solver.decision_var[var] || solver.assigns[var] != l_Undef) continue;
vec<XorClauseSimp>& occ = occur[var];
if (occ.size() == 1) {
#ifdef VERBOSE_DEBUG
std::cout << "Eliminating dependent var " << var + 1 << std::endl;
std::cout << "-> Removing dependent clause ";
occ[0].clause->plainPrint();
#endif //VERBOSE_DEBUG
unlinkClause(occ[0], var);
solver.setDecisionVar(var, false);
var_elimed[var] = true;
numElimed++;
} else if (occ.size() == 2) {
vec<Lit> lits;
XorClause& c1 = *(occ[0].clause);
lits.growTo(c1.size());
std::copy(c1.getData(), c1.getDataEnd(), lits.getData());
bool inverted = c1.xorEqualFalse();
XorClause& c2 = *(occ[1].clause);
lits.growTo(lits.size() + c2.size());
std::copy(c2.getData(), c2.getDataEnd(), lits.getData() + c1.size());
inverted ^= !c2.xorEqualFalse();
uint32_t group = c2.getGroup();
uint32_t ret = removeAll(lits, var);
release_assert(ret == 2);
#ifdef VERBOSE_DEBUG
std::cout << "Eliminating var " << var + 1 << " present in 2 xor-clauses" << std::endl;
std::cout << "-> Removing xor clause ";
occ[0].clause->plainPrint();
std::cout << "-> Removing xor clause ";
occ[1].clause->plainPrint();
#endif //VERBOSE_DEBUG
XorClauseSimp toUnlink0 = occ[0];
XorClauseSimp toUnlink1 = occ[1];
unlinkClause(toUnlink0);
unlinkClause(toUnlink1, var);
solver.setDecisionVar(var, false);
var_elimed[var] = true;
numElimed++;
for (uint32_t i = 0; i < lits.size(); i++)
cannot_eliminate[lits[i].var()] = true;
XorClause* c = solver.addXorClauseInt(lits, inverted, group);
#ifdef VERBOSE_DEBUG
if (c != NULL) {
std::cout << "-> Added combined xor clause:";
c->plainPrint();
} else
std::cout << "-> Combined xor clause is NULL" << std::endl;
#endif
if (c != NULL) linkInClause(*c);
if (!solver.ok) {
#ifdef VERBOSE_DEBUG
std::cout << "solver.ok is false after var-elim through xor" << std::endl;
#endif //VERBOSE_DEBUG
return false;
}
}
}
return true;
}
示例4: findXors
bool XorFinder::findXors(uint& sumLengths)
{
#ifdef VERBOSE_DEBUG
cout << "Finding Xors started" << endl;
#endif
sumLengths = 0;
ClauseTable::iterator begin = table.begin();
ClauseTable::iterator end = table.begin();
vec<Lit> lits;
bool impair;
while (getNextXor(begin, end, impair)) {
const Clause& c = *(begin->first);
lits.clear();
for (const Lit *it = &c[0], *cend = it+c.size() ; it != cend; it++) {
lits.push(Lit(it->var(), false));
}
uint old_group = c.getGroup();
#ifdef VERBOSE_DEBUG
cout << "- Found clauses:" << endl;
#endif
for (ClauseTable::iterator it = begin; it != end; it++)
if (impairSigns(*it->first) == impair){
#ifdef VERBOSE_DEBUG
it->first->plainPrint();
#endif
toRemove[it->second] = true;
solver.removeClause(*it->first);
}
switch(lits.size()) {
case 2: {
solver.varReplacer->replace(lits, impair, old_group);
#ifdef VERBOSE_DEBUG
XorClause* x = XorClause_new(lits, impair, old_group);
cout << "- Final 2-long xor-clause: ";
x->plainPrint();
clauseFree(x);
#endif
break;
}
default: {
XorClause* x = solver.clauseAllocator.XorClause_new(lits, impair, old_group);
solver.xorclauses.push(x);
solver.attachClause(*x);
#ifdef VERBOSE_DEBUG
cout << "- Final xor-clause: ";
x->plainPrint();
#endif
}
}
foundXors++;
sumLengths += lits.size();
}
return solver.ok;
}