support printing LitLvTypes objects

This commit is contained in:
Tiago Gomes 2012-12-10 18:48:54 +00:00
parent 9c8827c309
commit a25f4584c8
2 changed files with 25 additions and 4 deletions

View File

@ -60,7 +60,8 @@ Literal::toString (
std::ostream& operator<< (ostream &os, const Literal& lit) std::ostream&
operator<< (ostream &os, const Literal& lit)
{ {
os << lit.toString(); os << lit.toString();
return os; return os;
@ -256,7 +257,7 @@ LogVarTypes
Clause::logVarTypes (size_t litIdx) const Clause::logVarTypes (size_t litIdx) const
{ {
LogVarTypes types; LogVarTypes types;
const LogVars lvs = literals_[litIdx].logVars(); const LogVars& lvs = literals_[litIdx].logVars();
for (size_t i = 0; i < lvs.size(); i++) { for (size_t i = 0; i < lvs.size(); i++) {
if (posCountedLvs_.contains (lvs[i])) { if (posCountedLvs_.contains (lvs[i])) {
types.push_back (LogVarType::POS_LV); types.push_back (LogVarType::POS_LV);
@ -326,7 +327,8 @@ Clause::printClauses (const Clauses& clauses)
std::ostream& operator<< (ostream &os, const Clause& clause) std::ostream&
operator<< (ostream &os, const Clause& clause)
{ {
for (unsigned i = 0; i < clause.literals_.size(); i++) { for (unsigned i = 0; i < clause.literals_.size(); i++) {
if (i != 0) os << " v " ; if (i != 0) os << " v " ;
@ -357,6 +359,23 @@ Clause::getLogVarSetExcluding (size_t idx) const
std::ostream&
operator<< (std::ostream &os, const LitLvTypes& lit)
{
os << lit.lid_ << "<" ;
for (size_t i = 0; i < lit.lvTypes_.size(); i++) {
switch (lit.lvTypes_[i]) {
case LogVarType::FULL_LV: os << "F" ; break;
case LogVarType::POS_LV: os << "P" ; break;
case LogVarType::NEG_LV: os << "N" ; break;
}
}
os << ">" ;
return os;
}
LiftedWCNF::LiftedWCNF (const ParfactorList& pfList) LiftedWCNF::LiftedWCNF (const ParfactorList& pfList)
: freeLiteralId_(0), pfList_(pfList) : freeLiteralId_(0), pfList_(pfList)
{ {
@ -494,7 +513,7 @@ LiftedWCNF::getLiteralId (PrvGroup prvGroup, unsigned range)
assert (Util::contains (map_, prvGroup)); assert (Util::contains (map_, prvGroup));
return map_[prvGroup][range]; return map_[prvGroup][range];
} }
void void

View File

@ -179,6 +179,8 @@ class LitLvTypes
void setAllFullLogVars (void) { void setAllFullLogVars (void) {
std::fill (lvTypes_.begin(), lvTypes_.end(), LogVarType::FULL_LV); } std::fill (lvTypes_.begin(), lvTypes_.end(), LogVarType::FULL_LV); }
friend std::ostream& operator<< (std::ostream &os, const LitLvTypes& lit);
private: private:
LiteralId lid_; LiteralId lid_;
LogVarTypes lvTypes_; LogVarTypes lvTypes_;