| 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 |
|
| 27 |
|
| 28 |
|
| 29 |
package dr.evomodel.operators; |
| 30 |
|
| 31 |
import dr.evomodel.tree.ConditionalCladeFrequency; |
| 32 |
import dr.evomodel.tree.TreeModel; |
| 33 |
import dr.xml.*; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@Deprecated |
| 40 |
public class CCPImportanceDistributionOperator extends |
| 41 |
AbstractImportanceDistributionOperator { |
| 42 |
|
| 43 |
public static final String CCP_IMPORTANCE_DISTRIBUTION_OPERATOR = "CCPImportanceDistributionOperator"; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public CCPImportanceDistributionOperator(TreeModel tree, double weight, |
| 49 |
int samples, int sampleEvery, double epsilon) { |
| 50 |
super(tree, weight, samples, sampleEvery); |
| 51 |
|
| 52 |
probabilityEstimater = new ConditionalCladeFrequency(tree, epsilon); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public CCPImportanceDistributionOperator(TreeModel tree, double weight) { |
| 59 |
super(tree, weight); |
| 60 |
double epsilon = 1 - Math.pow(0.5, 1.0 / 10000); |
| 61 |
probabilityEstimater = new ConditionalCladeFrequency(tree, epsilon); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
@Override |
| 70 |
public String getOperatorName() { |
| 71 |
return CCP_IMPORTANCE_DISTRIBUTION_OPERATOR; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
@Override |
| 82 |
public String getPerformanceSuggestion() { |
| 83 |
if (getAcceptanceProbability() < getMinimumGoodAcceptanceLevel()) { |
| 84 |
return "Try to increase the sample size and/or the steps between each sample."; |
| 85 |
} |
| 86 |
return ""; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
public static XMLObjectParser CCP_IMPORTANCE_DISTRIBUTION_OPERATOR_PARSER = new AbstractXMLObjectParser() { |
| 97 |
|
| 98 |
public String getParserName() { |
| 99 |
return CCP_IMPORTANCE_DISTRIBUTION_OPERATOR; |
| 100 |
} |
| 101 |
|
| 102 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 103 |
|
| 104 |
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class); |
| 105 |
double weight = xo.getDoubleAttribute("weight"); |
| 106 |
int samples = xo.getIntegerAttribute("samples"); |
| 107 |
|
| 108 |
double epsilon = 1 - Math.pow(0.5, 1.0 / samples); |
| 109 |
if (xo.hasAttribute("epsilon")) { |
| 110 |
epsilon = xo.getDoubleAttribute("epsilon"); |
| 111 |
} |
| 112 |
|
| 113 |
int sampleEvery = 10; |
| 114 |
if (xo.hasAttribute("sampleEvery")) { |
| 115 |
sampleEvery = xo.getIntegerAttribute("sampleEvery"); |
| 116 |
} |
| 117 |
|
| 118 |
return new CCPImportanceDistributionOperator(treeModel, weight, |
| 119 |
samples, sampleEvery, epsilon); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
public String getParserDescription() { |
| 129 |
return "This element represents an operator proposing trees from an importance distribution which is created by the conditional clade probabilities."; |
| 130 |
} |
| 131 |
|
| 132 |
public Class getReturnType() { |
| 133 |
return CCPImportanceDistributionOperator.class; |
| 134 |
} |
| 135 |
|
| 136 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 137 |
return rules; |
| 138 |
} |
| 139 |
|
| 140 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 141 |
AttributeRule.newDoubleRule("weight"), |
| 142 |
AttributeRule.newIntegerRule("samples"), |
| 143 |
AttributeRule.newIntegerRule("sampleEvery", true), |
| 144 |
AttributeRule.newDoubleRule("epsilon", true), |
| 145 |
new ElementRule(TreeModel.class)}; |
| 146 |
|
| 147 |
}; |
| 148 |
} |