use of dr.inference.operators.AdaptationMode in project beast-mcmc by beast-dev.
the class RateScaleOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.parseMode(xo);
final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
final double scaleFactor = xo.getDoubleAttribute(SCALE_FACTOR);
final boolean noRoot = xo.getBooleanAttribute(NO_ROOT);
if (scaleFactor <= 0.0 || scaleFactor >= 1.0) {
throw new XMLParseException("scaleFactor must be between 0.0 and 1.0");
}
TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
RateScaleOperator operator = new RateScaleOperator(treeModel, scaleFactor, noRoot, mode);
operator.setWeight(weight);
return operator;
}
use of dr.inference.operators.AdaptationMode in project beast-mcmc by beast-dev.
the class LoadingsHamiltonianMCParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
LatentFactorModel lfm = (LatentFactorModel) xo.getChild(LatentFactorModel.class);
MomentDistributionModel prior = (MomentDistributionModel) xo.getChild(MomentDistributionModel.class);
double weight = xo.getDoubleAttribute(WEIGHT);
AdaptationMode mode = AdaptationMode.parseMode(xo);
int nSteps = xo.getIntegerAttribute(N_STEPS);
double stepSize = xo.getDoubleAttribute(STEP_SIZE);
double momentumSd = xo.getDoubleAttribute(MOMENTUM_SD);
MatrixParameter loadings = (MatrixParameter) xo.getChild(MatrixParameter.class);
return new LoadingsHamiltonianMC(lfm, prior, weight, mode, stepSize, nSteps, momentumSd, loadings);
}
use of dr.inference.operators.AdaptationMode in project beast-mcmc by beast-dev.
the class FactorOperatorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.parseMode(xo);
String scaleFactorTemp = (String) xo.getAttribute(SCALE_FACTOR);
double scaleFactor = Double.parseDouble(scaleFactorTemp);
String weightTemp = (String) xo.getAttribute(WEIGHT);
double weight = Double.parseDouble(weightTemp);
DiagonalMatrix diffusionMatrix;
diffusionMatrix = (DiagonalMatrix) xo.getChild(DiagonalMatrix.class);
LatentFactorModel LFM = (LatentFactorModel) xo.getChild(LatentFactorModel.class);
boolean randomScan = xo.getAttribute(RANDOM_SCAN, true);
return new FactorOperator(LFM, weight, randomScan, diffusionMatrix, scaleFactor, mode);
}
use of dr.inference.operators.AdaptationMode in project beast-mcmc by beast-dev.
the class LoadingsIndependenceOperatorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.parseMode(xo);
String scaleFactorTemp = (String) xo.getAttribute(SCALE_FACTOR);
double scaleFactor = Double.parseDouble(scaleFactorTemp);
String weightTemp = (String) xo.getAttribute(WEIGHT);
double weight = Double.parseDouble(weightTemp);
LatentFactorModel LFM = (LatentFactorModel) xo.getChild(LatentFactorModel.class);
DistributionLikelihood prior = (DistributionLikelihood) xo.getChild(DistributionLikelihood.class);
boolean randomScan = xo.getAttribute(RANDOM_SCAN, true);
// To change body of implemented methods use File | Settings | File Templates.
return new LoadingsIndependenceOperator(LFM, prior, weight, randomScan, scaleFactor, mode);
}
use of dr.inference.operators.AdaptationMode in project beast-mcmc by beast-dev.
the class DeltaMixOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
AdaptationMode mode = AdaptationMode.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);
}
Aggregations