diff --git a/packages/CLPBN/clpbn/bp/BpSolver.cpp b/packages/CLPBN/clpbn/bp/BpSolver.cpp index 6fe7c4851..c5f812f97 100644 --- a/packages/CLPBN/clpbn/bp/BpSolver.cpp +++ b/packages/CLPBN/clpbn/bp/BpSolver.cpp @@ -278,10 +278,14 @@ BpSolver::calculateFactor2VariableMsg (SpLink* link) const SpLinkSet& links = ninf(src)->getLinks(); // calculate the product of messages that were sent // to factor `src', except from var `dst' - unsigned msgSize = 1; + Params::size_type msgSize = 1; for (unsigned i = 0; i < links.size(); i++) { msgSize *= links[i]->getVariable()->range(); } + if (msgSize > Util::maxUnsigned()) { + cout << "error: an overflow occurred when sending bp message" << endl; + abort(); + } unsigned repetitions = 1; Params msgProduct (msgSize, LogAware::multIdenty()); if (Globals::logDomain) { diff --git a/packages/CLPBN/clpbn/bp/FoveSolver.cpp b/packages/CLPBN/clpbn/bp/FoveSolver.cpp index a82774217..e844c5b78 100644 --- a/packages/CLPBN/clpbn/bp/FoveSolver.cpp +++ b/packages/CLPBN/clpbn/bp/FoveSolver.cpp @@ -84,7 +84,7 @@ SumOutOperator::getLogCost (void) ++ pfIter; } if (nrProdFactors == 1) { - return std::log (1.0); // best possible case + return std::log (0.0); // best possible case } double cost = 1.0; for (unsigned i = 0; i < groupSet.size(); i++) {