use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class ScaledPiecewiseModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(EPOCH_SIZES);
Parameter epochSizes = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(TREE_MODEL);
TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
boolean isLinear = xo.getBooleanAttribute("linear");
return new ScaledPiecewiseModel(epochSizes, treeModel, isLinear, units);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class TwoEpochDemographicModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(EPOCH_1);
DemographicModel demo1 = (DemographicModel) cxo.getChild(DemographicModel.class);
cxo = xo.getChild(EPOCH_2);
DemographicModel demo2 = (DemographicModel) cxo.getChild(DemographicModel.class);
cxo = xo.getChild(TRANSITION_TIME);
Parameter timeParameter = (Parameter) cxo.getChild(Parameter.class);
return new TwoEpochDemographicModel(demo1, demo2, timeParameter, units);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class VariableSkylineLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(POPULATION_SIZES);
Parameter param = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(INDICATOR_PARAMETER);
Parameter param2 = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(CoalescentLikelihoodParser.POPULATION_TREE);
TreeModel treeModel = (TreeModel) cxo.getChild(TreeModel.class);
VariableSkylineLikelihood.Type type = VariableSkylineLikelihood.Type.STEPWISE;
if (xo.hasAttribute(TYPE)) {
final String s = xo.getStringAttribute(TYPE);
if (s.equalsIgnoreCase(STEPWISE)) {
type = VariableSkylineLikelihood.Type.STEPWISE;
} else if (s.equalsIgnoreCase(LINEAR)) {
type = VariableSkylineLikelihood.Type.LINEAR;
} else if (s.equalsIgnoreCase(EXPONENTIAL)) {
type = VariableSkylineLikelihood.Type.EXPONENTIAL;
} else {
throw new XMLParseException("Unknown Bayesian Skyline type: " + s);
}
}
boolean logSpace = xo.getBooleanAttribute(LOG_SPACE);
Logger.getLogger("dr.evomodel").info("Variable skyline plot: " + type.toString() + " control points");
return new VariableSkylineLikelihood(treeModel, param, param2, type, logSpace);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class BayesianSkylineGibbsOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
final double lowerBound = xo.getAttribute(LOWER, 0.0);
final double upperBound = xo.getAttribute(UPPER, Double.MAX_VALUE);
final boolean jeffreysPrior = xo.getAttribute(JEFFREYS, true);
boolean exponentialMarkovPrior = xo.getAttribute(EXPONENTIALMARKOV, false);
double shape = xo.getAttribute(SHAPE, 1.0);
boolean reverse = xo.getAttribute(REVERSE, false);
int iterations = xo.getAttribute(ITERATIONS, 1);
BayesianSkylineLikelihood bayesianSkylineLikelihood = (BayesianSkylineLikelihood) xo.getChild(BayesianSkylineLikelihood.class);
// This is the parameter on which this operator acts
Parameter paramPops = (Parameter) xo.getChild(Parameter.class);
Parameter paramGroups = bayesianSkylineLikelihood.getGroupSizeParameter();
final int type = bayesianSkylineLikelihood.getType();
if (type != BayesianSkylineLikelihood.STEPWISE_TYPE) {
throw new XMLParseException("Need stepwise control points (set 'linear=\"false\"' in skyline Gibbs operator)");
}
return new BayesianSkylineGibbsOperator(bayesianSkylineLikelihood, paramPops, paramGroups, type, weight, lowerBound, upperBound, jeffreysPrior, exponentialMarkovPrior, shape, reverse, iterations);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class RandomWalkIntegerNodeHeightWeightedOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
double d = xo.getDoubleAttribute(WINDOW_SIZE);
if (d != Math.floor(d)) {
throw new XMLParseException("The window size of a " + RANDOM_WALK_INT_NODE_HEIGHT_WGT_OP + " should be an integer");
}
int windowSize = (int) d;
Parameter parameter = (Parameter) xo.getChild(Parameter.class);
Parameter internalNodeHeights = (Parameter) xo.getElementFirstChild(INTERNAL_NODE_HEIGHTS);
return new RandomWalkIntegerNodeHeightWeightedOperator(parameter, windowSize, weight, internalNodeHeights);
}
Aggregations