| 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 |
public class ExponentialExponential extends ExponentialGrowth { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public ExponentialExponential(Type units) { |
| 39 |
|
| 40 |
super(units); |
| 41 |
} |
| 42 |
|
| 43 |
public double getTransitionTime() { return transitionTime; } |
| 44 |
public void setTransitionTime(double transitionTime) { this.transitionTime = transitionTime; } |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public final double getAncestralGrowthRate() { return r1; } |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public void setAncestralGrowthRate(double r1) { this.r1 = r1; } |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public double getDemographic(double t) { |
| 61 |
|
| 62 |
double N0 = getN0(); |
| 63 |
double r = getGrowthRate(); |
| 64 |
double r1 = getAncestralGrowthRate(); |
| 65 |
double changeTime = getTransitionTime(); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
if(t < changeTime) { |
| 70 |
return N0*Math.exp(-r * t); |
| 71 |
} |
| 72 |
|
| 73 |
double N1 = N0 * Math.exp(-r * changeTime); |
| 74 |
|
| 75 |
return N1 * Math.exp(-r1* (t - changeTime)); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
public double getIntegral(double start, double finish) |
| 82 |
{ |
| 83 |
return getNumericalIntegral(start, finish); |
| 84 |
} |
| 85 |
|
| 86 |
public double getIntensity(double t) { |
| 87 |
|
| 88 |
throw new RuntimeException("Not implemented!"); |
| 89 |
} |
| 90 |
|
| 91 |
public double getInverseIntensity(double x) { |
| 92 |
throw new RuntimeException("Not implemented!"); |
| 93 |
} |
| 94 |
|
| 95 |
public int getNumArguments() { |
| 96 |
return 4; |
| 97 |
} |
| 98 |
|
| 99 |
public String getArgumentName(int n) { |
| 100 |
switch (n) { |
| 101 |
case 0: return "N0"; |
| 102 |
case 1: return "r0"; |
| 103 |
case 2: return "r1"; |
| 104 |
case 3: return "transitionTime"; |
| 105 |
} |
| 106 |
throw new IllegalArgumentException("Argument " + n + " does not exist"); |
| 107 |
} |
| 108 |
|
| 109 |
public double getArgument(int n) { |
| 110 |
switch (n) { |
| 111 |
case 0: return getN0(); |
| 112 |
case 1: return getGrowthRate(); |
| 113 |
case 2: return getAncestralGrowthRate(); |
| 114 |
case 3: return getTransitionTime(); |
| 115 |
} |
| 116 |
throw new IllegalArgumentException("Argument " + n + " does not exist"); |
| 117 |
} |
| 118 |
|
| 119 |
public void setArgument(int n, double value) { |
| 120 |
switch (n) { |
| 121 |
case 0: setN0(value); break; |
| 122 |
case 1: setGrowthRate(value); break; |
| 123 |
case 2: setAncestralGrowthRate(value); break; |
| 124 |
case 3: setTransitionTime(value); break; |
| 125 |
default: throw new IllegalArgumentException("Argument " + n + " does not exist"); |
| 126 |
|
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
public double getLowerBound(int n) { |
| 131 |
switch (n) { |
| 132 |
case 0: return 0; |
| 133 |
case 1: return Double.NEGATIVE_INFINITY; |
| 134 |
case 2: return Double.NEGATIVE_INFINITY; |
| 135 |
case 3: return Double.NEGATIVE_INFINITY; |
| 136 |
default: throw new IllegalArgumentException("Argument " + n + " does not exist"); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
public double getUpperBound(int n) { |
| 141 |
return Double.POSITIVE_INFINITY; |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
private double transitionTime; |
| 149 |
private double r1; |
| 150 |
} |