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");
}
}
Aggregations