Search in sources :

Example 1 with GMRFMultilocusSkyrideBlockUpdateOperator

use of dr.evomodel.coalescent.operators.GMRFMultilocusSkyrideBlockUpdateOperator in project beast-mcmc by beast-dev.

the class GMRFSkyrideBlockUpdateOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    boolean logRecord = xo.getAttribute(KEEP_LOG_RECORD, false);
    Handler gmrfHandler;
    Logger gmrfLogger = Logger.getLogger("dr.evomodel.coalescent.operators.GMRFSkyrideBlockUpdateOperator");
    gmrfLogger.setUseParentHandlers(false);
    if (logRecord) {
        gmrfLogger.setLevel(Level.FINE);
        try {
            gmrfHandler = new FileHandler("GMRFBlockUpdate.log." + MathUtils.getSeed());
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage());
        }
        gmrfHandler.setLevel(Level.FINE);
        gmrfHandler.setFormatter(new XMLFormatter() {

            public String format(LogRecord record) {
                return "<record>\n \t<message>\n\t" + record.getMessage() + "\n\t</message>\n<record>\n";
            }
        });
        gmrfLogger.addHandler(gmrfHandler);
    }
    CoercionMode mode = CoercionMode.parseMode(xo);
    if (mode == CoercionMode.DEFAULT)
        mode = CoercionMode.COERCION_ON;
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    double scaleFactor = xo.getDoubleAttribute(SCALE_FACTOR);
    if (scaleFactor == 1.0) {
        mode = CoercionMode.COERCION_OFF;
    }
    //                throw new XMLParseException("scaleFactor must be greater than 0.0");
    if (scaleFactor < 1.0) {
        throw new XMLParseException("scaleFactor must be greater than or equal to 1.0");
    }
    int maxIterations = xo.getAttribute(MAX_ITERATIONS, 200);
    double stopValue = xo.getAttribute(STOP_VALUE, 0.01);
    if (xo.getAttribute(OLD_SKYRIDE, true) && !(xo.getName().compareTo(GRID_BLOCK_UPDATE_OPERATOR) == 0)) {
        GMRFSkyrideLikelihood gmrfLikelihood = (GMRFSkyrideLikelihood) xo.getChild(GMRFSkyrideLikelihood.class);
        return new GMRFSkyrideBlockUpdateOperator(gmrfLikelihood, weight, mode, scaleFactor, maxIterations, stopValue);
    } else {
        GMRFMultilocusSkyrideLikelihood gmrfMultilocusLikelihood = (GMRFMultilocusSkyrideLikelihood) xo.getChild(GMRFMultilocusSkyrideLikelihood.class);
        return new GMRFMultilocusSkyrideBlockUpdateOperator(gmrfMultilocusLikelihood, weight, mode, scaleFactor, maxIterations, stopValue);
    }
}
Also used : GMRFSkyrideLikelihood(dr.evomodel.coalescent.GMRFSkyrideLikelihood) IOException(java.io.IOException) GMRFSkyrideBlockUpdateOperator(dr.evomodel.coalescent.operators.GMRFSkyrideBlockUpdateOperator) CoercionMode(dr.inference.operators.CoercionMode) GMRFMultilocusSkyrideLikelihood(dr.evomodel.coalescent.GMRFMultilocusSkyrideLikelihood) GMRFMultilocusSkyrideBlockUpdateOperator(dr.evomodel.coalescent.operators.GMRFMultilocusSkyrideBlockUpdateOperator)

Aggregations

GMRFMultilocusSkyrideLikelihood (dr.evomodel.coalescent.GMRFMultilocusSkyrideLikelihood)1 GMRFSkyrideLikelihood (dr.evomodel.coalescent.GMRFSkyrideLikelihood)1 GMRFMultilocusSkyrideBlockUpdateOperator (dr.evomodel.coalescent.operators.GMRFMultilocusSkyrideBlockUpdateOperator)1 GMRFSkyrideBlockUpdateOperator (dr.evomodel.coalescent.operators.GMRFSkyrideBlockUpdateOperator)1 CoercionMode (dr.inference.operators.CoercionMode)1 IOException (java.io.IOException)1