Debian Codegraph @

src/dr/inferencexml/operators/LFMSplitMergeOperatorParser.java

raw symbols SCIP
1 package dr.inferencexml.operators;
2
3 import dr.evomodel.continuous.FullyConjugateMultivariateTraitLikelihood;
4 import dr.inference.model.AdaptableSizeFastMatrixParameter;
5 import dr.inference.operators.LFMSplitMergeOperator;
6 import dr.xml.*;
7
8 /**
9 * @author Max Tolkoff
10 */
11 public class LFMSplitMergeOperatorParser extends AbstractXMLObjectParser {
12 public final static String LFM_SPLIT_MERGE_OPERATOR = "LFMSplitMergeOperator";
13 public final static String FACTORS = "factors";
14 public final static String LOADINGS = "loadings";
15 public final static String CUTOFFS = "cutoffs";
16 public final static String SPARSE_LOADINGS = "sparseLoadings";
17 public static final String WEIGHT = "weight";
18 public static final String SPLIT_VARIANCE = "splitVariance";
19
20 @Override
21 public String getParserName() {
22 return LFM_SPLIT_MERGE_OPERATOR;
23 }
24
25 @Override
26 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
27 AdaptableSizeFastMatrixParameter loadings = (AdaptableSizeFastMatrixParameter) xo.getChild(LOADINGS).getChild(AdaptableSizeFastMatrixParameter.class);
28 AdaptableSizeFastMatrixParameter factors = (AdaptableSizeFastMatrixParameter) xo.getChild(FACTORS).getChild(AdaptableSizeFastMatrixParameter.class);
29 AdaptableSizeFastMatrixParameter cutoffs = (AdaptableSizeFastMatrixParameter) xo.getChild(CUTOFFS).getChild(AdaptableSizeFastMatrixParameter.class);
30 AdaptableSizeFastMatrixParameter sparseLoadings = (AdaptableSizeFastMatrixParameter) xo.getChild(SPARSE_LOADINGS).getChild(AdaptableSizeFastMatrixParameter.class);
31 double weight = xo.getDoubleAttribute(WEIGHT);
32 double splitVariance = xo.getDoubleAttribute(SPLIT_VARIANCE);
33 FullyConjugateMultivariateTraitLikelihood tree = (FullyConjugateMultivariateTraitLikelihood) xo.getChild(FullyConjugateMultivariateTraitLikelihood.class);
34
35 return new LFMSplitMergeOperator(weight, splitVariance, factors, loadings, sparseLoadings, cutoffs, tree);
36 }
37
38 @Override
39 public XMLSyntaxRule[] getSyntaxRules() {
40 return rules;
41 }
42
43
44 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
45 new ElementRule(FACTORS, new XMLSyntaxRule[]{
46 new ElementRule(AdaptableSizeFastMatrixParameter.class)}),
47 new ElementRule(LOADINGS, new XMLSyntaxRule[]{
48 new ElementRule(AdaptableSizeFastMatrixParameter.class)}),
49 new ElementRule(SPARSE_LOADINGS, new XMLSyntaxRule[]{
50 new ElementRule(AdaptableSizeFastMatrixParameter.class)}),
51 new ElementRule(CUTOFFS, new XMLSyntaxRule[]{
52 new ElementRule(AdaptableSizeFastMatrixParameter.class)}),
53 AttributeRule.newDoubleRule(WEIGHT),
54 AttributeRule.newDoubleRule(SPLIT_VARIANCE),
55 new ElementRule(FullyConjugateMultivariateTraitLikelihood.class)
56 };
57
58
59
60
61
62
63
64 @Override
65 public String getParserDescription() {
66 return null;
67 }
68
69 @Override
70 public Class getReturnType() {
71 return LFMSplitMergeOperator.class;
72 }
73 }