use of dr.evomodel.treedatalikelihood.hmc.DiffusionParametersGradient in project beast-mcmc by beast-dev.
the class DiffusionGradientParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
String traitName = xo.getAttribute(TRAIT_NAME, DEFAULT_TRAIT_NAME);
List<ContinuousTraitGradientForBranch.ContinuousProcessParameterGradient.DerivationParameter> derivationParametersList = new ArrayList<ContinuousTraitGradientForBranch.ContinuousProcessParameterGradient.DerivationParameter>();
CompoundParameter compoundParameter = new CompoundParameter(null);
List<GradientWrtParameterProvider> derivativeList = new ArrayList<GradientWrtParameterProvider>();
List<AbstractDiffusionGradient> diffGradients = xo.getAllChildren(AbstractDiffusionGradient.class);
if (diffGradients != null) {
for (AbstractDiffusionGradient grad : diffGradients) {
derivationParametersList.add(grad.getDerivationParameter());
compoundParameter.addParameter(grad.getRawParameter());
derivativeList.add(grad);
}
}
CompoundGradient parametersGradients = new CompoundDerivative(derivativeList);
// testSameModel(precisionGradient, attenuationGradient);
TreeDataLikelihood treeDataLikelihood = ((TreeDataLikelihood) diffGradients.get(0).getLikelihood());
DataLikelihoodDelegate delegate = treeDataLikelihood.getDataLikelihoodDelegate();
int dim = treeDataLikelihood.getDataLikelihoodDelegate().getTraitDim();
Tree tree = treeDataLikelihood.getTree();
ContinuousDataLikelihoodDelegate continuousData = (ContinuousDataLikelihoodDelegate) delegate;
ContinuousTraitGradientForBranch.ContinuousProcessParameterGradient traitGradient = new ContinuousTraitGradientForBranch.ContinuousProcessParameterGradient(dim, tree, continuousData, derivationParametersList);
BranchSpecificGradient branchSpecificGradient = new BranchSpecificGradient(traitName, treeDataLikelihood, continuousData, traitGradient, compoundParameter);
return new DiffusionParametersGradient(branchSpecificGradient, parametersGradients);
}
Aggregations