use of dr.evomodel.operators.SubtreeJumpOperator in project beast-mcmc by beast-dev.
the class SubtreeJumpOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.parseMode(xo);
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
// size attribute is mandatory
final double size = xo.getAttribute(SIZE, Double.NaN);
final double targetAcceptance = xo.getAttribute(TARGET_ACCEPTANCE, 0.234);
final boolean uniform = xo.getAttribute(UNIFORM, false);
if (size <= 0.0) {
throw new XMLParseException("The SubTreeLeap size attribute must be positive and non-zero.");
}
if (Double.isInfinite(size)) {
// uniform so no auto optimize
mode = AdaptationMode.ADAPTATION_OFF;
}
if (targetAcceptance <= 0.0 || targetAcceptance >= 1.0) {
throw new XMLParseException("Target acceptance probability has to lie in (0, 1)");
}
SubtreeJumpOperator operator = new SubtreeJumpOperator(treeModel, weight, size, targetAcceptance, uniform, mode);
return operator;
}
Aggregations