[beast-mcmc] r6752 committed - Make a Gibbs version of SwapParameterOperator

0 views
Skip to first unread message

beast...@googlecode.com

unread,
Apr 24, 2015, 9:22:19 AM4/24/15
to beast-...@googlegroups.com
Revision: 6752
Author: msuchard
Date: Fri Apr 24 13:21:56 2015 UTC
Log: Make a Gibbs version of SwapParameterOperator
https://code.google.com/p/beast-mcmc/source/detail?r=6752

Added:
/trunk/src/dr/inference/operators/SwapParameterGibbsOperator.java
Modified:
/trunk/src/dr/inference/operators/SwapParameterOperator.java
/trunk/src/dr/inferencexml/operators/SwapParameterOperatorParser.java

=======================================
--- /dev/null
+++ /trunk/src/dr/inference/operators/SwapParameterGibbsOperator.java Fri
Apr 24 13:21:56 2015 UTC
@@ -0,0 +1,48 @@
+/*
+ * SwapParameterGibbsOperator.java
+ *
+ * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
+ *
+ * This file is part of BEAST.
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership and licensing.
+ *
+ * BEAST is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * BEAST is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with BEAST; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+package dr.inference.operators;
+
+import dr.inference.model.Parameter;
+
+import java.util.List;
+
+/**
+ * @author Marc A. Suchard
+ */
+public class SwapParameterGibbsOperator extends SwapParameterOperator
implements GibbsOperator {
+
+ public SwapParameterGibbsOperator(List<Parameter> parameterList,
double weight) {
+ super(parameterList, weight);
+ }
+
+ public int getStepCount() {
+ return 1;
+ }
+
+ public String getOperatorName() {
+ return "GIBBS." + super.getOperatorName();
+ }
+}
=======================================
--- /trunk/src/dr/inference/operators/SwapParameterOperator.java Fri Apr 24
04:15:36 2015 UTC
+++ /trunk/src/dr/inference/operators/SwapParameterOperator.java Fri Apr 24
13:21:56 2015 UTC
@@ -106,6 +106,7 @@
for (Parameter p : parameterList) {
sb.append(p.getParameterName()).append(".");
}
+ parameterNames = sb.toString();
}
return parameterNames;
}
@@ -117,8 +118,6 @@
public String getPerformanceSuggestion() {
return "No suggestions";
}
-
- //PRIVATE STUFF

private final List<Parameter> parameterList;
private String parameterNames = null;
=======================================
--- /trunk/src/dr/inferencexml/operators/SwapParameterOperatorParser.java
Thu Apr 23 23:25:57 2015 UTC
+++ /trunk/src/dr/inferencexml/operators/SwapParameterOperatorParser.java
Fri Apr 24 13:21:56 2015 UTC
@@ -26,6 +26,7 @@
package dr.inferencexml.operators;

import dr.inference.model.Parameter;
+import dr.inference.operators.SwapParameterGibbsOperator;
import dr.inference.operators.SwapParameterOperator;
import dr.xml.*;

@@ -37,6 +38,8 @@
public class SwapParameterOperatorParser extends AbstractXMLObjectParser {

public final static String SWAP_OPERATOR = "swapParameterOperator";
+ public static final String FORCE_GIBBS = "forceGibbs";
+ public static final String WEIGHT = "weight";

public String getParserName() {
return SWAP_OPERATOR;
@@ -50,9 +53,15 @@
parameterList.add((Parameter) xo.getChild(i));
}

- double weight = xo.getDoubleAttribute("weight");
+ double weight = xo.getDoubleAttribute(WEIGHT);
+ boolean forceGibbs = xo.getAttribute(FORCE_GIBBS, false);

- return new SwapParameterOperator(parameterList, weight);
+ if (forceGibbs) {
+ return new SwapParameterGibbsOperator(parameterList, weight);
+ } else {
+ return new SwapParameterOperator(parameterList, weight);
+ }
+
}


//************************************************************************
@@ -72,7 +81,8 @@
}

private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{
- AttributeRule.newDoubleRule("weight"),
+ AttributeRule.newDoubleRule(WEIGHT),
+ AttributeRule.newBooleanRule(FORCE_GIBBS, true),
new ElementRule(Parameter.class, 2, Integer.MAX_VALUE)
};

Reply all
Reply to author
Forward
0 new messages