| 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.operators; |
| 27 |
|
| 28 |
import dr.inference.model.Parameter; |
| 29 |
import dr.inference.operators.SimpleMCMCOperator; |
| 30 |
import dr.math.MathUtils; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class MicrosatelliteModelSelectOperator extends SimpleMCMCOperator { |
| 38 |
private Parameter parameter; |
| 39 |
private Parameter[] indicators; |
| 40 |
public MicrosatelliteModelSelectOperator(Parameter parameter, Parameter[] indicators, double weight){ |
| 41 |
this.parameter = parameter; |
| 42 |
this.indicators = indicators; |
| 43 |
setWeight(weight); |
| 44 |
} |
| 45 |
|
| 46 |
public String getOperatorName(){ |
| 47 |
return "msatModelSelectOperator("+parameter.getParameterName()+")"; |
| 48 |
} |
| 49 |
|
| 50 |
public final String getPerformanceSuggestion() { |
| 51 |
return "no suggestions available"; |
| 52 |
} |
| 53 |
|
| 54 |
public double doOperation() { |
| 55 |
int index = MathUtils.nextInt(indicators.length); |
| 56 |
|
| 57 |
Parameter newModel = indicators[index]; |
| 58 |
for(int i = 0; i < parameter.getDimension() -1 ; i++){ |
| 59 |
parameter.setParameterValueQuietly(i,newModel.getParameterValue(i)); |
| 60 |
} |
| 61 |
parameter.setParameterValueNotifyChangedAll( |
| 62 |
parameter.getDimension()-1, |
| 63 |
newModel.getParameterValue(parameter.getDimension()-1) |
| 64 |
); |
| 65 |
|
| 66 |
return 0.0; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
} |