use of dr.inference.operators.DeltaExchangeOperator in project beast-mcmc by beast-dev.
the class DeltaExchangeOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
CoercionMode mode = CoercionMode.parseMode(xo);
final boolean isIntegerOperator = xo.getAttribute(INTEGER_OPERATOR, false);
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
double delta = xo.getDoubleAttribute(DELTA);
if (delta <= 0.0) {
throw new XMLParseException("delta must be greater than 0.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 DeltaExchangeOperator(parameter, parameterWeights, delta, weight, isIntegerOperator, mode);
}
Aggregations