Debian Codegraph @

src/dr/evomodel/speciation/SpeciationModel.java

raw symbols SCIP
1 /*
2 * SpeciationModel.java
3 *
4 * Copyright (c) 2002-2015 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.speciation;
27
28 import dr.evolution.tree.Tree;
29 import dr.evolution.util.Taxon;
30 import dr.evolution.util.Units;
31 import dr.inference.model.AbstractModel;
32 import dr.inference.model.Model;
33 import dr.inference.model.Parameter;
34 import dr.inference.model.Variable;
35
36 import java.util.Set;
37
38 /**
39 * @author Alexei Drummond
40 * @author Andrew Rambaut
41 */
42 public abstract class SpeciationModel extends AbstractModel implements Units {
43 /**
44 * Units in which population size is measured.
45 */
46 private Units.Type units;
47
48 public SpeciationModel(String name, Type units) {
49 super(name);
50 setUnits(units);
51 }
52
53 public abstract double calculateTreeLogLikelihood(Tree tree);
54
55 public abstract double calculateTreeLogLikelihood(Tree tree, Set<Taxon> exclude);
56
57 // True if Yule.
58 //
59 // Not abstract - non supporting derived classes do not need to override anything
60 public boolean isYule() {
61 return false;
62 }
63
64 // Likelihood for the speciation model conditional on monophyly and calibration densities in
65 // 'calibration'.
66 //
67 // The likelihood enforces the monophyly, so there is no need to specify it again in the XML.
68 //
69 public double calculateTreeLogLikelihood(Tree tree, CalibrationPoints calibration) {
70 return Double.NEGATIVE_INFINITY;
71 }
72
73 protected void handleModelChangedEvent(Model model, Object object, int index) {
74 // no intermediates need to be recalculated...
75 }
76
77 protected void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) {
78 // no intermediates need to be recalculated...
79 }
80
81 protected void storeState() {
82 } // no additional state needs storing
83
84 protected void restoreState() {
85 } // no additional state needs restoring
86
87 protected void acceptState() {
88 } // no additional state needs accepting
89
90 /**
91 * sets units of measurement.
92 *
93 * @param u units
94 */
95 public void setUnits(Units.Type u) {
96 units = u;
97 }
98
99 /**
100 * returns units of measurement.
101 */
102 public Units.Type getUnits() {
103 return units;
104 }
105 }