Debian Codegraph @

src/dr/inferencexml/model/DummyLikelihoodParser.java

raw symbols SCIP
1 /*
2 * DummyLikelihoodParser.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.model;
27
28 import dr.inference.model.DefaultModel;
29 import dr.inference.model.DummyLikelihood;
30 import dr.inference.model.Model;
31 import dr.inference.model.Parameter;
32 import dr.xml.*;
33
34 /**
35 * Reads a distribution likelihood from a DOM Document element.
36 */
37 public class DummyLikelihoodParser extends AbstractXMLObjectParser {
38
39 public static final String DUMMY_LIKELIHOOD = "dummyLikelihood";
40
41 public String getParserName() { return DUMMY_LIKELIHOOD; }
42
43 public Object parseXMLObject(XMLObject xo) {
44
45 Model model = (Model)xo.getChild(Model.class);
46 Parameter parameter = (Parameter)xo.getChild(Parameter.class);
47
48 if (model == null) {
49 model = new DefaultModel();
50 }
51 final DummyLikelihood likelihood = new DummyLikelihood(model);
52
53 ((DefaultModel)model).addVariable(parameter);
54
55 return likelihood;
56 }
57
58 //************************************************************************
59 // AbstractXMLObjectParser implementation
60 //************************************************************************
61
62 public String getParserDescription() {
63 return "A function wraps a component model that would otherwise not be registered with the MCMC. Always returns a log likelihood of zero.";
64 }
65
66 public Class getReturnType() { return DummyLikelihood.class; }
67
68 public XMLSyntaxRule[] getSyntaxRules() { return rules; }
69
70 private final XMLSyntaxRule[] rules = {
71 new XORRule(
72 new ElementRule(Model.class, "A model element"),
73 new ElementRule(Parameter.class, "A parameter")
74 )
75 };
76 }