Debian Codegraph @

src/dr/inferencexml/operators/LoadingsIndependenceOperatorParser.java

raw symbols SCIP
1 /*
2 * LoadingsIndependenceOperatorParser.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.inferencexml.operators;
27
28 import dr.inference.distribution.DistributionLikelihood;
29 import dr.inference.model.LatentFactorModel;
30 import dr.inference.operators.AdaptationMode;
31 import dr.inference.operators.LoadingsIndependenceOperator;
32 import dr.xml.*;
33
34 /**
35 * Created with IntelliJ IDEA.
36 * User: max
37 * Date: 5/23/14
38 * Time: 1:49 PM
39 * To change this template use File | Settings | File Templates.
40 */
41 public class LoadingsIndependenceOperatorParser extends AbstractXMLObjectParser {
42 public static final String LOADINGS_GIBBS_OPERATOR = "loadingsIndependenceOperator";
43 public static final String WEIGHT = "weight";
44 private final String RANDOM_SCAN = "randomScan";
45 private final String SCALE_FACTOR = "scaleFactor";
46
47
48 @Override
49 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
50 AdaptationMode mode = AdaptationMode.parseMode(xo);
51 String scaleFactorTemp = (String) xo.getAttribute(SCALE_FACTOR);
52 double scaleFactor = Double.parseDouble(scaleFactorTemp);
53 String weightTemp = (String) xo.getAttribute(WEIGHT);
54 double weight = Double.parseDouble(weightTemp);
55 LatentFactorModel LFM = (LatentFactorModel) xo.getChild(LatentFactorModel.class);
56 DistributionLikelihood prior = (DistributionLikelihood) xo.getChild(DistributionLikelihood.class);
57 boolean randomScan = xo.getAttribute(RANDOM_SCAN, true);
58
59 return new LoadingsIndependenceOperator(LFM, prior, weight, randomScan, scaleFactor, mode); //To change body of implemented methods use File | Settings | File Templates.
60 }
61
62 @Override
63 public XMLSyntaxRule[] getSyntaxRules() {
64 return rules;
65 }
66
67 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
68 new ElementRule(LatentFactorModel.class),
69 new ElementRule(DistributionLikelihood.class),
70 // new ElementRule(CompoundParameter.class),
71 AttributeRule.newDoubleRule(WEIGHT),
72 };
73
74 @Override
75 public String getParserDescription() {
76 return "Gibbs sampler for the loadings matrix of a latent factor model"; //To change body of implemented methods use File | Settings | File Templates.
77 }
78
79 @Override
80 public Class getReturnType() {
81 return LoadingsIndependenceOperator.class; //To change body of implemented methods use File | Settings | File Templates.
82 }
83
84 @Override
85 public String getParserName() {
86 return LOADINGS_GIBBS_OPERATOR; //To change body of implemented methods use File | Settings | File Templates.
87 }
88 }