| 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.evomodel.coalescent; |
| 27 |
|
| 28 |
import dr.evolution.coalescent.DemographicFunction; |
| 29 |
import dr.evolution.coalescent.FlexibleGrowth; |
| 30 |
import dr.evomodelxml.coalescent.PeakAndDeclineModelParser; |
| 31 |
import dr.inference.model.Parameter; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class PeakAndDeclineModel extends DemographicModel { |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public PeakAndDeclineModel(Parameter peakValueParameter, Parameter shapeParameter, Parameter peakTimeParameter, |
| 47 |
Type units) { |
| 48 |
|
| 49 |
this(PeakAndDeclineModelParser.PEAK_AND_DECLINE_MODEL, peakValueParameter, shapeParameter, peakTimeParameter, |
| 50 |
units); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public PeakAndDeclineModel(String name, Parameter peakValueParameter, Parameter shapeParameter, |
| 57 |
Parameter peakTimeParameter, Type units) { |
| 58 |
|
| 59 |
super(name); |
| 60 |
|
| 61 |
flexibleGrowth = new FlexibleGrowth(units); |
| 62 |
|
| 63 |
this.peakValueParameter = peakValueParameter; |
| 64 |
addVariable(peakValueParameter); |
| 65 |
peakValueParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 66 |
|
| 67 |
this.peakTimeParameter = peakTimeParameter; |
| 68 |
addVariable(peakTimeParameter); |
| 69 |
peakTimeParameter.addBounds(new Parameter.DefaultBounds(0, Double.NEGATIVE_INFINITY, 1)); |
| 70 |
|
| 71 |
this.shapeParameter = shapeParameter; |
| 72 |
addVariable(shapeParameter); |
| 73 |
shapeParameter.addBounds(new Parameter.DefaultBounds(0, Double.NEGATIVE_INFINITY, 1)); |
| 74 |
|
| 75 |
|
| 76 |
setUnits(units); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public DemographicFunction getDemographicFunction() { |
| 83 |
|
| 84 |
double peakTimeValue = peakTimeParameter.getParameterValue(0); |
| 85 |
double peakValueValue = peakValueParameter.getParameterValue(0); |
| 86 |
double shapeValue = shapeParameter.getParameterValue(0); |
| 87 |
|
| 88 |
double flexibleN0 = peakValueValue*(1-shapeValue)/(shapeValue*peakTimeValue); |
| 89 |
double flexibleK = (-shapeValue/Math.pow(-peakTimeValue, shapeValue-1)); |
| 90 |
|
| 91 |
|
| 92 |
flexibleGrowth.setN0(flexibleN0); |
| 93 |
flexibleGrowth.setK(flexibleK); |
| 94 |
flexibleGrowth.setR(shapeValue); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
return flexibleGrowth; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
Parameter peakValueParameter = null; |
| 106 |
Parameter shapeParameter = null; |
| 107 |
Parameter peakTimeParameter = null; |
| 108 |
FlexibleGrowth flexibleGrowth = null; |
| 109 |
|
| 110 |
} |