From 9e1a649262158e2b225e05d528c82d89c084fe5c Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Fri, 27 Apr 2012 14:47:30 +0100 Subject: [PATCH] raising the paramaters to some power should happen after summing out, not before --- packages/CLPBN/clpbn/bp/Parfactor.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/CLPBN/clpbn/bp/Parfactor.cpp b/packages/CLPBN/clpbn/bp/Parfactor.cpp index bf240599f..9e86cc23f 100644 --- a/packages/CLPBN/clpbn/bp/Parfactor.cpp +++ b/packages/CLPBN/clpbn/bp/Parfactor.cpp @@ -138,14 +138,6 @@ Parfactor::sumOut (unsigned fIdx) assert (fIdx < args_.size()); assert (args_[fIdx].contains (elimLogVars())); - LogVarSet excl = exclusiveLogVars (fIdx); - if (args_[fIdx].isCounting()) { - LogAware::pow (params_, constr_->getConditionalCount ( - excl - args_[fIdx].countedLogVar())); - } else { - LogAware::pow (params_, constr_->getConditionalCount (excl)); - } - if (args_[fIdx].isCounting()) { unsigned N = constr_->getConditionalCount ( args_[fIdx].countedLogVar()); @@ -179,9 +171,17 @@ Parfactor::sumOut (unsigned fIdx) } } + LogVarSet excl = exclusiveLogVars (fIdx); + if (args_[fIdx].isCounting()) { + LogAware::pow (params_, constr_->getConditionalCount ( + excl - args_[fIdx].countedLogVar())); + } else { + LogAware::pow (params_, constr_->getConditionalCount (excl)); + } + constr_->remove (excl); + args_.erase (args_.begin() + fIdx); ranges_.erase (ranges_.begin() + fIdx); - constr_->remove (excl); }