| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodel.speciation; |
| 27 |
|
| 28 |
import dr.evolution.tree.Tree; |
| 29 |
import dr.evomodel.tree.TreeModel; |
| 30 |
import dr.evomodelxml.speciation.BranchingLikelihoodParser; |
| 31 |
import dr.inference.model.AbstractModelLikelihood; |
| 32 |
import dr.inference.model.Model; |
| 33 |
import dr.inference.model.Parameter; |
| 34 |
import dr.inference.model.Variable; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public class BranchingLikelihood extends AbstractModelLikelihood { |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public BranchingLikelihood(Tree tree, BranchingModel branchingModel) { |
| 49 |
this(BranchingLikelihoodParser.BRANCHING_LIKELIHOOD, tree, branchingModel); |
| 50 |
} |
| 51 |
|
| 52 |
public BranchingLikelihood(String name, Tree tree, BranchingModel branchingModel) { |
| 53 |
|
| 54 |
super(name); |
| 55 |
|
| 56 |
this.tree = tree; |
| 57 |
this.branchingModel = branchingModel; |
| 58 |
if (tree instanceof TreeModel) { |
| 59 |
addModel((TreeModel) tree); |
| 60 |
} |
| 61 |
if (branchingModel != null) { |
| 62 |
addModel(branchingModel); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
protected void handleModelChangedEvent(Model model, Object object, int index) { |
| 72 |
} |
| 73 |
|
| 74 |
protected final void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) { |
| 75 |
} |
| 76 |
|
| 77 |
protected void storeState() { |
| 78 |
} |
| 79 |
|
| 80 |
protected void restoreState() { |
| 81 |
} |
| 82 |
|
| 83 |
protected final void acceptState() { |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public final Model getModel() { |
| 91 |
return this; |
| 92 |
} |
| 93 |
|
| 94 |
public final double getLogLikelihood() { |
| 95 |
return calculateLogLikelihood(); |
| 96 |
|
| 97 |
} |
| 98 |
|
| 99 |
public final void makeDirty() { |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
public double calculateLogLikelihood() { |
| 107 |
|
| 108 |
double logL = 0.0; |
| 109 |
for (int j = 0; j < tree.getInternalNodeCount(); j++) { |
| 110 |
logL += branchingModel.logNodeProbability(tree, tree.getInternalNode(j)); |
| 111 |
} |
| 112 |
|
| 113 |
return logL; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
public org.w3c.dom.Element createElement(org.w3c.dom.Document d) { |
| 121 |
throw new RuntimeException("createElement not implemented"); |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
BranchingModel branchingModel = null; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
Tree tree = null; |
| 137 |
} |