fix memory leak
This commit is contained in:
parent
fa2c5ee114
commit
86b57e961e
@ -8,7 +8,8 @@ LiftedBp::LiftedBp (const ParfactorList& pfList)
|
|||||||
: pfList_(pfList)
|
: pfList_(pfList)
|
||||||
{
|
{
|
||||||
refineParfactors();
|
refineParfactors();
|
||||||
solver_ = new WeightedBp (*getFactorGraph(), getWeights());
|
createFactorGraph();
|
||||||
|
solver_ = new WeightedBp (*fg_, getWeights());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ LiftedBp::LiftedBp (const ParfactorList& pfList)
|
|||||||
LiftedBp::~LiftedBp (void)
|
LiftedBp::~LiftedBp (void)
|
||||||
{
|
{
|
||||||
delete solver_;
|
delete solver_;
|
||||||
|
delete fg_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -131,10 +133,10 @@ LiftedBp::getQueryGroups (const Grounds& query)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
FactorGraph*
|
void
|
||||||
LiftedBp::getFactorGraph (void)
|
LiftedBp::createFactorGraph (void)
|
||||||
{
|
{
|
||||||
FactorGraph* fg = new FactorGraph();
|
fg_ = new FactorGraph();
|
||||||
ParfactorList::const_iterator it = pfList_.begin();
|
ParfactorList::const_iterator it = pfList_.begin();
|
||||||
for (; it != pfList_.end(); ++it) {
|
for (; it != pfList_.end(); ++it) {
|
||||||
vector<PrvGroup> groups = (*it)->getAllGroups();
|
vector<PrvGroup> groups = (*it)->getAllGroups();
|
||||||
@ -142,9 +144,8 @@ LiftedBp::getFactorGraph (void)
|
|||||||
for (size_t i = 0; i < groups.size(); i++) {
|
for (size_t i = 0; i < groups.size(); i++) {
|
||||||
varIds.push_back (groups[i]);
|
varIds.push_back (groups[i]);
|
||||||
}
|
}
|
||||||
fg->addFactor (Factor (varIds, (*it)->ranges(), (*it)->params()));
|
fg_->addFactor (Factor (varIds, (*it)->ranges(), (*it)->params()));
|
||||||
}
|
}
|
||||||
return fg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class LiftedBp
|
|||||||
|
|
||||||
vector<PrvGroup> getQueryGroups (const Grounds&);
|
vector<PrvGroup> getQueryGroups (const Grounds&);
|
||||||
|
|
||||||
FactorGraph* getFactorGraph (void);
|
void createFactorGraph (void);
|
||||||
|
|
||||||
vector<vector<unsigned>> getWeights (void) const;
|
vector<vector<unsigned>> getWeights (void) const;
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ class LiftedBp
|
|||||||
|
|
||||||
ParfactorList pfList_;
|
ParfactorList pfList_;
|
||||||
WeightedBp* solver_;
|
WeightedBp* solver_;
|
||||||
|
FactorGraph* fg_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user