use of dr.inference.model.AbstractModelLikelihood in project beast-mcmc by beast-dev.
the class FactorRJMCMCOperatorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
//attributes
double weight = xo.getDoubleAttribute(WEIGHT);
int chainLength = xo.getIntegerAttribute(CHAIN_LENGTH);
double sizeParameter = xo.getDoubleAttribute(SIZE_PARAMETER);
//declaration
AdaptableSizeFastMatrixParameter factors, loadings, cutoffs, loadingsSparcity;
//parameters
if (xo.hasChildNamed(FACTORS))
factors = (AdaptableSizeFastMatrixParameter) xo.getChild(FACTORS).getChild(AdaptableSizeFastMatrixParameter.class);
else
factors = null;
loadings = (AdaptableSizeFastMatrixParameter) xo.getChild(LOADINGS).getChild(AdaptableSizeFastMatrixParameter.class);
if (xo.hasChildNamed(CUTOFFS)) {
cutoffs = (AdaptableSizeFastMatrixParameter) xo.getChild(CUTOFFS).getChild(AdaptableSizeFastMatrixParameter.class);
} else
cutoffs = null;
if (xo.hasChildNamed(LOADINGS_SPARSITY))
loadingsSparcity = (AdaptableSizeFastMatrixParameter) xo.getChild(LOADINGS_SPARSITY).getChild(AdaptableSizeFastMatrixParameter.class);
else
loadingsSparcity = null;
//models
DeterminentalPointProcessPrior DPP = null;
if (xo.getChild(SPARSITY_PRIOR) != null)
DPP = (DeterminentalPointProcessPrior) xo.getChild(SPARSITY_PRIOR).getChild(DeterminentalPointProcessPrior.class);
SimpleMCMCOperator NOp = null;
if (xo.getChild(NEGATION_OPERATOR) != null) {
NOp = (SimpleMCMCOperator) xo.getChild(NEGATION_OPERATOR).getChild(SimpleMCMCOperator.class);
}
AbstractModelLikelihood LFM = (AbstractModelLikelihood) xo.getChild(AbstractModelLikelihood.class);
RowDimensionPoissonPrior rowPrior = (RowDimensionPoissonPrior) xo.getChild(ROW_PRIOR).getChild(RowDimensionPoissonPrior.class);
Likelihood loadingsPrior = null;
if (xo.hasChildNamed(LOADINGS_PRIOR)) {
loadingsPrior = (Likelihood) xo.getChild(LOADINGS_PRIOR).getChild(Likelihood.class);
}
//operators
BitFlipOperator sparsityOperator = null;
if (xo.getChild(BitFlipOperator.class) != null)
sparsityOperator = (BitFlipOperator) xo.getChild(BitFlipOperator.class);
SimpleMCMCOperator loadingsOperator = (SimpleMCMCOperator) xo.getChild(LOADINGS_OPERATOR).getChild(SimpleMCMCOperator.class);
SimpleMCMCOperator factorOperator = null;
if (xo.getChild(FACTOR_OPERATOR) != null)
factorOperator = (SimpleMCMCOperator) xo.getChild(FACTOR_OPERATOR).getChild(FactorTreeGibbsOperator.class);
return new FactorRJMCMCOperator(weight, sizeParameter, chainLength, factors, loadings, cutoffs, loadingsSparcity, LFM, DPP, loadingsPrior, loadingsOperator, factorOperator, sparsityOperator, NOp, rowPrior);
}
Aggregations