Debian Codegraph @

src/dr/inference/operators/hmc/deprecated/LatentFactorHamiltonianMCParser.java

raw symbols SCIP
1 /*
2 * LatentFactorHamiltonianMCParser.java
3 *
4 * Copyright (c) 2002-2017 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.inference.operators.hmc.deprecated;
27
28 import dr.evomodel.continuous.FullyConjugateMultivariateTraitLikelihood;
29 import dr.inference.operators.AdaptationMode;
30 import dr.inference.model.LatentFactorModel;
31 import dr.xml.*;
32
33 /**
34 * Created by max on 12/2/15.
35 */
36 @Deprecated
37 public class LatentFactorHamiltonianMCParser extends AbstractXMLObjectParser {
38 public static final String LATENT_FACTOR_MODEL_HAMILTONIAN_MC="LatentFactorHamiltonianMC";
39 public static final String WEIGHT="weight";
40 public static final String N_STEPS="nSteps";
41 public static final String STEP_SIZE="stepSize";
42 public static final String MOMENTUM_SD="momentumSd";
43 @Override
44 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
45 LatentFactorModel lfm=(LatentFactorModel) xo.getChild(LatentFactorModel.class);
46 FullyConjugateMultivariateTraitLikelihood tree=(FullyConjugateMultivariateTraitLikelihood) xo.getChild(FullyConjugateMultivariateTraitLikelihood.class);
47 double weight=xo.getDoubleAttribute(WEIGHT);
48 AdaptationMode mode= AdaptationMode.parseMode(xo);
49 int nSteps=xo.getIntegerAttribute(N_STEPS);
50 double stepSize=xo.getDoubleAttribute(STEP_SIZE);
51 double momentumSd= xo.getDoubleAttribute(MOMENTUM_SD);
52
53
54 return new LatentFactorHamiltonianMC(lfm, tree, weight, mode, stepSize, nSteps, momentumSd);
55
56
57 }
58
59 @Override
60 public XMLSyntaxRule[] getSyntaxRules() {
61 return rules;
62 }
63
64 private static final XMLSyntaxRule[] rules = {
65 AttributeRule.newDoubleRule(WEIGHT),
66 AttributeRule.newDoubleRule(STEP_SIZE),
67 AttributeRule.newIntegerRule(N_STEPS),
68 AttributeRule.newDoubleRule(MOMENTUM_SD),
69 new ElementRule(LatentFactorModel.class),
70 new ElementRule(FullyConjugateMultivariateTraitLikelihood.class),
71 };
72
73 @Override
74 public String getParserDescription() {
75 return "Hamiltonian Monte Carlo For factors";
76 }
77
78 @Override
79 public Class getReturnType() {
80 return LatentFactorHamiltonianMC.class;
81 }
82
83 @Override
84 public String getParserName() {
85 return LATENT_FACTOR_MODEL_HAMILTONIAN_MC;
86 }
87 }