use of dr.evomodel.branchratemodel.LocalBranchRates 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");
}
}
use of dr.evomodel.branchratemodel.LocalBranchRates in project beast-mcmc by beast-dev.
the class LocalBranchRatesParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
BranchRateTransform transform = (BranchRateTransform) xo.getChild(BranchRateTransform.class);
if (transform == null) {
transform = new BranchRateTransform.None();
}
Parameter multipllierParameter = (Parameter) xo.getChild(Parameter.class);
final int numBranches = tree.getNodeCount() - 1;
if (multipllierParameter.getDimension() != numBranches) {
multipllierParameter.setDimension(numBranches);
}
return new LocalBranchRates(tree, multipllierParameter, transform);
}
Aggregations