watch out for division by 0 in message calculation for BP
This commit is contained in:
parent
fec0bd44b4
commit
559b3e3b54
@ -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;
|
||||
|
Reference in New Issue
Block a user