Search in sources :

Example 1 with NodeHeightTransform

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);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) GMRFSkyrideGradient(dr.evomodel.coalescent.GMRFSkyrideGradient) NodeHeightTransform(dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform) OldGMRFSkyrideLikelihood(dr.evomodel.coalescent.OldGMRFSkyrideLikelihood) GMRFGradient(dr.evomodel.coalescent.hmc.GMRFGradient)

Example 2 with 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;
}
Also used : NodeHeightTransform(dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform) OldGMRFSkyrideLikelihood(dr.evomodel.coalescent.OldGMRFSkyrideLikelihood) ArrayList(java.util.ArrayList) TreeModel(dr.evomodel.tree.TreeModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) Parameter(dr.inference.model.Parameter) NodeHeightTransform(dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform) Transform(dr.util.Transform)

Aggregations

OldGMRFSkyrideLikelihood (dr.evomodel.coalescent.OldGMRFSkyrideLikelihood)2 TreeModel (dr.evomodel.tree.TreeModel)2 NodeHeightTransform (dr.evomodel.treedatalikelihood.discrete.NodeHeightTransform)2 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 GMRFSkyrideGradient (dr.evomodel.coalescent.GMRFSkyrideGradient)1 GMRFGradient (dr.evomodel.coalescent.hmc.GMRFGradient)1 Parameter (dr.inference.model.Parameter)1 Transform (dr.util.Transform)1 ArrayList (java.util.ArrayList)1