Search in sources :

Example 1 with PiecewisePopulationModel

use of dr.evomodel.coalescent.PiecewisePopulationModel 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);
    }
}
Also used : Parameter(dr.inference.model.Parameter) PiecewisePopulationModel(dr.evomodel.coalescent.PiecewisePopulationModel) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Aggregations

Units (dr.evolution.util.Units)1 PiecewisePopulationModel (dr.evomodel.coalescent.PiecewisePopulationModel)1 XMLUnits (dr.evoxml.util.XMLUnits)1 Parameter (dr.inference.model.Parameter)1