diff --git a/src/dr/evomodel/coalescent/basta/BastaLikelihood.java b/src/dr/evomodel/coalescent/basta/BastaLikelihood.java index c7c8351abd..9352fcdb91 100644 --- a/src/dr/evomodel/coalescent/basta/BastaLikelihood.java +++ b/src/dr/evomodel/coalescent/basta/BastaLikelihood.java @@ -281,7 +281,7 @@ private double calculateLogLikelihood() { final List matrixOperations = treeTraversalDelegate.getMatrixOperations(); final List intervalStarts = treeTraversalDelegate.getIntervalStarts(); - + if (COUNT_TOTAL_OPERATIONS) { totalPropagationCount += branchOperations.size(); totalMatrixUpdateCount += matrixOperations.size(); diff --git a/src/dr/evomodel/coalescent/basta/BastaLikelihoodDelegate.java b/src/dr/evomodel/coalescent/basta/BastaLikelihoodDelegate.java index 695d5a7f89..da0ec93d71 100644 --- a/src/dr/evomodel/coalescent/basta/BastaLikelihoodDelegate.java +++ b/src/dr/evomodel/coalescent/basta/BastaLikelihoodDelegate.java @@ -101,15 +101,14 @@ public AbstractBastaLikelihoodDelegate(String name, } private int getMaxNumberOfCoalescentIntervals(Tree tree) { -// BigFastTreeIntervals intervals = new BigFastTreeIntervals((TreeModel) tree); // TODO fix BFTI to take a Tree -// int zeroLengthSampling = 0; -// for (int i = 0; i < intervals.getIntervalCount(); ++i) { -// if (intervals.getIntervalType(i) == IntervalType.SAMPLE && intervals.getIntervalTime(i) == 0.0) { -// ++zeroLengthSampling; -// } -// } -// return tree.getNodeCount() - zeroLengthSampling; - return tree.getNodeCount(); + BigFastTreeIntervals intervals = new BigFastTreeIntervals((TreeModel) tree); // TODO fix BFTI to take a Tree + int zeroLengthSampling = 0; + for (int i = 0; i < intervals.getIntervalCount(); ++i) { + if (intervals.getIntervalType(i) == IntervalType.SAMPLE && intervals.getIntervalTime(i) == 0.0) { + ++zeroLengthSampling; + } + } + return tree.getNodeCount() - zeroLengthSampling; } @Override @@ -147,11 +146,9 @@ enum ParallelizationScheme { FULL } - abstract protected void clearAll(); - - abstract protected double computeBranchIntervalOperations(List branchIntervalOperations); + abstract protected void computeBranchIntervalOperations(List branchIntervalOperations); - abstract protected double computeTransitionProbabilityOperations(List matrixOperations); + abstract protected void computeTransitionProbabilityOperations(List matrixOperations); abstract protected double computeCoalescentIntervalReduction(List intervalStarts, List branchIntervalOperations); @@ -166,11 +163,9 @@ public double calculateLikelihood(List branchOperations System.err.println("Tree = " + tree); } - double logLikelihood = computeTransitionProbabilityOperations(matrixOperation); - logLikelihood += computeBranchIntervalOperations(branchOperations); - logLikelihood += computeCoalescentIntervalReduction(intervalStarts, branchOperations); - - return logLikelihood; + computeTransitionProbabilityOperations(matrixOperation); + computeBranchIntervalOperations(branchOperations); + return computeCoalescentIntervalReduction(intervalStarts, branchOperations); } @Override diff --git a/src/dr/evomodel/coalescent/basta/GenericBastaLikelihoodDelegate.java b/src/dr/evomodel/coalescent/basta/GenericBastaLikelihoodDelegate.java index 2eae2600c8..52839fa0c3 100644 --- a/src/dr/evomodel/coalescent/basta/GenericBastaLikelihoodDelegate.java +++ b/src/dr/evomodel/coalescent/basta/GenericBastaLikelihoodDelegate.java @@ -12,8 +12,6 @@ */ public class GenericBastaLikelihoodDelegate extends BastaLikelihoodDelegate.AbstractBastaLikelihoodDelegate { - private static final boolean PRINT_COMMANDS = true; - private final double[] partials; private final double[] matrices; private final double[] sizes; @@ -48,20 +46,7 @@ public GenericBastaLikelihoodDelegate(String name, } @Override - protected void clearAll() { -// Arrays.fill(partials, tree.getExternalNodeCount() * stateCount, partials.length, 0.0); -// Arrays.fill(matrices, 0.0); -// Arrays.fill(sizes, 0.0); - -// Arrays.fill(coalescent, 0.0); -// Arrays.fill(e, 0.0); -// Arrays.fill(f, 0.0); -// Arrays.fill(g, 0.0); -// Arrays.fill(h, 0.0); - } - - @Override - protected double computeBranchIntervalOperations(List branchIntervalOperations) { + protected void computeBranchIntervalOperations(List branchIntervalOperations) { Arrays.fill(coalescent, 0.0); @@ -81,12 +66,10 @@ protected double computeBranchIntervalOperations(List b new WrappedVector.Raw(partials, operation.outputBuffer * stateCount, stateCount)); } } - - return 0.0; } @Override - protected double computeTransitionProbabilityOperations(List matrixOperations) { + protected void computeTransitionProbabilityOperations(List matrixOperations) { for (TransitionMatrixOperation operation : matrixOperations) { // TODO execute in parallel computeTransitionProbabilities( @@ -101,8 +84,6 @@ protected double computeTransitionProbabilityOperations(List intervalStarts System.err.println("logL = " + logL + "\n"); } -// return 0.0; return logL; } diff --git a/src/dr/evomodel/coalescent/basta/NativeBastaLikelihoodDelegate.java b/src/dr/evomodel/coalescent/basta/NativeBastaLikelihoodDelegate.java index 9ce619bd3c..a2b44bbaa8 100644 --- a/src/dr/evomodel/coalescent/basta/NativeBastaLikelihoodDelegate.java +++ b/src/dr/evomodel/coalescent/basta/NativeBastaLikelihoodDelegate.java @@ -22,30 +22,21 @@ public NativeBastaLikelihoodDelegate(String name, } @Override - protected void clearAll() { - - } - - @Override - protected double computeBranchIntervalOperations(List branchIntervalOperations) { + protected void computeBranchIntervalOperations(List branchIntervalOperations) { if (branchIntervalOperations != null) { for (BranchIntervalOperation operation : branchIntervalOperations) { System.err.println(operation.toString()); } } - - return 0.0; } @Override - protected double computeTransitionProbabilityOperations(List matrixOperations) { + protected void computeTransitionProbabilityOperations(List matrixOperations) { if (matrixOperations != null) { for (TransitionMatrixOperation operation : matrixOperations) { System.err.println(operation.toString()); } } - - return 0.0; } @Override