diff --git a/packages/CLPBN/horus/LiftedCircuit.cpp b/packages/CLPBN/horus/LiftedCircuit.cpp index fd4c885ec..d330f2a68 100644 --- a/packages/CLPBN/horus/LiftedCircuit.cpp +++ b/packages/CLPBN/horus/LiftedCircuit.cpp @@ -78,6 +78,16 @@ double LeafNode::weight (void) const { assert (clause_->isUnit()); + if (clause_->posCountedLogVars().empty() == false + || clause_->negCountedLogVars().empty() == false) { + if (SetOrNode::isSet() == false) { + // return a NaN if we have a SetOrNode + // ancester that is not set. This can only + // happen when calculating the weights + // for the edge labels in graphviz + return 0.0 / 0.0; + } + } double weight = clause_->literals()[0].isPositive() ? lwcnf_.posWeight (clause_->literals().front().lid()) : lwcnf_.negWeight (clause_->literals().front().lid()); @@ -226,7 +236,7 @@ LiftedCircuit::compile ( } if (clauses.empty()) { - *follow = new TrueNode (); + *follow = new TrueNode(); return; } diff --git a/packages/CLPBN/horus/LiftedCircuit.h b/packages/CLPBN/horus/LiftedCircuit.h index 8303c797b..070d0f8d9 100644 --- a/packages/CLPBN/horus/LiftedCircuit.h +++ b/packages/CLPBN/horus/LiftedCircuit.h @@ -75,9 +75,11 @@ class SetOrNode : public CircuitNode CircuitNode** follow (void) { return &follow_; } - static unsigned nrPositives (void) { return nrGrsStack.top().first; } + static unsigned nrPositives (void) { return nrGrsStack.top().first; } static unsigned nrNegatives (void) { return nrGrsStack.top().second; } + + static bool isSet (void) { return nrGrsStack.size() > 0; } double weight (void) const;