Debian Codegraph @

src/dr/evomodel/coalescent/ExponentialConstantModel.java

raw symbols SCIP
1 /*
2 * ExponentialConstantModel.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.coalescent;
27
28 import dr.evolution.coalescent.DemographicFunction;
29 import dr.evolution.coalescent.ExpConstant;
30 import dr.evomodelxml.coalescent.ExponentialConstantModelParser;
31 import dr.inference.model.Parameter;
32 import dr.util.Author;
33 import dr.util.Citable;
34 import dr.util.Citation;
35
36 import java.util.Collections;
37 import java.util.List;
38
39 /**
40 * Exponential growth followed by constant size.
41 *
42 * @author Matthew Hall
43 */
44 public class ExponentialConstantModel extends DemographicModel implements Citable {
45
46 //
47 // Public stuff
48 //
49
50 /**
51 * Construct demographic model with default settings
52 */
53 public ExponentialConstantModel(Parameter N0Parameter,
54 Parameter growthRateParameter,
55 Parameter transitionTimeParameter,
56 Type units) {
57
58 this(ExponentialConstantModelParser.EXPONENTIAL_CONSTANT_MODEL,
59 N0Parameter,
60 growthRateParameter,
61 transitionTimeParameter,
62 units);
63 }
64
65 /**
66 * Construct demographic model with default settings
67 */
68 public ExponentialConstantModel(String name, Parameter N0Parameter,
69 Parameter growthRateParameter,
70 Parameter transitionTimeParameter,
71 Type units) {
72
73 super(name);
74
75 exponentialConstant = new ExpConstant(units);
76
77 this.N0Parameter = N0Parameter;
78 addVariable(N0Parameter);
79 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
80
81 this.growthRateParameter = growthRateParameter;
82 addVariable(growthRateParameter);
83 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
84
85 this.transitionTimeParameter = transitionTimeParameter;
86 addVariable(transitionTimeParameter);
87 transitionTimeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY,
88 Double.NEGATIVE_INFINITY, 1));
89
90 setUnits(units);
91 }
92
93
94 // general functions
95
96 public DemographicFunction getDemographicFunction() {
97 exponentialConstant.setN0(N0Parameter.getParameterValue(0));
98
99 exponentialConstant.setGrowthRate(growthRateParameter.getParameterValue(0));
100
101 exponentialConstant.setTransitionTime(transitionTimeParameter.getParameterValue(0));
102
103 return exponentialConstant;
104 }
105
106 //
107 // protected stuff
108 //
109
110 Parameter N0Parameter = null;
111 Parameter growthRateParameter = null;
112 Parameter transitionTimeParameter = null;
113 ExpConstant exponentialConstant = null;
114
115 @Override
116 public Citation.Category getCategory() {
117 return Citation.Category.TREE_PRIORS;
118 }
119
120 @Override
121 public String getDescription() {
122 return "Exponential-Constant Coalescent";
123 }
124
125 @Override
126 public List<Citation> getCitations() {
127 return Collections.singletonList(CITATION);
128 }
129
130 public static Citation CITATION = new Citation(
131 new Author[]{
132 new Author("OG", "Pybus"),
133 new Author("A", "Rambaut")
134 },
135 "GENIE: estimating demographic history from molecular phylogenies",
136 2001,
137 "Bioinformatics",
138 18, 1404, 1405
139 );
140 }