diff --git a/packages/CLPBN/horus/LiftedBp.cpp b/packages/CLPBN/horus/LiftedBp.cpp index 8fc8573b6..eb538f12a 100644 --- a/packages/CLPBN/horus/LiftedBp.cpp +++ b/packages/CLPBN/horus/LiftedBp.cpp @@ -8,7 +8,8 @@ LiftedBp::LiftedBp (const ParfactorList& pfList) : pfList_(pfList) { refineParfactors(); - solver_ = new WeightedBp (*getFactorGraph(), getWeights()); + createFactorGraph(); + solver_ = new WeightedBp (*fg_, getWeights()); } @@ -16,6 +17,7 @@ LiftedBp::LiftedBp (const ParfactorList& pfList) LiftedBp::~LiftedBp (void) { delete solver_; + delete fg_; } @@ -131,10 +133,10 @@ LiftedBp::getQueryGroups (const Grounds& query) -FactorGraph* -LiftedBp::getFactorGraph (void) +void +LiftedBp::createFactorGraph (void) { - FactorGraph* fg = new FactorGraph(); + fg_ = new FactorGraph(); ParfactorList::const_iterator it = pfList_.begin(); for (; it != pfList_.end(); ++it) { vector groups = (*it)->getAllGroups(); @@ -142,9 +144,8 @@ LiftedBp::getFactorGraph (void) for (size_t i = 0; i < groups.size(); i++) { varIds.push_back (groups[i]); } - fg->addFactor (Factor (varIds, (*it)->ranges(), (*it)->params())); + fg_->addFactor (Factor (varIds, (*it)->ranges(), (*it)->params())); } - return fg; } diff --git a/packages/CLPBN/horus/LiftedBp.h b/packages/CLPBN/horus/LiftedBp.h index 01e18310e..c34956320 100644 --- a/packages/CLPBN/horus/LiftedBp.h +++ b/packages/CLPBN/horus/LiftedBp.h @@ -24,7 +24,7 @@ class LiftedBp vector getQueryGroups (const Grounds&); - FactorGraph* getFactorGraph (void); + void createFactorGraph (void); vector> getWeights (void) const; @@ -34,6 +34,7 @@ class LiftedBp ParfactorList pfList_; WeightedBp* solver_; + FactorGraph* fg_; };