Skip to content

Commit

Permalink
Revert "function to respect grid points for Coalescent Simulator"
Browse files Browse the repository at this point in the history
This reverts commit a7437d9.
  • Loading branch information
xji3 committed Nov 7, 2024
1 parent d05608f commit 2000325
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
35 changes: 0 additions & 35 deletions src/dr/evolution/coalescent/CoalescentSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,41 +197,6 @@ private double getMinimumInactiveHeight() {
} else return Double.POSITIVE_INFINITY;
}

private DemographicBoundary getDemographicFunction(DemographicFunction demographic) {
if (demographic instanceof PiecewiseConstantPopulation) {
return DemographicBoundary.PIECEWISE_CONSTANT;
} else {
return DemographicBoundary.PIECEWISE_CONSTANT;
}
}

enum DemographicBoundary{
NONE {
@Override
double getNextBoundary(int currentActiveNodeCount, ArrayList<SimpleNode> sortedNodeList,
DemographicFunction demographic) {
return getMinimumInactiveNode(currentActiveNodeCount, sortedNodeList);
}
},
PIECEWISE_CONSTANT {
@Override
double getNextBoundary(int currentActiveNodeCount, ArrayList<SimpleNode> sortedNodeList, DemographicFunction demographic) {
PiecewiseConstantPopulation piecewisePopulationModel = (PiecewiseConstantPopulation) demographic;
final double currentActiveNodeHeight = sortedNodeList.get(currentActiveNodeCount - 1).getHeight();
final double nextEpochBoundary = piecewisePopulationModel.getNextEpochBoundary(currentActiveNodeHeight);
final double minInactiveNode = getMinimumInactiveNode(currentActiveNodeCount, sortedNodeList);
return nextEpochBoundary < minInactiveNode ? nextEpochBoundary : minInactiveNode;
}
};
abstract double getNextBoundary(int currentActiveNodeCount, ArrayList<SimpleNode> sortedNodeList,
DemographicFunction demographic);
double getMinimumInactiveNode(int currentActiveNodeCount, ArrayList<SimpleNode> sortedNodeList) {
if (currentActiveNodeCount < sortedNodeList.size()) {
return (sortedNodeList.get(currentActiveNodeCount)).getHeight();
} else return Double.POSITIVE_INFINITY;
}
}

/**
* Set the current height.
*/
Expand Down
10 changes: 0 additions & 10 deletions src/dr/evolution/coalescent/PiecewiseConstantPopulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ public double getDemographic(double t) {
return getDemographic(epoch, t1);
}

public double getNextEpochBoundary(double t) {
int epoch = 0; // TODO: XJ - really bad code duplication, but how do I return two values without making another structure...
double accumulatedTime = getEpochDuration(epoch);
while (accumulatedTime < t) {
accumulatedTime += getEpochDuration(epoch);
epoch += 1;
}
return accumulatedTime;
}

/**
* Gets the integral of intensity function from time 0 to time t.
*/
Expand Down

0 comments on commit 2000325

Please sign in to comment.