Debian Codegraph @

src/dr/evomodel/coalescent/ExponentialExponentialModel.java

raw symbols SCIP
1 /*
2 * ExponentialExponentialModel.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.ExponentialExponential;
30 import dr.evomodelxml.coalescent.ExponentialExponentialModelParser;
31 import dr.inference.model.Parameter;
32
33 /**
34 * Exponential growth followed by a different phase of exponential growth.
35 *
36 * @author Andrew Rambaut
37 */
38 public class ExponentialExponentialModel extends DemographicModel {
39
40 //
41 // Public stuff
42 //
43
44 /**
45 * Construct demographic model with default settings
46 */
47 public ExponentialExponentialModel(Parameter N0Parameter,
48 Parameter growthRateParameter,
49 Parameter ancestralGrowthRateParameter,
50 Parameter transitionTimeParameter,
51 Type units) {
52
53 this(ExponentialExponentialModelParser.EXPONENTIAL_EXPONENTIAL_MODEL,
54 N0Parameter,
55 growthRateParameter,
56 ancestralGrowthRateParameter,
57 transitionTimeParameter,
58 units);
59 }
60
61 /**
62 * Construct demographic model with default settings
63 */
64 public ExponentialExponentialModel(String name, Parameter N0Parameter,
65 Parameter growthRateParameter,
66 Parameter ancestralGrowthRateParameter,
67 Parameter transitionTimeParameter,
68 Type units) {
69
70 super(name);
71
72 exponentialExponential = new ExponentialExponential(units);
73
74 this.N0Parameter = N0Parameter;
75 addVariable(N0Parameter);
76 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
77
78 this.growthRateParameter = growthRateParameter;
79 addVariable(growthRateParameter);
80 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
81
82 this.ancestralGrowthRateParameter = ancestralGrowthRateParameter;
83 addVariable(ancestralGrowthRateParameter);
84 ancestralGrowthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
85
86 this.transitionTimeParameter = transitionTimeParameter;
87 addVariable(transitionTimeParameter);
88 transitionTimeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY,
89 Double.NEGATIVE_INFINITY, 1));
90
91 setUnits(units);
92 }
93
94
95 // general functions
96
97 public DemographicFunction getDemographicFunction() {
98 exponentialExponential.setN0(N0Parameter.getParameterValue(0));
99
100 exponentialExponential.setGrowthRate(growthRateParameter.getParameterValue(0));
101
102 exponentialExponential.setAncestralGrowthRate(ancestralGrowthRateParameter.getParameterValue(0));
103
104 exponentialExponential.setTransitionTime(transitionTimeParameter.getParameterValue(0));
105
106 return exponentialExponential;
107 }
108
109 //
110 // protected stuff
111 //
112
113 Parameter N0Parameter = null;
114 Parameter growthRateParameter = null;
115 Parameter ancestralGrowthRateParameter = null;
116 Parameter transitionTimeParameter = null;
117 ExponentialExponential exponentialExponential = null;
118 }