Search in sources :

Example 1 with LocalBranchRateGradientForDiscreteTrait

use of dr.evomodel.treedatalikelihood.discrete.LocalBranchRateGradientForDiscreteTrait in project beast-mcmc by beast-dev.

the class BranchRateGradientParser method parseTreeDataLikelihood.

private GradientWrtParameterProvider parseTreeDataLikelihood(TreeDataLikelihood treeDataLikelihood, String traitName, boolean useHessian) throws XMLParseException {
    BranchRateModel branchRateModel = treeDataLikelihood.getBranchRateModel();
    if (branchRateModel instanceof DefaultBranchRateModel || branchRateModel instanceof ArbitraryBranchRates) {
        Parameter branchRates = null;
        if (branchRateModel instanceof ArbitraryBranchRates) {
            branchRates = ((ArbitraryBranchRates) branchRateModel).getRateParameter();
        }
        DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
        if (delegate instanceof ContinuousDataLikelihoodDelegate) {
            ContinuousDataLikelihoodDelegate continuousData = (ContinuousDataLikelihoodDelegate) delegate;
            return new BranchRateGradient(traitName, treeDataLikelihood, continuousData, branchRates);
        } else if (delegate instanceof BeagleDataLikelihoodDelegate) {
            BeagleDataLikelihoodDelegate beagleData = (BeagleDataLikelihoodDelegate) delegate;
            if (branchRateModel instanceof LocalBranchRates) {
                return new LocalBranchRateGradientForDiscreteTrait(traitName, treeDataLikelihood, beagleData, branchRates, useHessian);
            } else {
                return new BranchRateGradientForDiscreteTrait(traitName, treeDataLikelihood, beagleData, branchRates, useHessian);
            }
        } else {
            throw new XMLParseException("Unknown likelihood delegate type");
        }
    } else {
        throw new XMLParseException("Only implemented for an arbitrary rates model");
    }
}
Also used : ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) 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) BranchRateGradient(dr.evomodel.treedatalikelihood.continuous.BranchRateGradient) BranchRateGradientForDiscreteTrait(dr.evomodel.treedatalikelihood.discrete.BranchRateGradientForDiscreteTrait) LocalBranchRateGradientForDiscreteTrait(dr.evomodel.treedatalikelihood.discrete.LocalBranchRateGradientForDiscreteTrait) LocalBranchRateGradientForDiscreteTrait(dr.evomodel.treedatalikelihood.discrete.LocalBranchRateGradientForDiscreteTrait) Parameter(dr.inference.model.Parameter) BeagleDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.BeagleDataLikelihoodDelegate) ContinuousDataLikelihoodDelegate(dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) LocalBranchRates(dr.evomodel.branchratemodel.LocalBranchRates)

Aggregations

ArbitraryBranchRates (dr.evomodel.branchratemodel.ArbitraryBranchRates)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)1 LocalBranchRates (dr.evomodel.branchratemodel.LocalBranchRates)1 BeagleDataLikelihoodDelegate (dr.evomodel.treedatalikelihood.BeagleDataLikelihoodDelegate)1 DataLikelihoodDelegate (dr.evomodel.treedatalikelihood.DataLikelihoodDelegate)1 BranchRateGradient (dr.evomodel.treedatalikelihood.continuous.BranchRateGradient)1 ContinuousDataLikelihoodDelegate (dr.evomodel.treedatalikelihood.continuous.ContinuousDataLikelihoodDelegate)1 BranchRateGradientForDiscreteTrait (dr.evomodel.treedatalikelihood.discrete.BranchRateGradientForDiscreteTrait)1 LocalBranchRateGradientForDiscreteTrait (dr.evomodel.treedatalikelihood.discrete.LocalBranchRateGradientForDiscreteTrait)1 Parameter (dr.inference.model.Parameter)1