From 9800db8c51d5c8ed049a7c5a2f81c0e2d1685dfa Mon Sep 17 00:00:00 2001 From: Marc Suchard Date: Wed, 4 Apr 2018 16:21:17 -0700 Subject: [PATCH] identify possibly latent, long-standing bug ... or I am a fool --- src/dr/inference/markovchain/MarkovChain.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/dr/inference/markovchain/MarkovChain.java b/src/dr/inference/markovchain/MarkovChain.java index 5df664383b..2c3fdd2f30 100644 --- a/src/dr/inference/markovchain/MarkovChain.java +++ b/src/dr/inference/markovchain/MarkovChain.java @@ -263,6 +263,29 @@ public long runChain(long length, boolean disableCoerce) { // The new model is evaluated score = evaluate(likelihood); + boolean EXTRA_CHECK = true; + + if (EXTRA_CHECK) { + String before = likelihood instanceof CompoundLikelihood ? + ((CompoundLikelihood) likelihood).getDiagnosis() : ""; + + likelihood.makeDirty(); + double newScore = evaluate(likelihood); + + String after = likelihood instanceof CompoundLikelihood ? + ((CompoundLikelihood) likelihood).getDiagnosis() : ""; + + if (Math.abs(score - newScore) > evaluationTestThreshold) { + + System.err.println("Latent error:"); + System.err.println(before); + System.err.println(); + System.err.println(after); + + System.exit(-1); + } + } + if (PROFILE) { long duration = System.currentTimeMillis() - elapsedTime; if (DEBUG) {