fix factor joint

This commit is contained in:
Tiago Gomes 2012-09-11 18:48:16 +01:00
parent 86b57e961e
commit febb17d753
3 changed files with 4 additions and 5 deletions

View File

@ -118,20 +118,19 @@ BeliefProp::getJointDistributionOf (const VarIds& jointVarIds)
if (idx == facNodes.size()) { if (idx == facNodes.size()) {
return getJointByConditioning (jointVarIds); return getJointByConditioning (jointVarIds);
} }
return getFactorJoint (idx, jointVarIds); return getFactorJoint (facNodes[idx], jointVarIds);
} }
Params Params
BeliefProp::getFactorJoint ( BeliefProp::getFactorJoint (
size_t fnIdx, FacNode* fn,
const VarIds& jointVarIds) const VarIds& jointVarIds)
{ {
if (runned_ == false) { if (runned_ == false) {
runSolver(); runSolver();
} }
FacNode* fn = fg.facNodes()[fnIdx];
Factor res (fn->factor()); Factor res (fn->factor());
const BpLinks& links = ninf(fn)->getLinks(); const BpLinks& links = ninf(fn)->getLinks();
for (size_t i = 0; i < links.size(); i++) { for (size_t i = 0; i < links.size(); i++) {

View File

@ -112,7 +112,7 @@ class BeliefProp : public Solver
virtual Params getJointByConditioning (const VarIds&) const; virtual Params getJointByConditioning (const VarIds&) const;
public: public:
Params getFactorJoint (size_t fnIdx, const VarIds&); Params getFactorJoint (FacNode* fn, const VarIds&);
protected: protected:
SPNodeInfo* ninf (const VarNode* var) const SPNodeInfo* ninf (const VarNode* var) const

View File

@ -49,7 +49,7 @@ LiftedBp::solveQuery (const Grounds& query)
for (unsigned i = 0; i < groups.size(); i++) { for (unsigned i = 0; i < groups.size(); i++) {
queryVids.push_back (groups[i]); queryVids.push_back (groups[i]);
} }
res = solver_->getFactorJoint (idx, queryVids); res = solver_->getFactorJoint (fg_->facNodes()[idx], queryVids);
} }
} }
return res; return res;