| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evolution.coalescent; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class LinearGrowth extends ConstantPopulation |
| 35 |
{ |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public LinearGrowth(Type units) { |
| 45 |
|
| 46 |
super(units); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public double getN0() { return N0; } |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public void setN0(double N0) { this.N0 = N0; } |
| 59 |
|
| 60 |
|
| 61 |
|
| 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 |
|
| 121 |
|
| 122 |
|
| 123 |
private double N0; |
| 124 |
} |