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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations