Search in sources :

Example 1 with TreeTipGradient

use of dr.evomodel.treedatalikelihood.continuous.TreeTipGradient in project beast-mcmc by beast-dev.

the class FullyConjugateTreeTipsPotentialDerivativeParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    // String name = xo.hasId() ? xo.getId() : FULLY_CONJUGATE_TREE_TIPS_POTENTIAL_DERIVATIVE2;
    String traitName = xo.getAttribute(TRAIT_NAME, DEFAULT_TRAIT_NAME);
    // Object co = xo.getChild(0);
    final FullyConjugateMultivariateTraitLikelihood fcTreeLikelihood = (FullyConjugateMultivariateTraitLikelihood) xo.getChild(FullyConjugateMultivariateTraitLikelihood.class);
    final TreeDataLikelihood treeDataLikelihood = (TreeDataLikelihood) xo.getChild(TreeDataLikelihood.class);
    Parameter mask = null;
    if (xo.hasChildNamed(MASKING)) {
        mask = (Parameter) xo.getElementFirstChild(MASKING);
    }
    if (fcTreeLikelihood != null) {
        return new FullyConjugateTreeTipsPotentialDerivative(fcTreeLikelihood, mask);
    } else if (treeDataLikelihood != null) {
        DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
        if (!(delegate instanceof ContinuousDataLikelihoodDelegate)) {
            throw new XMLParseException("May not provide a sequence data likelihood to compute tip trait gradient");
        }
        final ContinuousDataLikelihoodDelegate continuousData = (ContinuousDataLikelihoodDelegate) delegate;
        return new TreeTipGradient(traitName, treeDataLikelihood, continuousData, mask);
    } else {
        throw new XMLParseException("Must provide a tree likelihood");
    }
}
Also used : TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) ContinuousDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate) DataLikelihoodDelegate(dr.evomodel.treedatalikelihood.DataLikelihoodDelegate) Parameter(dr.inference.model.Parameter) TreeTipGradient(dr.evomodel.treedatalikelihood.continuous.TreeTipGradient) FullyConjugateTreeTipsPotentialDerivative(dr.evomodel.continuous.hmc.FullyConjugateTreeTipsPotentialDerivative) ContinuousDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate) FullyConjugateMultivariateTraitLikelihood(dr.evomodel.continuous.FullyConjugateMultivariateTraitLikelihood)

Aggregations

FullyConjugateMultivariateTraitLikelihood (dr.evomodel.continuous.FullyConjugateMultivariateTraitLikelihood)1 FullyConjugateTreeTipsPotentialDerivative (dr.evomodel.continuous.hmc.FullyConjugateTreeTipsPotentialDerivative)1 DataLikelihoodDelegate (dr.evomodel.treedatalikelihood.DataLikelihoodDelegate)1 TreeDataLikelihood (dr.evomodel.treedatalikelihood.TreeDataLikelihood)1 ContinuousDataLikelihoodDelegate (dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate)1 TreeTipGradient (dr.evomodel.treedatalikelihood.continuous.TreeTipGradient)1 Parameter (dr.inference.model.Parameter)1