more work to support inference with lifted knowledge compilation
This commit is contained in:
@@ -25,15 +25,15 @@ class CircuitNode
|
||||
public:
|
||||
CircuitNode (const Clauses& clauses, string explanation = "")
|
||||
: clauses_(clauses), explanation_(explanation) { }
|
||||
|
||||
|
||||
const Clauses& clauses (void) const { return clauses_; }
|
||||
|
||||
|
||||
Clauses clauses (void) { return clauses_; }
|
||||
|
||||
|
||||
virtual double weight (void) const = 0;
|
||||
|
||||
|
||||
string explanation (void) const { return explanation_; }
|
||||
|
||||
|
||||
private:
|
||||
Clauses clauses_;
|
||||
string explanation_;
|
||||
@@ -50,7 +50,7 @@ class OrNode : public CircuitNode
|
||||
|
||||
CircuitNode** leftBranch (void) { return &leftBranch_; }
|
||||
CircuitNode** rightBranch (void) { return &rightBranch_; }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
private:
|
||||
@@ -66,7 +66,7 @@ class AndNode : public CircuitNode
|
||||
AndNode (const Clauses& clauses, string explanation = "")
|
||||
: CircuitNode (clauses, explanation),
|
||||
leftBranch_(0), rightBranch_(0) { }
|
||||
|
||||
|
||||
AndNode (
|
||||
const Clauses& clauses,
|
||||
CircuitNode* leftBranch,
|
||||
@@ -74,7 +74,7 @@ class AndNode : public CircuitNode
|
||||
string explanation = "")
|
||||
: CircuitNode (clauses, explanation),
|
||||
leftBranch_(leftBranch), rightBranch_(rightBranch) { }
|
||||
|
||||
|
||||
AndNode (
|
||||
CircuitNode* leftBranch,
|
||||
CircuitNode* rightBranch,
|
||||
@@ -84,9 +84,9 @@ class AndNode : public CircuitNode
|
||||
|
||||
CircuitNode** leftBranch (void) { return &leftBranch_; }
|
||||
CircuitNode** rightBranch (void) { return &rightBranch_; }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
|
||||
private:
|
||||
CircuitNode* leftBranch_;
|
||||
CircuitNode* rightBranch_;
|
||||
@@ -106,7 +106,7 @@ class SetOrNode : public CircuitNode
|
||||
static unsigned nrPositives (void) { return nrGrsStack.top().first; }
|
||||
|
||||
static unsigned nrNegatives (void) { return nrGrsStack.top().second; }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
private:
|
||||
@@ -126,7 +126,7 @@ class SetAndNode : public CircuitNode
|
||||
nrGroundings_(nrGroundings) { }
|
||||
|
||||
CircuitNode** follow (void) { return &follow_; }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
private:
|
||||
@@ -146,7 +146,7 @@ class IncExcNode : public CircuitNode
|
||||
CircuitNode** plus1Branch (void) { return &plus1Branch_; }
|
||||
CircuitNode** plus2Branch (void) { return &plus2Branch_; }
|
||||
CircuitNode** minusBranch (void) { return &minusBranch_; }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
private:
|
||||
@@ -164,7 +164,7 @@ class LeafNode : public CircuitNode
|
||||
: CircuitNode (Clauses() = {clause}), lwcnf_(lwcnf) { }
|
||||
|
||||
double weight (void) const;
|
||||
|
||||
|
||||
private:
|
||||
const LiftedWCNF& lwcnf_;
|
||||
};
|
||||
@@ -189,7 +189,7 @@ class TrueNode : public CircuitNode
|
||||
{
|
||||
public:
|
||||
TrueNode (void) : CircuitNode ({}) { }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
};
|
||||
|
||||
@@ -200,7 +200,7 @@ class CompilationFailedNode : public CircuitNode
|
||||
public:
|
||||
CompilationFailedNode (const Clauses& clauses)
|
||||
: CircuitNode (clauses) { }
|
||||
|
||||
|
||||
double weight (void) const;
|
||||
};
|
||||
|
||||
@@ -210,62 +210,60 @@ class LiftedCircuit
|
||||
{
|
||||
public:
|
||||
LiftedCircuit (const LiftedWCNF* lwcnf);
|
||||
|
||||
void smoothCircuit (void);
|
||||
|
||||
|
||||
double getWeightedModelCount (void) const;
|
||||
|
||||
|
||||
void exportToGraphViz (const char*);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void compile (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
bool tryUnitPropagation (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryIndependence (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryShannonDecomp (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryInclusionExclusion (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryIndepPartialGrounding (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryIndepPartialGroundingAux (Clauses& clauses, ConstraintTree& ct,
|
||||
LogVars& rootLogVars);
|
||||
|
||||
|
||||
bool tryAtomCounting (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
bool tryGrounding (CircuitNode** follow, Clauses& clauses);
|
||||
|
||||
|
||||
void shatterCountedLogVars (Clauses& clauses);
|
||||
|
||||
|
||||
bool shatterCountedLogVarsAux (Clauses& clauses);
|
||||
|
||||
bool shatterCountedLogVarsAux (Clauses& clauses, size_t idx1, size_t idx2);
|
||||
|
||||
|
||||
bool independentClause (Clause& clause, Clauses& otherClauses) const;
|
||||
|
||||
|
||||
bool independentLiteral (const Literal& lit,
|
||||
const Literals& otherLits) const;
|
||||
|
||||
LitLvTypesSet smoothCircuit (CircuitNode* node);
|
||||
|
||||
|
||||
void createSmoothNode (const LitLvTypesSet& lids,
|
||||
CircuitNode** prev);
|
||||
|
||||
|
||||
vector<LogVarTypes> getAllPossibleTypes (unsigned nrLogVars) const;
|
||||
|
||||
|
||||
bool containsTypes (const LogVarTypes& typesA,
|
||||
const LogVarTypes& typesB) const;
|
||||
|
||||
|
||||
CircuitNodeType getCircuitNodeType (const CircuitNode* node) const;
|
||||
|
||||
|
||||
void exportToGraphViz (CircuitNode* node, ofstream&);
|
||||
|
||||
|
||||
void printClauses (const CircuitNode* node, ofstream&,
|
||||
string extraOptions = "");
|
||||
|
||||
|
||||
string escapeNode (const CircuitNode* node) const;
|
||||
|
||||
CircuitNode* root_;
|
||||
|
Reference in New Issue
Block a user