prevent excessive MLT/ERPT error messages due to roundoff errors
parent
0a441e78a8
commit
fb7fe6a8e1
|
@ -234,15 +234,17 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
if (Qxy == 0) { // be tolerant of this (can occasionally happen due to floating point inaccuracies)
|
||||
a = 0;
|
||||
} else if (Qxy < 0 || Qyx < 0 || std::isnan(Qxy) || std::isnan(Qyx)) {
|
||||
#if defined(MTS_BD_DEBUG)
|
||||
if (Qxy <= 0 || Qyx < 0 || std::isnan(Qxy) || std::isnan(Qyx)) {
|
||||
Log(EDebug, "Source path: %s", current->toString().c_str());
|
||||
Log(EDebug, "Proposal path: %s", proposed->toString().c_str());
|
||||
Log(EWarn, "Internal error while computing acceptance probabilities: "
|
||||
"Qxy=%f, Qyx=%f, muRec=%s", Qxy, Qyx, muRec.toString().c_str());
|
||||
#endif
|
||||
a = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
accumulatedWeight += 1-a;
|
||||
|
||||
|
|
|
@ -235,7 +235,9 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
if (Qxy <= 0 || Qyx < 0 || std::isnan(Qxy) || std::isnan(Qyx)) {
|
||||
if (Qxy == 0) { // be tolerant of this (can occasionally happen due to floating point inaccuracies)
|
||||
a = 0;
|
||||
} else if (Qxy < 0 || Qyx < 0 || std::isnan(Qxy) || std::isnan(Qyx)) {
|
||||
#if defined(MTS_BD_DEBUG)
|
||||
Log(EDebug, "Source path: %s", current->toString().c_str());
|
||||
Log(EDebug, "Proposal path: %s", proposed->toString().c_str());
|
||||
|
|
|
@ -272,7 +272,6 @@ bool ManifoldPerturbation::sampleMutation(
|
|||
for (int i=l+1; i<m; ++i) {
|
||||
proposal.append(m_pool.allocVertex());
|
||||
proposal.append(m_pool.allocEdge());
|
||||
memset(proposal.vertex(proposal.vertexCount()-1), 0, sizeof(PathVertex)); /// XXX
|
||||
}
|
||||
proposal.append(source, m, k+1);
|
||||
|
||||
|
@ -665,6 +664,10 @@ Float ManifoldPerturbation::Q(const Path &source, const Path &proposal,
|
|||
if (prob == 0)
|
||||
return 0.0f;
|
||||
weight /= prob;
|
||||
|
||||
/* Catch very low probabilities which round to +inf in the above division operation */
|
||||
if (!std::isfinite(weight.average()))
|
||||
return 0.0f;
|
||||
} else {
|
||||
Frame frame(source.vertex(a+step)->getGeometricNormal());
|
||||
|
||||
|
|
Loading…
Reference in New Issue