Search in sources :

Example 6 with CompoundParameter

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

the class MatrixMatrixProductParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    MatrixParameter[] temp = new MatrixParameter[3];
    temp[0] = (MatrixParameter) xo.getChild(LEFT).getChild(MatrixParameter.class);
    temp[1] = MatrixParameter.recast(((CompoundParameter) xo.getChild(RIGHT).getChild(CompoundParameter.class)).getVariableName(), (CompoundParameter) xo.getChild(RIGHT).getChild(CompoundParameter.class));
    if (xo.getChild(IN_PLACE) != null) {
        temp[2] = (MatrixParameter) xo.getChild(IN_PLACE).getChild(MatrixParameter.class);
    } else {
        int rowDim = temp[0].getRowDimension();
        int colDim = temp[1].getColumnDimension();
        Parameter[] params = new Parameter[colDim];
        for (int i = 0; i < colDim; i++) {
            params[i] = new Parameter.Default(rowDim);
        }
        temp[2] = new MatrixParameter(null, params);
    }
    Parameter ColumnMask;
    if (xo.getChild(COLUMN_MASK) != null)
        ColumnMask = (Parameter) xo.getChild(COLUMN_MASK).getChild(MatrixParameter.class);
    else
        ColumnMask = new Parameter.Default(null, temp[1].getColumnDimension(), 1);
    return new MatrixMatrixProduct(temp, ColumnMask);
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) MatrixParameter(dr.inference.model.MatrixParameter) MatrixMatrixProduct(dr.inference.model.MatrixMatrixProduct) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter)

Example 7 with CompoundParameter

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

the class DirichletProcessPrior method testDirichletProcess.

// END: main
private static void testDirichletProcess(double[] mapping, int categoryCount, double gamma, double expectedLogL) {
    Parameter categoriesParameter = new Parameter.Default(mapping);
    Parameter gammaParameter = new Parameter.Default(gamma);
    CompoundParameter dummy = new CompoundParameter("dummy");
    for (int i = 0; i < categoryCount; i++) {
        dummy.addParameter(new Parameter.Default(1.0));
    }
    DirichletProcessPrior dpp = new DirichletProcessPrior(categoriesParameter, dummy, null, gammaParameter);
    dpp.setVerbose();
    //		int[] counts = dpp.getCounts();
    System.out.println("lnL:          " + dpp.getCategoriesLogDensity());
    System.out.println("expected lnL: " + expectedLogL);
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter)

Example 8 with CompoundParameter

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

the class DirichletProcessOperatorParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    DirichletProcessPrior dpp = (DirichletProcessPrior) xo.getChild(DirichletProcessPrior.class);
    Likelihood likelihood = (Likelihood) xo.getElementFirstChild(DATA_LOG_LIKELIHOOD);
    Parameter categoriesParameter = (Parameter) xo.getElementFirstChild(DirichletProcessPriorParser.CATEGORIES);
    CountableRealizationsParameter allParameters = (CountableRealizationsParameter) xo.getChild(CountableRealizationsParameter.class);
    CompoundParameter uniquelyRealizedParameters = (CompoundParameter) xo.getChild(CompoundParameter.class);
    int M = xo.getIntegerAttribute(MH_STEPS);
    final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    return new // 
    DirichletProcessOperator(// 
    dpp, //
    categoriesParameter, //
    uniquelyRealizedParameters, //
    allParameters, //
    likelihood, //
    M, //
    weight);
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) Likelihood(dr.inference.model.Likelihood) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter)

Example 9 with CompoundParameter

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

the class DiscretizedLociRatesParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final boolean normalize = xo.getAttribute(NORMALIZE, false);
    final double normalizeBranchRateTo = xo.getAttribute(NORMALIZE_MEAN_LOCI_RATE_TO, Double.NaN);
    final int categoryCount = xo.getIntegerAttribute(CATEGORY_COUNT);
    CompoundParameter lociRates = (CompoundParameter) xo.getElementFirstChild(LOCI_RATES);
    Parameter rateCategoryParameter = (Parameter) xo.getElementFirstChild(RATE_CATEGORIES);
    ParametricDistributionModel distributionModel = (ParametricDistributionModel) xo.getElementFirstChild(DISTRIBUTION);
    Logger.getLogger("dr.evomodel").info("Using discretized loci rates model.");
    Logger.getLogger("dr.evomodel").info("Number of categories: " + categoryCount);
    Logger.getLogger("dr.evomodel").info("  parametric model = " + distributionModel.getModelName());
    if (normalize) {
        Logger.getLogger("dr.evomodel").info("   mean rate is normalized to " + normalizeBranchRateTo);
    }
    return new DiscretizedLociRates(lociRates, rateCategoryParameter, distributionModel, normalize, normalizeBranchRateTo, categoryCount);
}
Also used : CompoundParameter(dr.inference.model.CompoundParameter) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) DiscretizedLociRates(dr.oldevomodel.sitemodel.DiscretizedLociRates) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter)

Example 10 with CompoundParameter

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

the class EpochBranchModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Logger.getLogger("dr.evomodel").info("\nUsing multi-epoch branch model.");
    TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
    SubstitutionModel ancestralSubstitutionModel = (SubstitutionModel) xo.getChild(SubstitutionModel.class);
    List<Epoch> epochs = new ArrayList<Epoch>();
    for (int i = 0; i < xo.getChildCount(); i++) {
        if (xo.getChild(i) instanceof XMLObject) {
            XMLObject xoc = (XMLObject) xo.getChild(i);
            if (xoc.getName().equals(EPOCH)) {
                Parameter tt = null;
                if (xoc.hasAttribute(TRANSITION_TIME)) {
                    double t = xoc.getAttribute(TRANSITION_TIME, 0.0);
                    tt = new Parameter.Default(1, t);
                }
                SubstitutionModel s = (SubstitutionModel) xoc.getChild(SubstitutionModel.class);
                if (xoc.hasChildNamed(TRANSITION_TIME)) {
                    if (tt != null) {
                        throw new XMLParseException("An epoch cannot have a transitionTime attribute and a parameter");
                    }
                    tt = (Parameter) xoc.getElementFirstChild(TRANSITION_TIME);
                }
                epochs.add(new Epoch(s, tt));
            }
        }
    }
    Collections.sort(epochs);
    List<SubstitutionModel> substitutionModels = new ArrayList<SubstitutionModel>();
    CompoundParameter transitionTimes = new CompoundParameter("epochTimes");
    for (Epoch epoch : epochs) {
        substitutionModels.add(epoch.substitutionModel);
        transitionTimes.addParameter(epoch.timeParameter);
    }
    substitutionModels.add(ancestralSubstitutionModel);
    return new EpochBranchModel(tree, substitutionModels, transitionTimes);
}
Also used : EpochBranchModel(dr.evomodel.branchmodel.EpochBranchModel) ArrayList(java.util.ArrayList) XMLObject(dr.xml.XMLObject) SubstitutionModel(dr.evomodel.substmodel.SubstitutionModel) CompoundParameter(dr.inference.model.CompoundParameter) TreeModel(dr.evomodel.tree.TreeModel) CompoundParameter(dr.inference.model.CompoundParameter) Parameter(dr.inference.model.Parameter) XMLParseException(dr.xml.XMLParseException)

Aggregations

CompoundParameter (dr.inference.model.CompoundParameter)17 Parameter (dr.inference.model.Parameter)14 TreeModel (dr.evomodel.tree.TreeModel)4 NodeRef (dr.evolution.tree.NodeRef)2 Tree (dr.evolution.tree.Tree)2 Taxon (dr.evolution.util.Taxon)2 TaxonList (dr.evolution.util.TaxonList)2 ParametricDistributionModel (dr.inference.distribution.ParametricDistributionModel)2 Likelihood (dr.inference.model.Likelihood)2 OperatorSchedule (dr.inference.operators.OperatorSchedule)2 SimpleOperatorSchedule (dr.inference.operators.SimpleOperatorSchedule)2 ArrayList (java.util.ArrayList)2 TreeTraitProvider (dr.evolution.tree.TreeTraitProvider)1 ARGLogger (dr.evomodel.arg.ARGLogger)1 ARGReassortmentNodeCountStatistic (dr.evomodel.arg.ARGReassortmentNodeCountStatistic)1 ARGUniformPrior (dr.evomodel.arg.coalescent.ARGUniformPrior)1 EpochBranchModel (dr.evomodel.branchmodel.EpochBranchModel)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)1 MultivariateDiffusionModel (dr.evomodel.continuous.MultivariateDiffusionModel)1