From febb17d7530ba8545f8fb65199e0b3abee91c874 Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Tue, 11 Sep 2012 18:48:16 +0100 Subject: [PATCH] fix factor joint --- packages/CLPBN/horus/BeliefProp.cpp | 5 ++--- packages/CLPBN/horus/BeliefProp.h | 2 +- packages/CLPBN/horus/LiftedBp.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/CLPBN/horus/BeliefProp.cpp b/packages/CLPBN/horus/BeliefProp.cpp index d65c36a01..ed94e8c12 100644 --- a/packages/CLPBN/horus/BeliefProp.cpp +++ b/packages/CLPBN/horus/BeliefProp.cpp @@ -118,20 +118,19 @@ BeliefProp::getJointDistributionOf (const VarIds& jointVarIds) if (idx == facNodes.size()) { return getJointByConditioning (jointVarIds); } - return getFactorJoint (idx, jointVarIds); + return getFactorJoint (facNodes[idx], jointVarIds); } Params BeliefProp::getFactorJoint ( - size_t fnIdx, + FacNode* fn, const VarIds& jointVarIds) { if (runned_ == false) { runSolver(); } - FacNode* fn = fg.facNodes()[fnIdx]; Factor res (fn->factor()); const BpLinks& links = ninf(fn)->getLinks(); for (size_t i = 0; i < links.size(); i++) { diff --git a/packages/CLPBN/horus/BeliefProp.h b/packages/CLPBN/horus/BeliefProp.h index 44c867dbc..1545abfc8 100644 --- a/packages/CLPBN/horus/BeliefProp.h +++ b/packages/CLPBN/horus/BeliefProp.h @@ -112,7 +112,7 @@ class BeliefProp : public Solver virtual Params getJointByConditioning (const VarIds&) const; public: - Params getFactorJoint (size_t fnIdx, const VarIds&); + Params getFactorJoint (FacNode* fn, const VarIds&); protected: SPNodeInfo* ninf (const VarNode* var) const diff --git a/packages/CLPBN/horus/LiftedBp.cpp b/packages/CLPBN/horus/LiftedBp.cpp index eb538f12a..05a5ea6af 100644 --- a/packages/CLPBN/horus/LiftedBp.cpp +++ b/packages/CLPBN/horus/LiftedBp.cpp @@ -49,7 +49,7 @@ LiftedBp::solveQuery (const Grounds& query) for (unsigned i = 0; i < groups.size(); i++) { queryVids.push_back (groups[i]); } - res = solver_->getFactorJoint (idx, queryVids); + res = solver_->getFactorJoint (fg_->facNodes()[idx], queryVids); } } return res;