Search in sources :

Example 1 with BranchSpecificFixedEffects

use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.

the class LocationScaleGradientParser method parseTreeDataLikelihood.

private GradientWrtParameterProvider parseTreeDataLikelihood(XMLObject xo, TreeDataLikelihood treeDataLikelihood, String traitName, boolean useHessian) throws XMLParseException {
    BranchRateModel branchRateModel = treeDataLikelihood.getBranchRateModel();
    DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
    if (delegate instanceof ContinuousDataLikelihoodDelegate) {
        throw new XMLParseException("Not yet implemented! ");
    } else if (delegate instanceof BeagleDataLikelihoodDelegate) {
        BeagleDataLikelihoodDelegate beagleData = (BeagleDataLikelihoodDelegate) delegate;
        BranchModel branchModel = beagleData.getBranchModel();
        if (branchRateModel instanceof DefaultBranchRateModel || branchRateModel instanceof ArbitraryBranchRates) {
            if (xo.hasChildNamed(LOCATION)) {
                BranchSpecificFixedEffects location = parseLocation(xo);
                return new LocationGradient(traitName, treeDataLikelihood, beagleData, location, useHessian);
            } else if (xo.hasChildNamed(SCALE)) {
                Parameter scale = (Parameter) xo.getElementFirstChild(SCALE);
                return new ScaleGradient(traitName, treeDataLikelihood, beagleData, scale, useHessian);
            } else {
                throw new XMLParseException("Poorly formed");
            }
        } else if (branchModel instanceof ArbitrarySubstitutionParameterBranchModel) {
            BranchParameter branchParameter = (BranchParameter) xo.getChild(BranchParameter.class);
            if (xo.hasChildNamed(LOCATION)) {
                BranchSpecificFixedEffects location = parseLocation(xo);
                return new BranchSubstitutionParameterLocationGradient(traitName, treeDataLikelihood, beagleData, branchParameter, useHessian, location);
            } else if (xo.hasChildNamed(SCALE)) {
                Parameter scale = (Parameter) xo.getElementFirstChild(SCALE);
                return new BranchSubstitutionParameterScaleGradient(traitName, treeDataLikelihood, beagleData, branchParameter, scale, useHessian);
            } else {
                throw new XMLParseException("Not yet implemented.");
            }
        } else {
            throw new XMLParseException("Only implemented for an arbitrary rates model");
        }
    } else {
        throw new XMLParseException("Unknown likelihood delegate type");
    }
}
Also used : BranchParameter(dr.inference.model.BranchParameter) BeagleDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.BeagleDataLikelihoodDelegate) ArbitrarySubstitutionParameterBranchModel(dr.evomodel.branchmodel.ArbitrarySubstitutionParameterBranchModel) BranchModel(dr.evomodel.branchmodel.BranchModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) ArbitrarySubstitutionParameterBranchModel(dr.evomodel.branchmodel.ArbitrarySubstitutionParameterBranchModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) ContinuousDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate) BeagleDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.BeagleDataLikelihoodDelegate) DataLikelihoodDelegate(dr.evomodel.treedatalikelihood.DataLikelihoodDelegate) Parameter(dr.inference.model.Parameter) BranchParameter(dr.inference.model.BranchParameter) ContinuousDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate) BranchSpecificFixedEffects(dr.evomodel.branchratemodel.BranchSpecificFixedEffects)

Example 2 with BranchSpecificFixedEffects

use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.

the class LocationScaleGradientParser method parseLocation.

private BranchSpecificFixedEffects parseLocation(XMLObject xo) throws XMLParseException {
    Object locationObject = xo.getElementFirstChild(LOCATION);
    BranchSpecificFixedEffects location;
    if (locationObject instanceof Parameter) {
        location = new BranchSpecificFixedEffects.None((Parameter) xo.getElementFirstChild(LOCATION));
    } else if (locationObject instanceof BranchSpecificFixedEffects) {
        location = (BranchSpecificFixedEffects) locationObject;
    } else if (locationObject instanceof ArbitraryBranchRates.BranchRateTransform.LocationScaleLogNormal) {
        location = ((ArbitraryBranchRates.BranchRateTransform.LocationScaleLogNormal) locationObject).getLocationObject();
    } else {
        throw new XMLParseException("Poorly formed");
    }
    return location;
}
Also used : ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) Parameter(dr.inference.model.Parameter) BranchParameter(dr.inference.model.BranchParameter) BranchSpecificFixedEffects(dr.evomodel.branchratemodel.BranchSpecificFixedEffects)

Example 3 with BranchSpecificFixedEffects

use of dr.evomodel.branchratemodel.BranchSpecificFixedEffects in project beast-mcmc by beast-dev.

the class ArbitraryBranchRatesParser method parseTransform.

static ArbitraryBranchRates.BranchRateTransform parseTransform(XMLObject xo) throws XMLParseException {
    boolean reciprocal = xo.getAttribute(RECIPROCAL, false);
    Logger.getLogger("dr.evomodel").info("  reciprocal = " + reciprocal);
    boolean exp = xo.getAttribute(EXP, false);
    boolean multiplier = xo.getAttribute(MULTIPLIER, false);
    BranchSpecificFixedEffects locationParameter = null;
    if (xo.hasChildNamed(LOCATION)) {
        Object locationObject = xo.getElementFirstChild(LOCATION);
        if (locationObject instanceof BranchSpecificFixedEffects) {
            locationParameter = (BranchSpecificFixedEffects) locationObject;
        } else {
            locationParameter = new BranchSpecificFixedEffects.None((Parameter) locationObject);
        }
    }
    Parameter scaleParameter = null;
    if (xo.hasChildNamed(SCALE)) {
        scaleParameter = (Parameter) xo.getElementFirstChild(SCALE);
    }
    return make(reciprocal, exp, multiplier, locationParameter, scaleParameter);
}
Also used : Parameter(dr.inference.model.Parameter) BranchSpecificFixedEffects(dr.evomodel.branchratemodel.BranchSpecificFixedEffects)

Aggregations

BranchSpecificFixedEffects (dr.evomodel.branchratemodel.BranchSpecificFixedEffects)3 Parameter (dr.inference.model.Parameter)3 ArbitraryBranchRates (dr.evomodel.branchratemodel.ArbitraryBranchRates)2 BranchParameter (dr.inference.model.BranchParameter)2 ArbitrarySubstitutionParameterBranchModel (dr.evomodel.branchmodel.ArbitrarySubstitutionParameterBranchModel)1 BranchModel (dr.evomodel.branchmodel.BranchModel)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)1 BeagleDataLikelihoodDelegate (dr.evomodel.treedatalikelihood.BeagleDataLikelihoodDelegate)1 DataLikelihoodDelegate (dr.evomodel.treedatalikelihood.DataLikelihoodDelegate)1 ContinuousDataLikelihoodDelegate (dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate)1