本文整理汇总了C++中vec::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::getData方法的具体用法?C++ vec::getData怎么用?C++ vec::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanClauses
void ClauseCleaner::cleanClauses(vec<Clause*>& cs, ClauseSetType type, const uint32_t limit)
{
assert(solver.decisionLevel() == 0);
assert(solver.qhead == solver.trail.size());
if (lastNumUnitaryClean[type] + limit >= solver.get_unitary_learnts_num())
return;
#ifdef VERBOSE_DEBUG
std::cout << "Cleaning " << (type==binaryClauses ? "binaryClauses" : "normal clauses" ) << std::endl;
#endif //VERBOSE_DEBUG
Clause **s, **ss, **end;
for (s = ss = cs.getData(), end = s + cs.size(); s != end; s++) {
if (s+1 != end) __builtin_prefetch(*(s+1));
if (cleanClause(*s)) {
solver.clauseAllocator.clauseFree(*s);
} else {
*ss++ = *s;
}
}
cs.shrink(s-ss);
lastNumUnitaryClean[type] = solver.get_unitary_learnts_num();
#ifdef VERBOSE_DEBUG
cout << "cleanClauses(Clause) useful ?? Removed: " << s-ss << endl;
#endif
}
示例2: cleanClausesBewareNULL
void ClauseCleaner::cleanClausesBewareNULL(vec<ClauseSimp>& cs,
ClauseCleaner::ClauseSetType type,
Subsumer& subs, const unsigned limit)
{
assert(solver.decisionLevel() == 0);
assert(solver.qhead == solver.trail.size());
if (lastNumUnitaryClean[type] + limit >= solver.get_unitary_learnts_num())
return;
ClauseSimp* s, *end;
for (s = cs.getData(), end = s + cs.size(); s != end; s++)
{
if (s + 1 != end)
__builtin_prefetch((s + 1)->clause, 1, 0);
if (s->clause == NULL)
continue;
if (cleanClauseBewareNULL(*s, subs))
{
continue;
}
else if (s->clause->size() == 2)
solver.becameBinary++;
}
lastNumUnitaryClean[type] = solver.get_unitary_learnts_num();
}
示例3: updatePointers
void ClauseAllocator::updatePointers(vec<T*>& toUpdate, const map<Clause*, Clause*>& oldToNewPointer)
{
for (T **it = toUpdate.getData(), **end = toUpdate.getDataEnd(); it != end; it++) {
if (!(*it)->wasBin()) {
//assert(oldToNewPointer.find((TT*)*it) != oldToNewPointer.end());
map<Clause*, Clause*>::const_iterator it2 = oldToNewPointer.find((Clause*)*it);
*it = (T*)it2->second;
}
}
}
示例4: checkOnlyThisPart
bool PartHandler::checkOnlyThisPart(const vec<T*>& cs, const uint32_t part, const PartFinder& partFinder) const
{
for(T * const*it = cs.getData(), * const*end = it + cs.size(); it != end; it++) {
const T& c = **it;
for(const Lit *l = c.getData(), *end2 = l + c.size(); l != end2; l++) {
if (partFinder.getVarPart(l->var()) != part) return false;
}
}
return true;
}
示例5: addDegrees
void RestartTypeChooser::addDegrees(const vec<T*>& cs, vector<uint32_t>& degrees) const
{
for (T * const*c = cs.getData(), * const*end = c + cs.size(); c != end; c++) {
T& cl = **c;
if (cl.learnt()) continue;
for (const Lit *l = cl.getData(), *end2 = l + cl.size(); l != end2; l++) {
degrees[l->var()]++;
}
}
}
示例6: calcIn
void PartFinder::calcIn(const vec<T*>& cs, vector<uint>& numClauseInPart, vector<uint>& sumLitsInPart)
{
for (T*const* c = cs.getData(), *const*end = c + cs.size(); c != end; c++) {
if ((*c)->learnt()) continue;
T& x = **c;
const uint part = table[x[0].var()];
assert(part < part_no);
//for stats
numClauseInPart[part]++;
sumLitsInPart[part] += x.size();
}
}
示例7: addFromSolver
void XorSubsumer::addFromSolver(vec<XorClause*>& cs)
{
clauseID = 0;
clauses.clear();
XorClause **i = cs.getData();
for (XorClause **end = i + cs.size(); i != end; i++) {
if (i+1 != end) __builtin_prefetch(*(i+1));
linkInClause(**i);
}
cs.clear();
cs.push(NULL); //HACK --to force xor-propagation
}
示例8: replace_set
/**
@brief Replaces vars in xorclauses
*/
bool VarReplacer::replace_set(vec<XorClause*>& cs)
{
XorClause **a = cs.getData();
XorClause **r = a;
for (XorClause **end = a + cs.size(); r != end; r++) {
XorClause& c = **r;
bool changed = false;
Var origVar1 = c[0].var();
Var origVar2 = c[1].var();
for (Lit *l = &c[0], *end2 = l + c.size(); l != end2; l++) {
Lit newlit = table[l->var()];
if (newlit.var() != l->var()) {
changed = true;
*l = Lit(newlit.var(), false);
c.invert(newlit.sign());
replacedLits++;
}
}
if (changed && handleUpdatedClause(c, origVar1, origVar2)) {
if (!solver.ok) {
#ifdef VERBOSE_DEBUG
cout << "contradiction while replacing lits in xor clause" << std::endl;
#endif
for(;r != end; r++) solver.clauseAllocator.clauseFree(*r);
cs.shrink(r-a);
return false;
}
//solver.clauseAllocator.clauseFree(&c);
c.setRemoved();
solver.freeLater.push(&c);
} else {
#ifdef SILENT_DEBUG
uint32_t numUndef = 0;
for (uint32_t i = 0; i < c.size(); i++) {
if (solver.value(c[i]) == l_Undef) numUndef++;
}
assert(numUndef >= 2 || numUndef == 0);
#endif
*a++ = *r;
}
}
cs.shrink(r-a);
return solver.ok;
}
示例9: addFromSolver
void XorSubsumer::addFromSolver(vec<XorClause*>& cs)
{
clauseID = 0;
clauses.clear();
XorClause **i = cs.getData();
for (XorClause **end = i + cs.size(); i != end; i++) {
if (i+1 != end)
__builtin_prefetch(*(i+1), 1, 1);
linkInClause(**i);
if ((*i)->getVarChanged() || (*i)->getStrenghtened())
(*i)->calcXorAbstraction();
}
cs.clear();
cs.push(NULL); //HACK --to force xor-propagation
}
示例10: cleanClauses
void ClauseCleaner::cleanClauses(vec<XorClause*>& cs, ClauseSetType type,
const unsigned limit)
{
assert(solver.decisionLevel() == 0);
assert(solver.qhead == solver.trail.size());
if (lastNumUnitaryClean[type] + limit >= solver.get_unitary_learnts_num())
return;
XorClause** s, **ss, **end;
for (s = ss = cs.getData(), end = s + cs.size(); s != end; s++)
{
if (s + 1 != end)
__builtin_prefetch(*(s + 1), 1, 0);
#ifdef DEBUG_ATTACH
assert(find(solver.xorwatches[(**s)[0].var()], *s));
assert(find(solver.xorwatches[(**s)[1].var()], *s));
if (solver.assigns[(**s)[0].var()] != l_Undef ||
solver.assigns[(**s)[1].var()] != l_Undef)
{
satisfied(**s);
}
#endif // DEBUG_ATTACH
if (cleanClause(**s))
{
solver.freeLater.push(*s);
(*s)->setRemoved();
}
else
{
#ifdef DEBUG_ATTACH
assert(find(solver.xorwatches[(**s)[0].var()], *s));
assert(find(solver.xorwatches[(**s)[1].var()], *s));
#endif // DEBUG_ATTACH
*ss++ = *s;
}
}
cs.shrink(s - ss);
lastNumUnitaryClean[type] = solver.get_unitary_learnts_num();
#ifdef VERBOSE_DEBUG
cout << "cleanClauses(XorClause) useful: ?? Removed: " << s - ss << endl;
#endif
}
示例11: addFromSolver
/**
@brief Initialises datastructures for 2-long xor finding by shortening longer xors
*/
void FailedLitSearcher::addFromSolver(const vec< XorClause* >& cs) {
xorClauseSizes.clear();
xorClauseSizes.growTo(cs.size());
occur.resize(solver.nVars());
for (Var var = 0; var < solver.nVars(); var++) {
occur[var].clear();
}
uint32_t i = 0;
for (XorClause * const*it = cs.getData(), * const*end = it + cs.size(); it != end; it++, i++) {
if (it + 1 != end) __builtin_prefetch(*(it + 1));
const XorClause& cl = **it;
xorClauseSizes[i] = cl.size();
for (const Lit *l = cl.getData(), *end2 = l + cl.size(); l != end2; l++) {
occur[l->var()].push_back(i);
}
}
}
示例12: moveLearntClauses
void PartHandler::moveLearntClauses(vec<Clause*>& cs, Solver& newSolver, const uint32_t part, PartFinder& partFinder)
{
Clause **i, **j, **end;
for (i = j = cs.getData(), end = i + cs.size() ; i != end; i++) {
if (!(**i).learnt()) {
*j++ = *i;
continue;
}
Clause& c = **i;
assert(c.size() > 0);
uint32_t clause_part = partFinder.getVarPart(c[0].var());
bool removed = false;
for (const Lit* l = c.getData(), *end = l + c.size(); l != end; l++) {
if (partFinder.getVarPart(l->var()) != clause_part) {
#ifdef VERBOSE_DEBUG
std::cout << "Learnt clause in both parts:"; c.plainPrint();
#endif
removed = true;
solver.removeClause(c);
break;
}
}
if (removed) continue;
if (clause_part == part) {
#ifdef VERBOSE_DEBUG
//std::cout << "Learnt clause in this part:"; c.plainPrint();
#endif
solver.detachClause(c);
newSolver.addLearntClause(c, c.getGroup(), c.activity());
solver.clauseAllocator.clauseFree(&c);
} else {
#ifdef VERBOSE_DEBUG
std::cout << "Learnt clause in other part:"; c.plainPrint();
#endif
*j++ = *i;
}
}
cs.shrink(i-j);
}
示例13: syncBinFromOthers
const bool DataSync::syncBinFromOthers(const Lit lit, const vector<Lit>& bins, uint32_t& finished, vec<Watched>& ws)
{
assert(solver.varReplacer->getReplaceTable()[lit.var()].var() == lit.var());
assert(solver.subsumer->getVarElimed()[lit.var()] == false);
assert(solver.xorSubsumer->getVarElimed()[lit.var()] == false);
vec<Lit> addedToSeen;
for (vec<Watched>::iterator it = ws.getData(), end = ws.getDataEnd(); it != end; it++) {
if (it->isBinary()) {
addedToSeen.push(it->getOtherLit());
seen[it->getOtherLit().toInt()] = true;
}
}
vec<Lit> lits(2);
for (uint32_t i = finished; i < bins.size(); i++) {
if (!seen[bins[i].toInt()]) {
Lit otherLit = bins[i];
otherLit = solver.varReplacer->getReplaceTable()[otherLit.var()] ^ otherLit.sign();
if (solver.subsumer->getVarElimed()[otherLit.var()]
|| solver.xorSubsumer->getVarElimed()[otherLit.var()]
|| solver.value(otherLit.var()) != l_Undef
) continue;
recvBinData++;
lits[0] = lit;
lits[1] = otherLit;
solver.addClauseInt(lits, 0, true, 2, 0, true);
lits.clear();
lits.growTo(2);
if (!solver.ok) goto end;
}
}
finished = bins.size();
end:
for (uint32_t i = 0; i < addedToSeen.size(); i++)
seen[addedToSeen[i].toInt()] = false;
return solver.ok;
}
示例14: replace_set
/**
@brief Replaces variables in normal clauses
*/
const bool VarReplacer::replace_set(vec<Clause*>& cs, const bool binClauses)
{
Clause **a = cs.getData();
Clause **r = a;
for (Clause **end = a + cs.size(); r != end; r++) {
Clause& c = **r;
bool changed = false;
Lit origLit1 = c[0];
Lit origLit2 = c[1];
Lit origLit3 = (c.size() == 3) ? c[2] : lit_Undef;
for (Lit *l = c.getData(), *end2 = l + c.size(); l != end2; l++) {
if (table[l->var()].var() != l->var()) {
changed = true;
*l = table[l->var()] ^ l->sign();
replacedLits++;
}
}
if (changed && handleUpdatedClause(c, origLit1, origLit2, origLit3)) {
if (!solver.ok) {
for(;r != end; r++) solver.clauseAllocator.clauseFree(*r);
cs.shrink(r-a);
return false;
}
} else {
if (!binClauses && c.size() == 2) {
solver.detachClause(c);
Clause *c2 = solver.clauseAllocator.Clause_new(c);
solver.clauseAllocator.clauseFree(&c);
solver.attachClause(*c2);
solver.becameBinary++;
solver.binaryClauses.push(c2);
} else
*a++ = *r;
}
}
cs.shrink(r-a);
return solver.ok;
}
示例15: removeSatisfied
void ClauseCleaner::removeSatisfied(vec<Clause*>& cs, ClauseSetType type, const uint limit)
{
#ifdef DEBUG_CLEAN
assert(solver.decisionLevel() == 0);
#endif
if (lastNumUnitarySat[type] + limit >= solver.get_unitary_learnts_num())
return;
Clause **i,**j, **end;
for (i = j = cs.getData(), end = i + cs.size(); i != end; i++) {
if (i+1 != end)
__builtin_prefetch(*(i+1), 0, 0);
if (satisfied(**i))
solver.removeClause(**i);
else
*j++ = *i;
}
cs.shrink(i - j);
lastNumUnitarySat[type] = solver.get_unitary_learnts_num();
}