minor improvements

This commit is contained in:
Tiago Gomes 2012-05-28 19:10:29 +01:00
parent 004e6c0c5f
commit 64b53e8180

View File

@ -333,7 +333,6 @@ Params
BpSolver::getVar2FactorMsg (const SpLink* link) const BpSolver::getVar2FactorMsg (const SpLink* link) const
{ {
const VarNode* src = link->getVariable(); const VarNode* src = link->getVariable();
const FacNode* dst = link->getFactor();
Params msg; Params msg;
if (src->hasEvidence()) { if (src->hasEvidence()) {
msg.resize (src->range(), LogAware::noEvidence()); msg.resize (src->range(), LogAware::noEvidence());
@ -344,10 +343,10 @@ BpSolver::getVar2FactorMsg (const SpLink* link) const
if (Constants::SHOW_BP_CALCS) { if (Constants::SHOW_BP_CALCS) {
cout << msg; cout << msg;
} }
SpLinkSet::const_iterator it;
const SpLinkSet& links = ninf (src)->getLinks(); const SpLinkSet& links = ninf (src)->getLinks();
if (Globals::logDomain) { if (Globals::logDomain) {
SpLinkSet::const_iterator it; for (it = links.begin(); it != links.end(); ++it) {
for (it = links.begin(); it != links.end(); ++ it) {
msg += (*it)->getMessage(); msg += (*it)->getMessage();
if (Constants::SHOW_BP_CALCS) { if (Constants::SHOW_BP_CALCS) {
cout << " x " << (*it)->getMessage(); cout << " x " << (*it)->getMessage();
@ -355,14 +354,13 @@ BpSolver::getVar2FactorMsg (const SpLink* link) const
} }
msg -= link->getMessage(); msg -= link->getMessage();
} else { } else {
for (size_t i = 0; i < links.size(); i++) { for (it = links.begin(); it != links.end(); ++it) {
if (links[i]->getFactor() != dst) { msg *= (*it)->getMessage();
msg *= links[i]->getMessage(); if (Constants::SHOW_BP_CALCS) {
if (Constants::SHOW_BP_CALCS) { cout << " x " << (*it)->getMessage();
cout << " x " << links[i]->getMessage();
}
} }
} }
msg /= link->getMessage();
} }
if (Constants::SHOW_BP_CALCS) { if (Constants::SHOW_BP_CALCS) {
cout << " = " << msg; cout << " = " << msg;