| 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.alloppnet.operators; |
| 27 |
|
| 28 |
import dr.evomodel.alloppnet.speciation.AlloppSpeciesBindings; |
| 29 |
import dr.evomodel.alloppnet.speciation.AlloppSpeciesNetworkModel; |
| 30 |
import dr.evomodel.alloppnet.parsers.AlloppHybPopSizesScaleParser; |
| 31 |
import dr.inference.operators.SimpleMCMCOperator; |
| 32 |
import dr.math.MathUtils; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public class AlloppHybPopSizesScale extends SimpleMCMCOperator { |
| 39 |
|
| 40 |
private final AlloppSpeciesNetworkModel apspnet; |
| 41 |
private final AlloppSpeciesBindings apsp; |
| 42 |
private final double scalingFactor; |
| 43 |
|
| 44 |
public AlloppHybPopSizesScale(AlloppSpeciesNetworkModel apspnet, AlloppSpeciesBindings apsp, double scalingFactor, double weight) { |
| 45 |
this.apspnet = apspnet; |
| 46 |
this.apsp = apsp; |
| 47 |
this.scalingFactor = scalingFactor; |
| 48 |
setWeight(weight); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
public String getPerformanceSuggestion() { |
| 53 |
return "None"; |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public String getOperatorName() { |
| 58 |
return AlloppHybPopSizesScaleParser.HYB_POP_SIZES_SCALE + "(" + apspnet.getId() + |
| 59 |
"," + apsp.getId() + ")"; |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public double doOperation() { |
| 64 |
apspnet.beginNetworkEdit(); |
| 65 |
double b = (1.0-scalingFactor) * (1.0-scalingFactor) / scalingFactor; |
| 66 |
double c = scalingFactor / (1.0-scalingFactor); |
| 67 |
double y = MathUtils.nextDouble(); |
| 68 |
double s = b * (y+c) * (y+c); |
| 69 |
int i = MathUtils.nextInt(apspnet.getNumberOfTetraTrees()); |
| 70 |
apspnet.setOneHybPopValue(i, s * apspnet.getOneHybPopValue(i)); |
| 71 |
apspnet.endNetworkEdit(); |
| 72 |
return 0.0; |
| 73 |
} |
| 74 |
|
| 75 |
} |