watch out for division by 0 in message calculation for BP

This commit is contained in:
Tiago Gomes 2012-09-30 22:04:44 +01:00
parent fec0bd44b4
commit 559b3e3b54
2 changed files with 7 additions and 5 deletions

View File

@ -349,20 +349,22 @@ BeliefProp::getVarToFactorMsg (const BpLink* link) const
const BpLinks& links = ninf (src)->getLinks();
if (Globals::logDomain) {
for (it = links.begin(); it != links.end(); ++it) {
if (*it != link) {
msg += (*it)->message();
}
if (Constants::SHOW_BP_CALCS) {
cout << " x " << (*it)->message();
}
}
msg -= link->message();
} else {
for (it = links.begin(); it != links.end(); ++it) {
if (*it != link) {
msg *= (*it)->message();
}
if (Constants::SHOW_BP_CALCS) {
cout << " x " << (*it)->message();
}
}
msg /= link->message();
}
if (Constants::SHOW_BP_CALCS) {
cout << " = " << msg;