Search in sources :

Example 16 with AdaptationMode

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

Example 17 with AdaptationMode

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);
}
Also used : AdaptationMode(dr.inference.operators.AdaptationMode) MatrixParameter(dr.inference.model.MatrixParameter) LatentFactorModel(dr.inference.model.LatentFactorModel) MomentDistributionModel(dr.inference.distribution.MomentDistributionModel)

Example 18 with AdaptationMode

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);
}
Also used : AdaptationMode(dr.inference.operators.AdaptationMode) DiagonalMatrix(dr.inference.model.DiagonalMatrix) FactorOperator(dr.inference.operators.factorAnalysis.FactorOperator) LatentFactorModel(dr.inference.model.LatentFactorModel)

Example 19 with AdaptationMode

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);
}
Also used : AdaptationMode(dr.inference.operators.AdaptationMode) LoadingsIndependenceOperator(dr.inference.operators.factorAnalysis.LoadingsIndependenceOperator) LatentFactorModel(dr.inference.model.LatentFactorModel) DistributionLikelihood(dr.inference.distribution.DistributionLikelihood)

Example 20 with AdaptationMode

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);
}
Also used : AdaptationMode(dr.inference.operators.AdaptationMode) Parameter(dr.inference.model.Parameter) DeltaMixOperator(dr.inference.operators.DeltaMixOperator)

Aggregations

AdaptationMode (dr.inference.operators.AdaptationMode)25 TreeModel (dr.evomodel.tree.TreeModel)8 Parameter (dr.inference.model.Parameter)8 LatentFactorModel (dr.inference.model.LatentFactorModel)5 GaussianProcessSkytrackLikelihood (dr.evomodel.coalescent.GaussianProcessSkytrackLikelihood)2 SubtreeLeapOperator (dr.evomodel.operators.SubtreeLeapOperator)2 DiagonalMatrix (dr.inference.model.DiagonalMatrix)2 MatrixParameter (dr.inference.model.MatrixParameter)2 Transform (dr.util.Transform)2 IOException (java.io.IOException)2 NodeRef (dr.evolution.tree.NodeRef)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1 CladeAwareSubtreeLeap (dr.evomodel.bigfasttree.constrainedtree.CladeAwareSubtreeLeap)1 CladeNodeModel (dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel)1 GMRFMultilocusSkyrideLikelihood (dr.evomodel.coalescent.GMRFMultilocusSkyrideLikelihood)1 GMRFSkygridLikelihood (dr.evomodel.coalescent.GMRFSkygridLikelihood)1 OldGMRFSkyrideLikelihood (dr.evomodel.coalescent.OldGMRFSkyrideLikelihood)1 GMRFMultilocusSkyrideBlockUpdateOperator (dr.evomodel.coalescent.operators.GMRFMultilocusSkyrideBlockUpdateOperator)1 GMRFSkygridBlockUpdateOperator (dr.evomodel.coalescent.operators.GMRFSkygridBlockUpdateOperator)1