Debian Codegraph @

src/dr/evomodel/coalescent/ExponentialGrowthModel.java

raw symbols SCIP
1 /*
2 * ExponentialGrowthModel.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.ExponentialGrowth;
30 import dr.evomodelxml.coalescent.ExponentialGrowthModelParser;
31 import dr.inference.model.Parameter;
32
33 /**
34 * This class models an exponentially growing (or shrinking) population
35 * (Parameters: N0=present-day population size; r=growth rate).
36 * This model is nested with the constant-population size model (r=0).
37 *
38 * @author Alexei Drummond
39 * @author Andrew Rambaut
40 * @version $Id: ExponentialGrowthModel.java,v 1.14 2005/05/24 20:25:57 rambaut Exp $
41 */
42 public class ExponentialGrowthModel extends DemographicModel {
43
44 //
45 // Public stuff
46 //
47 /**
48 * Construct demographic model with default settings
49 */
50 public ExponentialGrowthModel(Parameter N0Parameter, Parameter growthRateParameter,
51 Type units, boolean usingGrowthRate) {
52
53 this(ExponentialGrowthModelParser.EXPONENTIAL_GROWTH_MODEL, N0Parameter, growthRateParameter, units, usingGrowthRate);
54 }
55
56 /**
57 * Construct demographic model with default settings
58 */
59 public ExponentialGrowthModel(String name, Parameter N0Parameter, Parameter growthRateParameter,
60 Type units, boolean usingGrowthRate) {
61
62 super(name);
63
64 exponentialGrowth = new ExponentialGrowth(units);
65
66 this.N0Parameter = N0Parameter;
67 addVariable(N0Parameter);
68 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
69
70 this.growthRateParameter = growthRateParameter;
71 addVariable(growthRateParameter);
72 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
73
74 this.usingGrowthRate = usingGrowthRate;
75
76 setUnits(units);
77 }
78
79
80 // general functions
81
82 public DemographicFunction getDemographicFunction() {
83 exponentialGrowth.setN0(N0Parameter.getParameterValue(0));
84
85 if (usingGrowthRate) {
86 double r = growthRateParameter.getParameterValue(0);
87 exponentialGrowth.setGrowthRate(r);
88 } else {
89 double doublingTime = growthRateParameter.getParameterValue(0);
90 exponentialGrowth.setDoublingTime(doublingTime);
91 }
92
93 return exponentialGrowth;
94 }
95 //
96 // protected stuff
97 //
98
99 Parameter N0Parameter = null;
100 Parameter growthRateParameter = null;
101 ExponentialGrowth exponentialGrowth = null;
102 boolean usingGrowthRate = true;
103 }