Skip to content

Commit

Permalink
patch 10
Browse files Browse the repository at this point in the history
  • Loading branch information
igococha committed Jun 16, 2020
1 parent 5b0b530 commit 0e1423e
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 212 deletions.
Binary file modified dist/PhyDyn.v1.3.6.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions src/phydyn/distribution/STreeLikelihood.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ public boolean initValues() {
}

public double calculateLogP() {
doCalculateLogP();
//System.out.println("logP="+logP);
return logP;
}

public double doCalculateLogP() {
//System.out.println("tree = "+tree.getRoot().toNewick(false));

if ( isConstantLhInput.get() ) {
// force timeseries calculation
// remove reject case (review)
Expand Down
3 changes: 2 additions & 1 deletion src/phydyn/distribution/STreeLikelihoodODE.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class STreeLikelihoodODE extends STreeLikelihood {
"method","Integration method", IntegrationMethod.CLASSICRK, IntegrationMethod.values() );

public Input<Double> stepSizeInput = new Input<>("stepSize",
"ODE solver stepsize", new Double(0.01));
"ODE solver stepsize", new Double(0.001));

public Input<Double> rTolInput = new Input<>(
"rTol", "relative tolerance", new Double(0.0001));
Expand Down Expand Up @@ -148,6 +148,7 @@ protected double processInterval(int interval, double intervalDuration, TimeSeri
lh = solver.getLogLh();
}
//if (interval==15) solver.setDebug(false);
//solver.setDebug(true);;
/* update tsPoint, h and t */

if (ts.getTime(tsPoint) > tEvent) {
Expand Down
6 changes: 3 additions & 3 deletions src/phydyn/model/PopModelODE.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ public void setStartTime(double newT0) {
public double getStartTime() { return trajParams.getStartTime(); }
public void setEndTime(double newt1) {
trajParams.setEndTime(newt1);
} // integrate again
// (below) removed until we figure out how to keep track changes of t0Input/t0
//public void setStartTime(double newt0) { trajParams.t0 = newt0; } // integrate again
trajectoryKnown = false; // integrate again
}

public void unsetEndTime() {
trajParams.unsetEndTime();
}
Expand Down
208 changes: 0 additions & 208 deletions src/phydyn/operators/ABCOperator.java

This file was deleted.

85 changes: 85 additions & 0 deletions src/phydyn/operators/LoopOperator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
*
*/
package phydyn.operators;

import beast.core.Input;
import beast.core.Operator;
import beast.core.parameter.RealParameter;

/**
* @author igor
*
*/
public class LoopOperator extends Operator {

public final Input<RealParameter> parameterInput = new Input<>("parameter", "parameter to be looped over",
Input.Validate.REQUIRED);

//public final Input<Double> spanInput = new Input<>("span","(length po) span to be looped over", Input.Validate.REQUIRED);

public final Input<Integer> numpointsInput = new Input<>("numpoints","number of points / number of loop interations+1",Input.Validate.REQUIRED);
public final Input<Double> lboundInput = new Input<>("lbound","lower bound (start) of loop",Input.Validate.REQUIRED);
public final Input<Double> rboundInput = new Input<>("rbound","upper bound (start) of loop",Input.Validate.REQUIRED);

private int samplePoint=0; // 0 to numPoints-1
private double span;
private double startv, endv;
private int numPoints;

protected boolean outsideBounds(final double value, final RealParameter param) {
final Double l = param.getLower();
final Double h = param.getUpper();
return (value < l || value > h);
//return (l != null && value < l || h != null && value > h);
}

public void initAndValidate() {
final RealParameter param = parameterInput.get(this);

if (param.getDimension() > 1)
throw new IllegalArgumentException("(LoopOperator) Parameter has more than one dimension");
if (outsideBounds(lboundInput.get(),param)) {
System.out.println(lboundInput.get());
throw new IllegalArgumentException("(LoopOperator) lower bound outside parameter bounds");
}
if (outsideBounds(rboundInput.get(),param)) {
throw new IllegalArgumentException("(LoopOperator) upper bound outside parameter bounds");
}
numPoints = numpointsInput.get();
span = (rboundInput.get() - lboundInput.get())/(numPoints-1);
if (span>0) {
startv = lboundInput.get();
endv = rboundInput.get();
} else {
endv = lboundInput.get();
startv = rboundInput.get();
}



}

/**
* Always accepted / return Double.POSITIVE_INFINITY
*
* @return log of Hastings Ratio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
*/
public double proposal() {
final RealParameter param = parameterInput.get(this);
// sample from samplePoint;
double newValue;
if (samplePoint==0) {
newValue = startv; samplePoint++;
} else if (samplePoint == (numPoints-1)) {
newValue = endv; samplePoint = 0;
// or shall we exit?
} else {
newValue = startv + span*samplePoint; samplePoint++;
}

param.setValue(0, newValue);
return Double.POSITIVE_INFINITY;
}

}

0 comments on commit 0e1423e

Please sign in to comment.