Debian Codegraph @

src/dr/evomodel/coalescent/LogisticGrowthModel.java

raw symbols SCIP
1 /*
2 * LogisticGrowthModel.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.LogisticGrowth;
30 import dr.evomodelxml.coalescent.LogisticGrowthModelParser;
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 * Logistic growth.
41 *
42 * @author Alexei Drummond
43 * @author Andrew Rambaut
44 * @version $Id: LogisticGrowthModel.java,v 1.21 2005/05/24 20:25:57 rambaut Exp $
45 */
46 public class LogisticGrowthModel extends DemographicModel implements Citable {
47
48 //
49 // Public stuff
50 //
51
52 /**
53 * Construct demographic model with default settings
54 */
55 public LogisticGrowthModel(Parameter N0Parameter, Parameter growthRateParameter,
56 Parameter shapeParameter, double alpha, Type units,
57 boolean usingGrowthRate) {
58
59 this(LogisticGrowthModelParser.LOGISTIC_GROWTH_MODEL, N0Parameter, growthRateParameter, shapeParameter, alpha, units, usingGrowthRate);
60 }
61
62 /**
63 * Construct demographic model with default settings
64 */
65 public LogisticGrowthModel(String name, Parameter N0Parameter, Parameter growthRateParameter, Parameter shapeParameter, double alpha, Type units, boolean usingGrowthRate) {
66
67 super(name);
68
69 logisticGrowth = new LogisticGrowth(units);
70
71 this.N0Parameter = N0Parameter;
72 addVariable(N0Parameter);
73 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
74
75 this.growthRateParameter = growthRateParameter;
76 addVariable(growthRateParameter);
77 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
78
79 this.shapeParameter = shapeParameter;
80 addVariable(shapeParameter);
81 shapeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
82
83 this.alpha = alpha;
84 this.usingGrowthRate = usingGrowthRate;
85
86 setUnits(units);
87 }
88
89
90 // general functions
91
92 public DemographicFunction getDemographicFunction() {
93
94 logisticGrowth.setN0(N0Parameter.getParameterValue(0));
95
96 if (usingGrowthRate) {
97 double r = growthRateParameter.getParameterValue(0);
98 logisticGrowth.setGrowthRate(r);
99 } else {
100 double doublingTime = growthRateParameter.getParameterValue(0);
101 logisticGrowth.setDoublingTime(doublingTime);
102 }
103
104 logisticGrowth.setTime50(shapeParameter.getParameterValue(0));
105
106 return logisticGrowth;
107 }
108
109 //
110 // protected stuff
111 //
112
113 Parameter N0Parameter = null;
114 Parameter growthRateParameter = null;
115 Parameter shapeParameter = null;
116 double alpha = 0.5;
117 LogisticGrowth logisticGrowth = null;
118 boolean usingGrowthRate = true;
119
120 @Override
121 public Citation.Category getCategory() {
122 return Citation.Category.TREE_PRIORS;
123 }
124
125 @Override
126 public String getDescription() {
127 return "Logistic Growth Coalescent";
128 }
129
130 @Override
131 public List<Citation> getCitations() {
132 return Collections.singletonList(CITATION);
133 }
134
135 public static Citation CITATION = new Citation(
136 new Author[]{
137 new Author("OG", "Pybus"),
138 new Author("A", "Rambaut")
139 },
140 "GENIE: estimating demographic history from molecular phylogenies",
141 2001,
142 "Bioinformatics",
143 18, 1404, 1405
144 );
145 }