Debian Codegraph @

src/dr/evomodel/coalescent/ExponentialLogisticModel.java

raw symbols SCIP
1 /*
2 * ExponentialLogisticModel.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.ExponentialLogistic;
30 import dr.evomodelxml.coalescent.ExponentialLogisticModelParser;
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 Logistic growth.
41 *
42 * @author Andrew Rambaut
43 * @author Alexei Drummond
44 * @version $Id$
45 */
46 public class ExponentialLogisticModel extends DemographicModel implements Citable {
47
48 //
49 // Public stuff
50 //
51
52 /**
53 * Construct demographic model with default settings
54 */
55 public ExponentialLogisticModel(Parameter N0Parameter,
56 Parameter logisticGrowthParameter,
57 Parameter logisticShapeParameter,
58 Parameter exponentialGrowthParameter,
59 Parameter transitionTimeParameter,
60 double alpha, Type units) {
61
62 this(ExponentialLogisticModelParser.EXPONENTIAL_LOGISTIC_MODEL,
63 N0Parameter,
64 logisticGrowthParameter,
65 logisticShapeParameter,
66 exponentialGrowthParameter,
67 transitionTimeParameter,
68 alpha, units);
69 }
70
71 /**
72 * Construct demographic model with default settings
73 */
74 public ExponentialLogisticModel(String name, Parameter N0Parameter,
75 Parameter logisticGrowthParameter,
76 Parameter logisticShapeParameter,
77 Parameter exponentialGrowthParameter,
78 Parameter transistionTimeParameter,
79 double alpha, Type units) {
80
81 super(name);
82
83 exponentialLogistic = new ExponentialLogistic(units);
84
85 this.N0Parameter = N0Parameter;
86 addVariable(N0Parameter);
87 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
88
89 this.logisticGrowthParameter = logisticGrowthParameter;
90 addVariable(logisticGrowthParameter);
91 logisticGrowthParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
92
93 this.logisticShapeParameter = logisticShapeParameter;
94 addVariable(logisticShapeParameter);
95 logisticShapeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
96
97 this.exponentialGrowthParameter = exponentialGrowthParameter;
98 addVariable(exponentialGrowthParameter);
99 exponentialGrowthParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
100
101 this.transistionTimeParameter = transistionTimeParameter;
102 addVariable(transistionTimeParameter);
103 transistionTimeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
104
105 this.alpha = alpha;
106
107 setUnits(units);
108 }
109
110
111 // general functions
112
113 public DemographicFunction getDemographicFunction() {
114 exponentialLogistic.setN0(N0Parameter.getParameterValue(0));
115
116 double r = logisticGrowthParameter.getParameterValue(0);
117 exponentialLogistic.setGrowthRate(r);
118
119 double r1 = exponentialGrowthParameter.getParameterValue(0);
120 exponentialLogistic.setR1(r1);
121
122 double t = transistionTimeParameter.getParameterValue(0);
123 exponentialLogistic.setTime(t);
124
125 // logisticGrowth.setShape(Math.exp(shapeParameter.getParameterValue(0)));
126 exponentialLogistic.setTime50(logisticShapeParameter.getParameterValue(0));
127 //exponentialLogistic.setShapeFromTimeAtAlpha(logisticShapeParameter.getParameterValue(0), alpha);
128
129 return exponentialLogistic;
130 }
131
132 //
133 // protected stuff
134 //
135
136 Parameter N0Parameter = null;
137 Parameter logisticGrowthParameter = null;
138 Parameter logisticShapeParameter = null;
139 Parameter exponentialGrowthParameter = null;
140 Parameter transistionTimeParameter = null;
141 double alpha = 0.5;
142 ExponentialLogistic exponentialLogistic = null;
143
144 @Override
145 public Citation.Category getCategory() {
146 return Citation.Category.TREE_PRIORS;
147 }
148
149 @Override
150 public String getDescription() {
151 return "Exponential-Logistic Coalescent";
152 }
153
154 @Override
155 public List<Citation> getCitations() {
156 return Collections.singletonList(CITATION);
157 }
158
159 public static Citation CITATION = new Citation(
160 new Author[]{
161 new Author("OG", "Pybus"),
162 new Author("A", "Rambaut")
163 },
164 "GENIE: estimating demographic history from molecular phylogenies",
165 2001,
166 "Bioinformatics",
167 18, 1404, 1405
168 );
169 }