Search in sources :

Example 1 with SubtreeJumpOperator

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;
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) AdaptationMode(dr.inference.operators.AdaptationMode) SubtreeJumpOperator(dr.evomodel.operators.SubtreeJumpOperator)

Aggregations

SubtreeJumpOperator (dr.evomodel.operators.SubtreeJumpOperator)1 TreeModel (dr.evomodel.tree.TreeModel)1 AdaptationMode (dr.inference.operators.AdaptationMode)1