Program: 189588
Project: 189588
Buggy source:
/** 
 * This method samples a path, updates the belief to reflect that, and returns the path.
 * @param edgeTransDist
 * @param belief
 * @param startEdge
 * @param movementFilter
 * @return
 */
private InferredPath traverseEdge(EdgeTransitionDistributions edgeTransDist,final MultivariateGaussian belief,PathEdge startEdge,StandardRoadTrackingFilter movementFilter){
  PathEdge currentEdge=startEdge;
  List<PathEdge> currentPath=Lists.newArrayList();
  double distTraveled=0d;
  Double totalDistToTravel=null;
  while (totalDistToTravel == null || totalDistToTravel >= currentEdge.getDistToStartOfEdge() + currentEdge.getInferredEdge().getLength()) {
    List<InferredEdge> transferEdges=Lists.newArrayList();
    if (currentEdge.getInferredEdge() == InferredGraph.getEmptyEdge()) {
      transferEdges.addAll(this.inferredGraph.getNearbyEdges(belief.getMean()));
    }
 else {
      if (belief.getMean().getElement(0) < 0d) {
        transferEdges.addAll(currentEdge.getInferredEdge().getIncomingTransferableEdges());
      }
 else       if (belief.getMean().getElement(0) > 0d) {
        transferEdges.addAll(currentEdge.getInferredEdge().getOutgoingTransferableEdges());
      }
 else {
        transferEdges.addAll(currentEdge.getInferredEdge().getIncomingTransferableEdges());
        transferEdges.addAll(currentEdge.getInferredEdge().getOutgoingTransferableEdges());
      }
      transferEdges.add(currentEdge.getInferredEdge());
    }
    InferredEdge sampledEdge=edgeTransDist.sample(rng,transferEdges,currentEdge.getInferredEdge());
    if (sampledEdge == InferredGraph.getEmptyEdge()) {
      movementFilter.predict(belief,PathEdge.getEmptyPathEdge(),currentEdge);
      if (currentPath.isEmpty()) {
        return InferredPath.getEmptyPath();
      }
 else {
        currentPath.add(PathEdge.getEmptyPathEdge());
        return new InferredPath(ImmutableList.copyOf(currentPath),distTraveled);
      }
    }
    PathEdge sampledPathEdge=PathEdge.getEdge(sampledEdge,distTraveled);
    if (totalDistToTravel == null) {
      if (belief.getInputDimensionality() == 4) {
        StandardRoadTrackingFilter.invertProjection(belief,sampledPathEdge);
      }
      movementFilter.predict(belief,null,null);
      totalDistToTravel=belief.getMean().getElement(0);
    }
    final double direction=belief.getMean().getElement(0) >= 0d ? 1d : -1d;
    if (sampledPathEdge == null) {
      belief.getMean().setElement(0,direction * currentEdge.getInferredEdge().getLength());
      belief.getMean().setElement(1,0d);
      break;
    }
    distTraveled+=direction * currentEdge.getInferredEdge().getLength();
    currentEdge=sampledPathEdge;
    currentPath.add(sampledPathEdge);
  }
  belief.getMean().setElement(0,belief.getMean().getElement(0) - currentEdge.getDistToStartOfEdge());
  return new InferredPath(ImmutableList.copyOf(currentPath));
}

Fixed version (ground truth):
/** 
 * This method samples a path, updates the belief to reflect that, and returns the path.
 * @param edgeTransDist
 * @param belief
 * @param startEdge
 * @param movementFilter
 * @return
 */
private InferredPath traverseEdge(EdgeTransitionDistributions edgeTransDist,final MultivariateGaussian belief,PathEdge startEdge,StandardRoadTrackingFilter movementFilter){
  PathEdge currentEdge=startEdge;
  List<PathEdge> currentPath=Lists.newArrayList();
  double distTraveled=0d;
  Double totalDistToTravel=null;
  while (totalDistToTravel == null || totalDistToTravel >= currentEdge.getDistToStartOfEdge() + currentEdge.getInferredEdge().getLength()) {
    List<InferredEdge> transferEdges=Lists.newArrayList();
    if (currentEdge.getInferredEdge() == InferredGraph.getEmptyEdge()) {
      Vector projLocation=StandardRoadTrackingFilter.getOg().times(belief.getMean());
      transferEdges.addAll(this.inferredGraph.getNearbyEdges(projLocation));
    }
 else {
      if (belief.getMean().getElement(0) < 0d) {
        transferEdges.addAll(currentEdge.getInferredEdge().getIncomingTransferableEdges());
      }
 else       if (belief.getMean().getElement(0) > 0d) {
        transferEdges.addAll(currentEdge.getInferredEdge().getOutgoingTransferableEdges());
      }
 else {
        transferEdges.addAll(currentEdge.getInferredEdge().getIncomingTransferableEdges());
        transferEdges.addAll(currentEdge.getInferredEdge().getOutgoingTransferableEdges());
      }
    }
    InferredEdge sampledEdge=edgeTransDist.sample(rng,transferEdges,currentEdge.getInferredEdge());
    if (sampledEdge == InferredGraph.getEmptyEdge()) {
      movementFilter.predict(belief,PathEdge.getEmptyPathEdge(),currentEdge);
      if (currentPath.isEmpty()) {
        return InferredPath.getEmptyPath();
      }
 else {
        currentPath.add(PathEdge.getEmptyPathEdge());
        return new InferredPath(ImmutableList.copyOf(currentPath),distTraveled);
      }
    }
    PathEdge sampledPathEdge=PathEdge.getEdge(sampledEdge,distTraveled);
    if (totalDistToTravel == null) {
      if (belief.getInputDimensionality() == 4) {
        StandardRoadTrackingFilter.invertProjection(belief,sampledPathEdge);
      }
      movementFilter.predict(belief,null,null);
      totalDistToTravel=belief.getMean().getElement(0);
    }
    final double direction=belief.getMean().getElement(0) >= 0d ? 1d : -1d;
    if (sampledPathEdge == null) {
      belief.getMean().setElement(0,direction * currentEdge.getInferredEdge().getLength());
      belief.getMean().setElement(1,0d);
      break;
    }
    distTraveled+=direction * sampledPathEdge.getInferredEdge().getLength();
    currentEdge=sampledPathEdge;
    currentPath.add(sampledPathEdge);
  }
  belief.getMean().setElement(0,belief.getMean().getElement(0) - currentEdge.getDistToStartOfEdge());
  return new InferredPath(ImmutableList.copyOf(currentPath));
}