Search in sources :

Example 1 with GradientProvider

use of dr.inference.model.GradientProvider in project beast-mcmc by beast-dev.

the class GradientWrapperParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Object obj = xo.getChild(0);
    if (obj instanceof MultivariateDistributionLikelihood) {
        final MultivariateDistributionLikelihood mdl = (MultivariateDistributionLikelihood) xo.getChild(MultivariateDistributionLikelihood.class);
        if (!(mdl.getDistribution() instanceof GradientProvider)) {
            throw new XMLParseException("Not a gradient provider");
        }
        final GradientProvider provider = (GradientProvider) mdl.getDistribution();
        final Parameter parameter = mdl.getDataParameter();
        return new GradientWrtParameterProvider.ParameterWrapper(provider, parameter, mdl);
    } else {
        DistributionLikelihood dl = (DistributionLikelihood) obj;
        if (!(dl.getDistribution() instanceof GradientProvider)) {
            throw new XMLParseException("Not a gradient provider");
        }
        throw new RuntimeException("Not yet implemented");
    }
}
Also used : MultivariateDistributionLikelihood(dr.inference.distribution.MultivariateDistributionLikelihood) GradientProvider(dr.inference.model.GradientProvider) Parameter(dr.inference.model.Parameter) DistributionLikelihood(dr.inference.distribution.DistributionLikelihood) MultivariateDistributionLikelihood(dr.inference.distribution.MultivariateDistributionLikelihood)

Aggregations

DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)1 MultivariateDistributionLikelihood (dr.inference.distribution.MultivariateDistributionLikelihood)1 GradientProvider (dr.inference.model.GradientProvider)1 Parameter (dr.inference.model.Parameter)1