From fb7fe6a8e18f325f4f8e61c5899363f93e9edcc6 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 15 Nov 2012 00:52:14 -0500 Subject: [PATCH] prevent excessive MLT/ERPT error messages due to roundoff errors --- src/integrators/erpt/erpt_proc.cpp | 16 +++++++++------- src/integrators/mlt/mlt_proc.cpp | 4 +++- src/libbidir/mut_manifold.cpp | 5 ++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/integrators/erpt/erpt_proc.cpp b/src/integrators/erpt/erpt_proc.cpp index 13708297..fe5b7714 100644 --- a/src/integrators/erpt/erpt_proc.cpp +++ b/src/integrators/erpt/erpt_proc.cpp @@ -234,15 +234,17 @@ public: } #endif - #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()); + 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()); + 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; diff --git a/src/integrators/mlt/mlt_proc.cpp b/src/integrators/mlt/mlt_proc.cpp index d70132e0..7d820505 100644 --- a/src/integrators/mlt/mlt_proc.cpp +++ b/src/integrators/mlt/mlt_proc.cpp @@ -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()); diff --git a/src/libbidir/mut_manifold.cpp b/src/libbidir/mut_manifold.cpp index 7d589c04..5835456f 100644 --- a/src/libbidir/mut_manifold.cpp +++ b/src/libbidir/mut_manifold.cpp @@ -272,7 +272,6 @@ bool ManifoldPerturbation::sampleMutation( for (int i=l+1; igetGeometricNormal());