Search in sources :

Example 76 with Parameter

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

the class SingleTipObservationProcessParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter mu = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.DEATH_RATE);
    Parameter lam = (Parameter) xo.getElementFirstChild(AnyTipObservationProcessParser.IMMIGRATION_RATE);
    TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
    PatternList patterns = (PatternList) xo.getChild(PatternList.class);
    Taxon sourceTaxon = (Taxon) xo.getChild(Taxon.class);
    SiteModel siteModel = (SiteModel) xo.getChild(SiteModel.class);
    BranchRateModel branchRateModel = (BranchRateModel) xo.getChild(BranchRateModel.class);
    Logger.getLogger("dr.evomodel.MSSD").info("Creating SingleTipObservationProcess model. All traits are assumed extant in " + sourceTaxon.getId() + "Initial mu = " + mu.getParameterValue(0) + " initial lam = " + lam.getParameterValue(0));
    return new SingleTipObservationProcess(treeModel, patterns, siteModel, branchRateModel, mu, lam, sourceTaxon);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) SingleTipObservationProcess(dr.oldevomodel.MSSD.SingleTipObservationProcess) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) Taxon(dr.evolution.util.Taxon) PatternList(dr.evolution.alignment.PatternList) Parameter(dr.inference.model.Parameter) SiteModel(dr.oldevomodel.sitemodel.SiteModel)

Example 77 with Parameter

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

the class BifractionalDiffusionModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(ALPHA_PARAMETER);
    Parameter alpha = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(BETA_PARAMETER);
    Parameter beta = (Parameter) cxo.getChild(Parameter.class);
    return new BifractionalDiffusionModel(alpha, beta);
}
Also used : BifractionalDiffusionModel(dr.evomodel.continuous.BifractionalDiffusionModel) Parameter(dr.inference.model.Parameter)

Example 78 with Parameter

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

the class MarkovJumpsTreeLikelihoodParser method parseAllChildren.

public static int parseAllChildren(XMLObject xo, MarkovJumpsRegisterAcceptor acceptor, int stateCount, String jumpTag, MarkovJumpsType type, boolean scaleRewards) throws XMLParseException {
    int registersFound = 0;
    for (int i = 0; i < xo.getChildCount(); i++) {
        Object obj = xo.getChild(i);
        if (obj instanceof Parameter) {
            Parameter registerParameter = (Parameter) obj;
            if (type == MarkovJumpsType.COUNTS && registerParameter.getDimension() != stateCount * stateCount) {
                if (registerParameter.getDimension() == 1) {
                    // if the dimension hasn't been set then default to counting all jumps
                    registerParameter.setDimension(stateCount * stateCount);
                    for (int j = 0; j < stateCount; j++) {
                        for (int k = 0; k < stateCount; k++) {
                            registerParameter.setParameterValueQuietly((j * stateCount) + k, (j == k ? 0.0 : 1.0));
                        }
                    }
                } else {
                    throw new XMLParseException("Markov Jumps register parameter " + registerParameter.getId() + " is of the wrong dimension");
                }
            }
            if (type == MarkovJumpsType.REWARDS && registerParameter.getDimension() != stateCount) {
                if (registerParameter.getDimension() == 1) {
                    // if the dimension hasn't been set then default to getting rewards for all states
                    registerParameter.setDimension(stateCount);
                    for (int j = 0; j < stateCount; j++) {
                        registerParameter.setParameterValueQuietly(j, 1.0);
                    }
                } else {
                    throw new XMLParseException("Markov Rewards register parameter " + registerParameter.getId() + " is of the wrong dimension");
                }
            }
            if (registerParameter.getId() == null) {
                registerParameter.setId(jumpTag + (registersFound + 1));
            }
            acceptor.addRegister(registerParameter, type, scaleRewards);
            registersFound++;
        }
    }
    return registersFound;
}
Also used : Parameter(dr.inference.model.Parameter)

Example 79 with Parameter

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

the class SampleNonActiveGibbsOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    XMLObject cxo = xo.getChild(DISTRIBUTION);
    ParametricDistributionModel distribution = (ParametricDistributionModel) cxo.getChild(ParametricDistributionModel.class);
    cxo = xo.getChild(DATA_PARAMETER);
    Parameter data = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(INDICATOR_PARAMETER);
    Parameter indicators = (Parameter) cxo.getChild(Parameter.class);
    return new SampleNonActiveGibbsOperator(distribution, data, indicators, weight);
}
Also used : SampleNonActiveGibbsOperator(dr.evomodel.coalescent.operators.SampleNonActiveGibbsOperator) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) Parameter(dr.inference.model.Parameter)

Example 80 with Parameter

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

the class DataFromTreeTipsParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    TreeTraitParserUtilities utilities = new TreeTraitParserUtilities();
    String traitName = (String) xo.getAttribute(TreeTraitParserUtilities.TRAIT_NAME);
    MultivariateTraitTree treeModel = (MultivariateTraitTree) xo.getChild(MultivariateTraitTree.class);
    TreeTraitParserUtilities.TraitsAndMissingIndices returnValue = utilities.parseTraitsFromTaxonAttributes(xo, traitName, treeModel, true);
    MatrixParameter dataParameter = MatrixParameter.recast(returnValue.traitParameter.getId(), returnValue.traitParameter);
    if (xo.hasChildNamed(TreeTraitParserUtilities.MISSING)) {
        Parameter missing = (Parameter) xo.getChild(TreeTraitParserUtilities.MISSING).getChild(Parameter.class);
        missing.setDimension(dataParameter.getDimension());
        for (int i = 0; i < missing.getDimension(); i++) {
            if (returnValue.missingIndices.contains(i)) {
                missing.setParameterValue(i, 1);
            } else {
                missing.setParameterValue(i, 0);
            }
        }
    }
    return dataParameter;
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) TreeTraitParserUtilities(dr.evomodelxml.treelikelihood.TreeTraitParserUtilities) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter) MultivariateTraitTree(dr.evolution.tree.MultivariateTraitTree)

Aggregations

Parameter (dr.inference.model.Parameter)397 TreeModel (dr.evomodel.tree.TreeModel)62 MatrixParameter (dr.inference.model.MatrixParameter)46 ArrayList (java.util.ArrayList)44 FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)43 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)41 Units (dr.evolution.util.Units)36 XMLUnits (dr.evoxml.util.XMLUnits)36 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)30 Tree (dr.evolution.tree.Tree)25 DataType (dr.evolution.datatype.DataType)24 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)23 CompoundParameter (dr.inference.model.CompoundParameter)23 GammaSiteModel (dr.oldevomodel.sitemodel.GammaSiteModel)21 SitePatterns (dr.evolution.alignment.SitePatterns)20 HKY (dr.evomodel.substmodel.nucleotide.HKY)17 Likelihood (dr.inference.model.Likelihood)17 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)16 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)16 ParametricDistributionModel (dr.inference.distribution.ParametricDistributionModel)16