Debian Codegraph @

src/dr/evomodel/operators/CCPImportanceDistributionOperator.java

raw symbols SCIP
1 /*
2 * CCPImportanceDistributionOperator.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 /**
27 *
28 */
29 package dr.evomodel.operators;
30
31 import dr.evomodel.tree.ConditionalCladeFrequency;
32 import dr.evomodel.tree.TreeModel;
33 import dr.xml.*;
34
35 /**
36 * @author Sebastian Hoehna
37 */
38 // Cleaning out untouched stuff. Can be resurrected if needed
39 @Deprecated
40 public class CCPImportanceDistributionOperator extends
41 AbstractImportanceDistributionOperator {
42
43 public static final String CCP_IMPORTANCE_DISTRIBUTION_OPERATOR = "CCPImportanceDistributionOperator";
44
45 /**
46 *
47 */
48 public CCPImportanceDistributionOperator(TreeModel tree, double weight,
49 int samples, int sampleEvery, double epsilon) {
50 super(tree, weight, samples, sampleEvery);
51
52 probabilityEstimater = new ConditionalCladeFrequency(tree, epsilon);
53 }
54
55 /**
56 *
57 */
58 public CCPImportanceDistributionOperator(TreeModel tree, double weight) {
59 super(tree, weight);
60 double epsilon = 1 - Math.pow(0.5, 1.0 / 10000);
61 probabilityEstimater = new ConditionalCladeFrequency(tree, epsilon);
62 }
63
64 /*
65 * (non-Javadoc)
66 *
67 * @see dr.inference.operators.AbstractImportanceSampler#getOperatorName()
68 */
69 @Override
70 public String getOperatorName() {
71 return CCP_IMPORTANCE_DISTRIBUTION_OPERATOR;
72 }
73
74 /*
75 * (non-Javadoc)
76 *
77 * @see
78 * dr.inference.operators.AbstractImportanceSampler#getPerformanceSuggestion
79 * ()
80 */
81 @Override
82 public String getPerformanceSuggestion() {
83 if (getAcceptanceProbability() < getMinimumGoodAcceptanceLevel()) {
84 return "Try to increase the sample size and/or the steps between each sample.";
85 }
86 return "";
87 }
88
89
90 // Sebastian
91 // public void printClades(){
92 // probabilityEstimater.printClades();
93 // }
94 // Sebastian
95
96 public static XMLObjectParser CCP_IMPORTANCE_DISTRIBUTION_OPERATOR_PARSER = new AbstractXMLObjectParser() {
97
98 public String getParserName() {
99 return CCP_IMPORTANCE_DISTRIBUTION_OPERATOR;
100 }
101
102 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
103
104 TreeModel treeModel = (TreeModel) xo.getChild(TreeModel.class);
105 double weight = xo.getDoubleAttribute("weight");
106 int samples = xo.getIntegerAttribute("samples");
107
108 double epsilon = 1 - Math.pow(0.5, 1.0 / samples);
109 if (xo.hasAttribute("epsilon")) {
110 epsilon = xo.getDoubleAttribute("epsilon");
111 }
112
113 int sampleEvery = 10;
114 if (xo.hasAttribute("sampleEvery")) {
115 sampleEvery = xo.getIntegerAttribute("sampleEvery");
116 }
117
118 return new CCPImportanceDistributionOperator(treeModel, weight,
119 samples, sampleEvery, epsilon);
120 }
121
122 //**********************************************************************
123 // **
124 // AbstractXMLObjectParser implementation
125 //**********************************************************************
126 // **
127
128 public String getParserDescription() {
129 return "This element represents an operator proposing trees from an importance distribution which is created by the conditional clade probabilities.";
130 }
131
132 public Class getReturnType() {
133 return CCPImportanceDistributionOperator.class;
134 }
135
136 public XMLSyntaxRule[] getSyntaxRules() {
137 return rules;
138 }
139
140 private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
141 AttributeRule.newDoubleRule("weight"),
142 AttributeRule.newIntegerRule("samples"),
143 AttributeRule.newIntegerRule("sampleEvery", true),
144 AttributeRule.newDoubleRule("epsilon", true),
145 new ElementRule(TreeModel.class)};
146
147 };
148 }