use of dr.evomodel.coalescent.operators.GaussianProcessSkytrackBlockUpdateOperator in project beast-mcmc by beast-dev.
the class GaussianProcessSkytrackBlockUpdateOperatorParser 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.GaussianProcessSkytrackBlockUpdateOperator");
gmrfLogger.setUseParentHandlers(false);
if (logRecord) {
gmrfLogger.setLevel(Level.FINE);
try {
gmrfHandler = new FileHandler("GPBlockUpdate.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);
// 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)) {
GaussianProcessSkytrackLikelihood gpLikelihood = (GaussianProcessSkytrackLikelihood) xo.getChild(GaussianProcessSkytrackLikelihood.class);
return new GaussianProcessSkytrackBlockUpdateOperator(gpLikelihood, weight, mode, scaleFactor, maxIterations, stopValue);
} else {
GaussianProcessSkytrackLikelihood gpLikelihood = (GaussianProcessSkytrackLikelihood) xo.getChild(GaussianProcessSkytrackLikelihood.class);
return new GaussianProcessSkytrackBlockUpdateOperator(gpLikelihood, weight, mode, scaleFactor, maxIterations, stopValue);
}
}
Aggregations