use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class RandomWalkIntegerSetSizeWeightedOperatorParser 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_SET_SIZE_WGT_OP + " should be an integer");
}
double baseSetSize = xo.getDoubleAttribute(BASE_SET_SIZE);
int windowSize = (int) d;
Parameter parameter = (Parameter) xo.getChild(Parameter.class);
MicrosatelliteSamplerTreeModel msatSampleTreeModel = (MicrosatelliteSamplerTreeModel) xo.getChild(MicrosatelliteSamplerTreeModel.class);
return new RandomWalkIntegerSetSizeWeightedOperator(parameter, windowSize, weight, msatSampleTreeModel, baseSetSize);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class LeafTraitExtractorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
TreeModel model = (TreeModel) xo.getChild(TreeModel.class);
final CompoundParameter allTraits = (CompoundParameter) xo.getChild(CompoundParameter.class);
String taxonString = (String) xo.getAttribute(TreeModelParser.TAXON);
final int leafIndex = model.getTaxonIndex(taxonString);
if (leafIndex == -1) {
throw new XMLParseException("Unable to find taxon '" + taxonString + "' in trees.");
}
final Parameter leafTrait = allTraits.getParameter(leafIndex);
boolean setBounds = xo.getAttribute(SET_BOUNDS, true);
if (setBounds) {
Parameter.DefaultBounds bound = new Parameter.DefaultBounds(Double.MAX_VALUE, -Double.MAX_VALUE, leafTrait.getDimension());
leafTrait.addBounds(bound);
}
return leafTrait;
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class PeakAndDeclineModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(PEAK_VALUE);
Parameter peakValueParam = (Parameter) cxo.getChild(Parameter.class);
Parameter rParam;
cxo = xo.getChild(SHAPE);
rParam = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(PEAK_TIME);
Parameter peakTimeParam = (Parameter) cxo.getChild(Parameter.class);
return new PeakAndDeclineModel(peakValueParam, rParam, peakTimeParam, units);
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class PiecewisePopulationModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject obj = xo.getChild(EPOCH_WIDTHS);
double[] epochWidths = obj.getDoubleArrayAttribute(WIDTHS);
if (xo.hasChildNamed(EPOCH_SIZES)) {
Parameter epochSizes = (Parameter) xo.getElementFirstChild(EPOCH_SIZES);
boolean isLinear = false;
if (xo.hasAttribute(LINEAR)) {
isLinear = xo.getBooleanAttribute(LINEAR);
}
return new PiecewisePopulationModel(PIECEWISE_POPULATION, epochSizes, epochWidths, isLinear, units);
} else {
Parameter populationSize = (Parameter) xo.getElementFirstChild(POPULATION_SIZE);
Parameter growthRates = (Parameter) xo.getElementFirstChild(GROWTH_RATES);
return new PiecewisePopulationModel(PIECEWISE_POPULATION, populationSize, growthRates, epochWidths, units);
}
}
use of dr.inference.model.Parameter in project beast-mcmc by beast-dev.
the class PowerLawGrowthModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
XMLObject cxo = xo.getChild(N0);
Parameter N0Param = (Parameter) cxo.getChild(Parameter.class);
Parameter rParam;
cxo = xo.getChild(POWER);
rParam = (Parameter) cxo.getChild(Parameter.class);
return new PowerLawGrowthModel(N0Param, rParam, units);
}
Aggregations