Debian Codegraph @

src/dr/evolution/coalescent/ExponentialLogistic.java

raw symbols SCIP
1 /*
2 * ExponentialLogistic.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.evolution.coalescent;
27
28 /**
29 * Exponential growth followed by Logistic growth.
30 *
31 * @author Andrew Rambaut
32 * @author Alexei Drummond
33 *
34 * @version $Id: ConstLogistic.java,v 1.4 2005/04/11 11:43:03 alexei Exp $
35 *
36 */
37 public class ExponentialLogistic extends LogisticGrowth {
38
39 /**
40 * Construct demographic model with default settings
41 */
42 public ExponentialLogistic(Type units) {
43
44 super(units);
45 }
46
47 public double getTime() {
48 return time;
49 }
50 public void setTime(double time) {
51 this.time = time;
52 }
53
54 public double getR1() {
55 return r1;
56 }
57
58 public void setR1(double r1) {
59 this.r1 = r1;
60 }
61
62 // Implementation of abstract methods
63
64 public double getDemographic(double t) {
65
66 double transition_time = getTime();
67
68 // size of the population under the logistic at transition_time
69 if (t < transition_time) {
70 return super.getDemographic(t);
71 } else {
72 double r1 = getR1();
73 double N1 = super.getDemographic(transition_time);
74 return N1 * Math.exp(-r1*(t - transition_time));
75 }
76 }
77
78 /**
79 * Returns value of demographic intensity function at time t
80 * (= integral 1/N(x) dx from 0 to t).
81 */
82 public double getIntensity(double t) {
83 throw new RuntimeException("Not implemented!");
84 }
85
86 public double getInverseIntensity(double x) {
87
88 throw new RuntimeException("Not implemented!");
89 }
90
91 public double getIntegral(double start, double finish) {
92 //final double v1 = getIntensity(finish) - getIntensity(start);
93 // Until the above getIntensity is implemented, numerically integrate
94 final double numerical = getNumericalIntegral(start, finish);
95 return numerical;
96 }
97
98 public int getNumArguments() {
99 return 5;
100 }
101
102 public String getArgumentName(int n) {
103 switch (n) {
104 case 0: return "N0";
105 case 1: return "r0";
106 case 2: return "c";
107 case 3: return "r1";
108 case 4: return "t1";
109 }
110 throw new IllegalArgumentException("Argument " + n + " does not exist");
111 }
112
113 public double getArgument(int n) {
114 switch (n) {
115 case 0: return getN0();
116 case 1: return getGrowthRate();
117 case 2: return getShape();
118 case 3: return getR1();
119 case 4: return getTime();
120 }
121 throw new IllegalArgumentException("Argument " + n + " does not exist");
122 }
123
124 public void setArgument(int n, double value) {
125 switch (n) {
126 case 0: setN0(value); break;
127 case 1: setGrowthRate(value); break;
128 case 2: setShape(value); break;
129 case 3: setR1(value); break;
130 case 4: setTime(value); break;
131 default: throw new IllegalArgumentException("Argument " + n + " does not exist");
132
133 }
134 }
135
136 public double getLowerBound(int n) {
137 return 0.0;
138 }
139
140 public double getUpperBound(int n) {
141 return Double.POSITIVE_INFINITY;
142 }
143
144 //
145 // private stuff
146 //
147
148 /**
149 * The transition time between exponential and logistic
150 */
151 private double time = 0.0;
152
153 /**
154 * The growth rate of the exponential phase
155 */
156 private double r1 = 0.0;
157
158 }