Debian Codegraph @

src/dr/evolution/coalescent/LinearGrowth.java

raw symbols SCIP
1 /*
2 * LinearGrowth.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 * Under the assumption that the effective population size at time zero was zero (and all coalescent events are
30 * before zero in backwards time), this models linear population groth
31 *
32 * @author Matthew Hall
33 */
34 public class LinearGrowth extends ConstantPopulation
35 {
36 //
37 // Public stuff
38 //
39
40 /**
41 * Construct demographic model with default settings
42 * @param units
43 */
44 public LinearGrowth(Type units) {
45
46 super(units);
47 }
48
49 /**
50 * @return initial population size.
51 */
52 public double getN0() { return N0; }
53
54 /**
55 * sets initial population size.
56 * @param N0 new size
57 */
58 public void setN0(double N0) { this.N0 = N0; }
59
60
61 // Implementation of abstract methods
62
63 public double getDemographic(double t) {
64 if(t>0){
65 throw new RuntimeException("Negative times only!");
66 }
67
68 return -getN0()*t;
69 }
70 public double getIntensity(double t) {
71 throw new RuntimeException("getIntensity is not implemented (and not finite); use getIntegral instead");
72 }
73
74 public double getInverseIntensity(double x) {
75 throw new RuntimeException("Not implemented");
76 }
77
78 public double getIntegral(double start, double finish) {
79 return 1/getN0() * Math.log((-start)/(-finish));
80 }
81
82 public double getInverseIntegral(double x, double start){
83
84 return start*Math.exp(-(x*getN0()));
85
86 }
87
88 public int getNumArguments() {
89 return 1;
90 }
91
92 public String getArgumentName(int n) {
93 return "N0";
94 }
95
96 public double getArgument(int n) {
97 return getN0();
98 }
99
100 public void setArgument(int n, double value) {
101 setN0(value);
102 }
103
104 public double getLowerBound(int n) {
105 return 0.0;
106 }
107
108 public double getUpperBound(int n) {
109 return Double.POSITIVE_INFINITY;
110 }
111
112 public DemographicFunction getCopy() {
113 LinearGrowth df = new LinearGrowth(getUnits());
114 df.N0 = N0;
115
116 return df;
117 }
118
119 //
120 // private stuff
121 //
122
123 private double N0;
124 }