| 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.continuous; |
| 27 |
|
| 28 |
import dr.evolution.tree.NodeRef; |
| 29 |
import dr.evolution.tree.Tree; |
| 30 |
import dr.evolution.tree.TreeUtils; |
| 31 |
import dr.evolution.util.TaxonList; |
| 32 |
import dr.evomodel.tree.TreeModel; |
| 33 |
import dr.evomodel.treedatalikelihood.continuous.cdi.PrecisionType; |
| 34 |
import dr.inference.model.AbstractModel; |
| 35 |
import dr.inference.model.Model; |
| 36 |
import dr.inference.model.Parameter; |
| 37 |
import dr.inference.model.Variable; |
| 38 |
|
| 39 |
import java.util.BitSet; |
| 40 |
import java.util.Set; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public class RestrictedPartials extends AbstractModel { |
| 46 |
|
| 47 |
public RestrictedPartials(String name, |
| 48 |
TreeModel treeModel, |
| 49 |
TaxonList taxonList, Parameter meanParameter, |
| 50 |
Parameter priorSampleSize) throws TreeUtils.MissingTaxonException { |
| 51 |
this(name, treeModel, taxonList, meanParameter, priorSampleSize, null, -1); |
| 52 |
} |
| 53 |
|
| 54 |
public RestrictedPartials(String name, |
| 55 |
TreeModel treeModel, |
| 56 |
TaxonList taxonList, Parameter meanParameter, |
| 57 |
Parameter priorSampleSize, |
| 58 |
NodeRef node, int index) throws TreeUtils.MissingTaxonException { |
| 59 |
super(name); |
| 60 |
this.treeModel = treeModel; |
| 61 |
this.taxonList = taxonList; |
| 62 |
this.meanParameter = meanParameter; |
| 63 |
this.priorSampleSize = priorSampleSize; |
| 64 |
this.index = index; |
| 65 |
this.node = node; |
| 66 |
|
| 67 |
this.tips = TreeUtils.getTipsForTaxa(treeModel, taxonList); |
| 68 |
this.tipBitSet = TreeUtils.getTipsBitSetForTaxa(treeModel, taxonList); |
| 69 |
|
| 70 |
addVariable(meanParameter); |
| 71 |
addVariable(priorSampleSize); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
final TreeModel getTreeModel() { return treeModel; } |
| 77 |
|
| 78 |
final double[] getPartials() { return meanParameter.getParameterValues(); } |
| 79 |
|
| 80 |
final double getPartial(int i) { return meanParameter.getParameterValue(i); } |
| 81 |
|
| 82 |
final double getPriorSampleSize() { return priorSampleSize.getParameterValue(0); } |
| 83 |
|
| 84 |
final double[] getRestrictedPartials() { |
| 85 |
assert(false); |
| 86 |
return null; |
| 87 |
} |
| 88 |
|
| 89 |
final PrecisionType getPrecisionType() { |
| 90 |
assert(false); |
| 91 |
return PrecisionType.SCALAR; |
| 92 |
} |
| 93 |
|
| 94 |
final int getIndex() { return index; } |
| 95 |
|
| 96 |
final void setIndex(int index) { this.index = index; } |
| 97 |
|
| 98 |
final NodeRef getNode() { return node; } |
| 99 |
|
| 100 |
final void setNode(NodeRef node) { this.node = node; } |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
@Override |
| 105 |
protected void handleModelChangedEvent(Model model, Object object, int index) { |
| 106 |
throw new RuntimeException("Not yet implemented"); |
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
protected void storeState() { |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
@Override |
| 115 |
protected void restoreState() { |
| 116 |
|
| 117 |
} |
| 118 |
|
| 119 |
@Override |
| 120 |
protected void acceptState() { |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
@Override |
| 125 |
protected void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) { |
| 126 |
fireModelChanged(variable, index); |
| 127 |
} |
| 128 |
|
| 129 |
final private TreeModel treeModel; |
| 130 |
final private TaxonList taxonList; |
| 131 |
|
| 132 |
final private Set<Integer> tips; |
| 133 |
final private BitSet tipBitSet; |
| 134 |
|
| 135 |
final private Parameter meanParameter; |
| 136 |
final private Parameter priorSampleSize; |
| 137 |
|
| 138 |
private int index; |
| 139 |
private NodeRef node; |
| 140 |
|
| 141 |
public TaxonList getTaxonList() { |
| 142 |
return taxonList; |
| 143 |
} |
| 144 |
|
| 145 |
public BitSet getTipBitSet() { |
| 146 |
return tipBitSet; |
| 147 |
} |
| 148 |
} |