| 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.structure; |
| 27 |
|
| 28 |
import dr.evolution.colouring.ColourSampler; |
| 29 |
import dr.inference.operators.SimpleMCMCOperator; |
| 30 |
import dr.xml.*; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@Deprecated |
| 38 |
public class TreeColouringOperator extends SimpleMCMCOperator { |
| 39 |
|
| 40 |
public static final String TREE_COLOURING_OPERATOR = "treeColouringOperator"; |
| 41 |
|
| 42 |
ColourSamplerModel colouringModel; |
| 43 |
ColourSampler colourSampler; |
| 44 |
|
| 45 |
public TreeColouringOperator(ColourSamplerModel colouringModel) { |
| 46 |
|
| 47 |
this.colouringModel = colouringModel; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public String getPerformanceSuggestion() { |
| 54 |
return "This operator cannot be optimized"; |
| 55 |
} |
| 56 |
|
| 57 |
public String getOperatorName() { |
| 58 |
return "twoColourTree"; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public double doOperation() { |
| 67 |
|
| 68 |
double logP = colouringModel.getTreeColouringWithProbability().getLogProbabilityDensity(); |
| 69 |
|
| 70 |
colouringModel.resample(); |
| 71 |
|
| 72 |
double logQ = colouringModel.getTreeColouringWithProbability().getLogProbabilityDensity(); |
| 73 |
|
| 74 |
return logP - logQ; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public static XMLObjectParser PARSER = new AbstractXMLObjectParser() { |
| 81 |
|
| 82 |
public String getParserName() { return TREE_COLOURING_OPERATOR; } |
| 83 |
|
| 84 |
public Object parseXMLObject(XMLObject xo) { |
| 85 |
|
| 86 |
ColourSamplerModel colourSamplerModel = (ColourSamplerModel)xo.getChild(ColourSamplerModel.class); |
| 87 |
|
| 88 |
return new TreeColouringOperator(colourSamplerModel); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public XMLSyntaxRule[] getSyntaxRules() { return rules; } |
| 96 |
|
| 97 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[] { |
| 98 |
new ElementRule(ColourSamplerModel.class), |
| 99 |
}; |
| 100 |
|
| 101 |
public String getParserDescription() { |
| 102 |
return "A tree colouring model."; |
| 103 |
} |
| 104 |
|
| 105 |
public Class getReturnType() { return TreeColouringOperator.class; } |
| 106 |
}; |
| 107 |
|
| 108 |
|
| 109 |
} |