Search in sources :

Example 1 with DeltaMixOperator

use of dr.inference.operators.DeltaMixOperator in project beast-mcmc by beast-dev.

the class DeltaMixOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    CoercionMode mode = CoercionMode.parseMode(xo);
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    double delta = xo.getDoubleAttribute(DELTA);
    if (delta <= 0.0 || delta >= 1) {
        throw new XMLParseException("delta must be between 0.0 and 1.0");
    }
    Parameter parameter = (Parameter) xo.getChild(Parameter.class);
    int[] parameterWeights;
    if (xo.hasAttribute(PARAMETER_WEIGHTS)) {
        parameterWeights = xo.getIntegerArrayAttribute(PARAMETER_WEIGHTS);
        System.out.print("Parameter weights for delta exchange are: ");
        for (int parameterWeight : parameterWeights) {
            System.out.print(parameterWeight + "\t");
        }
        System.out.println();
    } else {
        parameterWeights = new int[parameter.getDimension()];
        for (int i = 0; i < parameterWeights.length; i++) {
            parameterWeights[i] = 1;
        }
    }
    if (parameterWeights.length != parameter.getDimension()) {
        throw new XMLParseException("parameter weights have the same length as parameter");
    }
    return new DeltaMixOperator(parameter, parameterWeights, delta, weight, mode);
}
Also used : Parameter(dr.inference.model.Parameter) DeltaMixOperator(dr.inference.operators.DeltaMixOperator) CoercionMode(dr.inference.operators.CoercionMode)

Aggregations

Parameter (dr.inference.model.Parameter)1 CoercionMode (dr.inference.operators.CoercionMode)1 DeltaMixOperator (dr.inference.operators.DeltaMixOperator)1