use of dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform in project beast-mcmc by beast-dev.
the class GMRFSkyrideGradientParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// Parameter parameter = (Parameter) xo.getChild(Parameter.class);
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
OldGMRFSkyrideLikelihood skyrideLikelihood = (OldGMRFSkyrideLikelihood) xo.getChild(OldGMRFSkyrideLikelihood.class);
String wrtParameterCase = (String) xo.getAttribute(WRT_PARAMETER);
GMRFGradient.WrtParameter type = GMRFGradient.WrtParameter.factory(wrtParameterCase);
if (type != null) {
type.getWarning((GMRFMultilocusSkyrideLikelihood) skyrideLikelihood);
return new GMRFGradient((GMRFMultilocusSkyrideLikelihood) skyrideLikelihood, type);
}
// Old behaviour
GMRFSkyrideGradient.WrtParameter wrtParameter = setupWrtParameter(wrtParameterCase);
NodeHeightTransform nodeHeightTransform = (NodeHeightTransform) xo.getChild(NodeHeightTransform.class);
return new GMRFSkyrideGradient(skyrideLikelihood, wrtParameter, tree, nodeHeightTransform);
}
use of dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform in project beast-mcmc by beast-dev.
the class NodeHeightTransformParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(NODEHEIGHT);
Parameter nodeHeightParameter = (Parameter) cxo.getChild(Parameter.class);
Parameter ratioParameter = null;
if (xo.hasChildNamed(RATIO)) {
ratioParameter = (Parameter) xo.getChild(RATIO).getChild(Parameter.class);
}
if (ratioParameter != null) {
if (ratioParameter.getDimension() == 1) {
ratioParameter.setDimension(nodeHeightParameter.getDimension());
}
ratioParameter.addBounds(new Parameter.DefaultBounds(1.0, 0.0, ratioParameter.getDimension()));
}
Parameter coalescentIntervals = null;
OldGMRFSkyrideLikelihood skyrideLikelihood = null;
if (xo.hasChildNamed(COALESCENT_INTERVAL)) {
cxo = xo.getChild(COALESCENT_INTERVAL);
skyrideLikelihood = (OldGMRFSkyrideLikelihood) cxo.getChild(OldGMRFSkyrideLikelihood.class);
}
TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
Transform nodeHeightTransform;
if (ratioParameter != null) {
NodeHeightTransform transform = new NodeHeightTransform(nodeHeightParameter, ratioParameter, tree, branchRateModel);
if (xo.getChild(RATIO).getAttribute(REAL_LINE, false)) {
List<Transform> transforms = new ArrayList<Transform>();
if (nodeHeightParameter.getDimension() != ratioParameter.getDimension()) {
transforms.add(new Transform.LogTransform());
}
for (int i = 0; i < ratioParameter.getDimension(); i++) {
transforms.add(new Transform.LogitTransform());
}
nodeHeightTransform = new Transform.ComposeMultivariable(new Transform.Array(transforms, nodeHeightParameter), transform);
} else {
nodeHeightTransform = transform;
}
} else {
nodeHeightTransform = new NodeHeightTransform(nodeHeightParameter, tree, skyrideLikelihood);
coalescentIntervals = ((NodeHeightTransform) nodeHeightTransform).getParameter();
cxo = xo.getChild(COALESCENT_INTERVAL);
coalescentIntervals.setId(cxo.getId());
cxo.setNativeObject(coalescentIntervals);
}
return nodeHeightTransform;
}
Aggregations