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();
|
const BpLinks& links = ninf (src)->getLinks();
|
||||||
if (Globals::logDomain) {
|
if (Globals::logDomain) {
|
||||||
for (it = links.begin(); it != links.end(); ++it) {
|
for (it = links.begin(); it != links.end(); ++it) {
|
||||||
msg += (*it)->message();
|
if (*it != link) {
|
||||||
|
msg += (*it)->message();
|
||||||
|
}
|
||||||
if (Constants::SHOW_BP_CALCS) {
|
if (Constants::SHOW_BP_CALCS) {
|
||||||
cout << " x " << (*it)->message();
|
cout << " x " << (*it)->message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg -= link->message();
|
|
||||||
} else {
|
} else {
|
||||||
for (it = links.begin(); it != links.end(); ++it) {
|
for (it = links.begin(); it != links.end(); ++it) {
|
||||||
msg *= (*it)->message();
|
if (*it != link) {
|
||||||
|
msg *= (*it)->message();
|
||||||
|
}
|
||||||
if (Constants::SHOW_BP_CALCS) {
|
if (Constants::SHOW_BP_CALCS) {
|
||||||
cout << " x " << (*it)->message();
|
cout << " x " << (*it)->message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg /= link->message();
|
|
||||||
}
|
}
|
||||||
if (Constants::SHOW_BP_CALCS) {
|
if (Constants::SHOW_BP_CALCS) {
|
||||||
cout << " = " << msg;
|
cout << " = " << msg;
|
||||||
|
Reference in New Issue
Block a user