Debian Codegraph @

src/dr/evomodel/coalescent/structure/TreeColouringOperator.java

raw symbols SCIP
1 /*
2 * TreeColouringOperator.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.evomodel.coalescent.structure;
27
28 import dr.evolution.colouring.ColourSampler;
29 import dr.inference.operators.SimpleMCMCOperator;
30 import dr.xml.*;
31
32 /**
33 * @author Alexei Drummond
34 *
35 * @version $Id: TreeColouringOperator.java,v 1.8 2006/08/12 12:55:44 gerton Exp $
36 */
37 @Deprecated
38 public class TreeColouringOperator extends SimpleMCMCOperator {
39
40 public static final String TREE_COLOURING_OPERATOR = "treeColouringOperator";
41
42 ColourSamplerModel colouringModel;
43 ColourSampler colourSampler;
44
45 public TreeColouringOperator(ColourSamplerModel colouringModel) {
46
47 this.colouringModel = colouringModel;
48 }
49
50 /**
51 * @return a short descriptive message of the performance of this operator.
52 */
53 public String getPerformanceSuggestion() {
54 return "This operator cannot be optimized";
55 }
56
57 public String getOperatorName() {
58 return "twoColourTree";
59 }
60
61 /**
62 * Called by operate(), does the actual operation.
63 *
64 * @return the hastings ratio
65 */
66 public double doOperation() {
67
68 double logP = colouringModel.getTreeColouringWithProbability().getLogProbabilityDensity();
69
70 colouringModel.resample();
71
72 double logQ = colouringModel.getTreeColouringWithProbability().getLogProbabilityDensity();
73
74 return logP - logQ;
75 }
76
77 /**
78 * Reads a distribution likelihood from a DOM Document element.
79 */
80 public static XMLObjectParser PARSER = new AbstractXMLObjectParser() {
81
82 public String getParserName() { return TREE_COLOURING_OPERATOR; }
83
84 public Object parseXMLObject(XMLObject xo) {
85
86 ColourSamplerModel colourSamplerModel = (ColourSamplerModel)xo.getChild(ColourSamplerModel.class);
87
88 return new TreeColouringOperator(colourSamplerModel);
89 }
90
91 //************************************************************************
92 // AbstractXMLObjectParser implementation
93 //************************************************************************
94
95 public XMLSyntaxRule[] getSyntaxRules() { return rules; }
96
97 private XMLSyntaxRule[] rules = new XMLSyntaxRule[] {
98 new ElementRule(ColourSamplerModel.class),
99 };
100
101 public String getParserDescription() {
102 return "A tree colouring model.";
103 }
104
105 public Class getReturnType() { return TreeColouringOperator.class; }
106 };
107
108
109 }