diff --git a/packages/CLPBN/horus/LiftedCircuit.cpp b/packages/CLPBN/horus/LiftedCircuit.cpp index 1166f1e9d..d520a51a5 100644 --- a/packages/CLPBN/horus/LiftedCircuit.cpp +++ b/packages/CLPBN/horus/LiftedCircuit.cpp @@ -655,10 +655,8 @@ LiftedCircuit::isIndependentClause ( Clause& clause, Clauses& otherClauses) const { - // TODO consider counted log vars - TinySet lidSet = clause.lidSet(); for (size_t i = 0; i < otherClauses.size(); i++) { - if ((lidSet & otherClauses[i].lidSet()).empty() == false) { + if (Clause::independentClauses (clause, otherClauses[i]) == false) { return false; } } @@ -667,7 +665,6 @@ LiftedCircuit::isIndependentClause ( - LitLvTypesSet LiftedCircuit::smoothCircuit (CircuitNode* node) { diff --git a/packages/CLPBN/horus/LiftedWCNF.cpp b/packages/CLPBN/horus/LiftedWCNF.cpp index 6585947de..f9f47d155 100644 --- a/packages/CLPBN/horus/LiftedWCNF.cpp +++ b/packages/CLPBN/horus/LiftedWCNF.cpp @@ -288,6 +288,24 @@ Clause::removeLiteral (size_t litIdx) +bool +Clause::independentClauses (Clause& c1, Clause& c2) +{ + const Literals& lits1 = c1.literals(); + const Literals& lits2 = c2.literals(); + for (size_t i = 0; i < lits1.size(); i++) { + for (size_t j = 0; j < lits2.size(); j++) { + if (lits1[i].lid() == lits2[j].lid() + && c1.logVarTypes (i) == c2.logVarTypes (j)) { + return false; + } + } + } + return true; +} + + + void Clause::printClauses (const Clauses& clauses) { @@ -335,27 +353,11 @@ LiftedWCNF::LiftedWCNF (const ParfactorList& pfList) //addIndicatorClauses (pfList); //addParameterClauses (pfList); + /* vector> names = { -/* - {"p1","p1"}, - {"p1","p2"}, - {"p2","p1"}, - {"p2","p2"}, - {"p1","p3"}, - {"p2","p3"}, - {"p3","p3"}, - {"p3","p2"}, - {"p3","p1"} -*/ - {"p1","p1"}, - {"p1","p2"}, - {"p1","p3"}, - {"p2","p1"}, - {"p2","p2"}, - {"p2","p3"}, - {"p3","p1"}, - {"p3","p2"}, - {"p3","p3"} + {"p1","p1"},{"p1","p2"},{"p1","p3"}, + {"p2","p1"},{"p2","p2"},{"p2","p3"}, + {"p3","p1"},{"p3","p2"},{"p3","p3"} }; Clause c1 (names); @@ -372,6 +374,37 @@ LiftedWCNF::LiftedWCNF (const ParfactorList& pfList) addWeight (1, 2.0, 5.0); freeLiteralId_ = 2; + */ + + Literal lit1 (0, {0}); + Literal lit2 (1, {}); + Literal lit3 (2, {}); + Literal lit4 (3, {}); + + vector> names = {{"p1"},{"p2"}}; + Clause c1 (names); + c1.addLiteral (lit1); + c1.addLiteral (lit2); + c1.addPosCountedLogVar (0); + clauses_.push_back (c1); + + Clause c2 (names); + c2.addLiteral (lit1); + c2.addLiteral (lit3); + c2.addNegCountedLogVar (0); + clauses_.push_back (c2); + /* + Clause c3; + c3.addLiteral (lit3); + c3.addLiteral (lit4); + clauses_.push_back (c3); + + Clause c4; + c4.addLiteral (lit4); + c4.addLiteral (lit3); + clauses_.push_back (c4); + */ + freeLiteralId_ = 4; cout << "FORMULA INDICATORS:" << endl; // printFormulaIndicators(); diff --git a/packages/CLPBN/horus/LiftedWCNF.h b/packages/CLPBN/horus/LiftedWCNF.h index 5eb679168..fd236a80d 100644 --- a/packages/CLPBN/horus/LiftedWCNF.h +++ b/packages/CLPBN/horus/LiftedWCNF.h @@ -126,6 +126,8 @@ class Clause LogVarTypes logVarTypes (size_t litIdx) const; void removeLiteral (size_t litIdx); + + static bool independentClauses (Clause& c1, Clause& c2); static void printClauses (const vector& clauses);