Debian Codegraph @

src/dr/inferencexml/distribution/DeterminentalPointProcessPriorParser.java

raw symbols SCIP
1 package dr.inferencexml.distribution;
2
3 import dr.inference.model.AdaptableSizeFastMatrixParameter;
4 import dr.inference.distribution.DeterminentalPointProcessPrior;
5 import dr.inference.model.MatrixParameterInterface;
6 import dr.inference.model.Parameter;
7 import dr.xml.*;
8
9 /**
10 * Created by max on 4/6/16.
11 */
12 public class DeterminentalPointProcessPriorParser extends AbstractXMLObjectParser {
13 public static final String DETERMINENTAL_POINT_PROCESS_PRIOR="determinentalPointProcessPrior";
14 public static final String THETA = "theta";
15 public static final String NORMALIZING_CONSTANTS = "normalizingConstants";
16 public static final String PATH_SAMPLING = "pathSampling";
17 public static final String NO_ZEROS = "noZeros";
18 public static final String RESET_DATA = "resetData";
19
20 @Override
21 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
22
23 String name = xo.getName();
24 double theta = xo.getDoubleAttribute(THETA);
25 MatrixParameterInterface data = (MatrixParameterInterface) xo.getChild(MatrixParameterInterface.class);
26 Parameter normalizingConstants = null;
27 if(xo.getChild(NORMALIZING_CONSTANTS) != null) {
28 normalizingConstants = (Parameter) xo.getChild(NORMALIZING_CONSTANTS).getChild(Parameter.class);
29 }
30 boolean noZeros = xo.getAttribute(NO_ZEROS, false);
31 boolean pathSampling = xo.getAttribute(PATH_SAMPLING, false);
32 boolean resetData = xo.getAttribute(RESET_DATA, true);
33
34 return new DeterminentalPointProcessPrior(name, theta, data, normalizingConstants, noZeros, pathSampling, resetData);
35 }
36
37 @Override
38 public XMLSyntaxRule[] getSyntaxRules() {
39 return rules;
40 }
41
42 private final XMLSyntaxRule[] rules = {
43 // new ElementRule(Parameter.class, 0, Integer.MAX_VALUE),
44 new ElementRule(MatrixParameterInterface.class),
45 AttributeRule.newDoubleRule(THETA),
46 AttributeRule.newBooleanRule(NO_ZEROS, true),
47 AttributeRule.newBooleanRule(PATH_SAMPLING, true),
48 AttributeRule.newBooleanRule(RESET_DATA, true),
49 new ElementRule(NORMALIZING_CONSTANTS, new XMLSyntaxRule[]{
50 new ElementRule(Parameter.class)
51 }, true),
52 };
53
54
55
56 @Override
57 public String getParserDescription() {
58 return "Returns a blockUpperTriangularMatrixParameter which is a compoundParameter which forces the last element to be of full length, the second to last element to be of full length-1, etc."; //To change body of implemented methods use File | Settings | File Templates.
59 }
60
61 @Override
62 public Class getReturnType() {
63 return DeterminentalPointProcessPrior.class; //To change body of implemented methods use File | Settings | File Templates.
64 }
65
66 @Override
67 public String getParserName() {
68 return DETERMINENTAL_POINT_PROCESS_PRIOR; //To change body of implemented methods use File | Settings | File Templates.
69 }
70 }
71