Debian Codegraph @

src/dr/evomodel/continuous/RestrictedPartials.java

raw symbols SCIP
1 /*
2 * RestrictedPartials.java
3 *
4 * Copyright (c) 2002-2016 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * Created by msuchard on 6/4/16.
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 // Public API
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 // AbstractModel implementation
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 }