Program: 189425
Project: 189425
Buggy source:
@Override public void update(DataDistribution<VehicleStateDistribution<O>> target,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> resampleDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  for (  final VehicleStateDistribution<O> state : target.getDomain()) {
    final int count;
    if (target instanceof CountedDataDistribution<?>) {
      count=((CountedDataDistribution)target).getCount(state);
    }
 else {
      count=1;
    }
    final double logCount=Math.log(count);
    VehicleStateDistribution<O> predictedState=state.clone();
    predictedState.setParentState(state);
    predictedState.setObservation(obs);
    predictedState=this.updater.update(predictedState);
    CountedDataDistribution<VehicleStateDistribution<O>> childDist=internalPriorPrediction(predictedState,obs);
    predictedState.setTransitionStateDistribution(childDist);
    resampleDist.increment(predictedState,childDist.getTotal() + logCount);
  }
  Preconditions.checkState(!resampleDist.isEmpty());
  if (this.isDebug)   this.lastResampleDistribution=resampleDist;
  if (obs instanceof TrueObservation) {
    final VehicleStateDistribution<?> trueState=((TrueObservation)obs).getTrueState();
    if (!trueState.getPathStateParam().getValue().getEdge().equals(resampleDist.getMaxValueKey().getTransitionStateDistribution().getMaxValueKey().getPathStateParam().getValue().getEdge())) {
      List<Entry<VehicleStateDistribution<O>,MutableDouble>> sortedDist=Lists.newArrayList(resampleDist.asMap().entrySet());
      Collections.sort(sortedDist,new Comparator<Entry<VehicleStateDistribution<O>,MutableDouble>>(){
        @Override public int compare(        Entry<VehicleStateDistribution<O>,MutableDouble> o1,        Entry<VehicleStateDistribution<O>,MutableDouble> o2){
          final double adjValue1=o1.getValue().getValue() + Math.log(((MutableDoubleCount)o1.getValue()).getCount());
          final double adjValue2=o2.getValue().getValue() + Math.log(((MutableDoubleCount)o2.getValue()).getCount());
          return -Double.compare(adjValue1,adjValue2);
        }
      }
);
      for (      Entry<VehicleStateDistribution<O>,MutableDouble> entry : sortedDist) {
        final VehicleStateDistribution<O> state=entry.getKey().getTransitionStateDistribution().getMaxValueKey();
        final Vector distToTrueState=state.getPathStateParam().getParameterPrior().getGroundDistribution().getMean().minus(trueState.getPathStateParam().getValue().getGroundState());
        final int count=((MutableDoubleCount)entry.getValue()).getCount();
        final double adjValue=entry.getValue().getValue() + Math.log(count);
        System.out.println(resampleDist.getLogFraction(entry.getKey()) + "String_Node_Str" + adjValue+ "String_Node_Str"+ count+ "String_Node_Str"+ distToTrueState+ "String_Node_Str"+ state.getPathStateParam().getValue()+ "String_Node_Str"+ state.getPathStateDistLogLikelihood()+ "String_Node_Str"+ state.getPredictiveLogLikelihood());
      }
      System.out.println(trueState.getPathStateParam().getValue());
    }
  }
  final ArrayList<VehicleStateDistribution<O>> smoothedStates=resampleDist.sample(this.random,this.getNumParticles());
  List<VehicleStateDistribution<O>> updatedStates=Lists.newArrayList();
  for (  final VehicleStateDistribution<O> state : smoothedStates) {
    final VehicleStateDistribution<O> sampledTransitionState=state.getTransitionStateDistribution().sample(this.random);
    VehicleStateDistribution<O> updatedState=internalUpdate(sampledTransitionState,obs);
    updatedState.setTransitionStateDistribution(sampledTransitionState.getTransitionStateDistribution());
    updatedState.setPriorPredictiveState(sampledTransitionState);
    updatedStates.add(updatedState);
  }
  target.clear();
  target.incrementAll(updatedStates);
  Preconditions.checkState(target.getDomainSize() > 0);
  if (target instanceof CountedDataDistribution<?>) {
    Preconditions.checkState(((CountedDataDistribution<?>)target).getTotalCount() == this.numParticles);
  }
}

Fixed version (ground truth):
@Override public void update(DataDistribution<VehicleStateDistribution<O>> target,O obs){
  final CountedDataDistribution<VehicleStateDistribution<O>> resampleDist=new CountedDataDistribution<VehicleStateDistribution<O>>(true);
  for (  final VehicleStateDistribution<O> state : target.getDomain()) {
    final int count;
    if (target instanceof CountedDataDistribution<?>) {
      count=((CountedDataDistribution)target).getCount(state);
    }
 else {
      count=1;
    }
    final double logCount=Math.log(count);
    VehicleStateDistribution<O> predictedState=state.clone();
    predictedState.setParentState(state);
    predictedState.setObservation(obs);
    predictedState=this.updater.update(predictedState);
    CountedDataDistribution<VehicleStateDistribution<O>> childDist=internalPriorPrediction(predictedState,obs);
    predictedState.setTransitionStateDistribution(childDist);
    resampleDist.increment(predictedState,childDist.getTotal() + logCount);
  }
  Preconditions.checkState(!resampleDist.isEmpty());
  if (this.isDebug)   this.lastResampleDistribution=resampleDist;
  if (obs instanceof TrueObservation) {
    final VehicleStateDistribution<?> trueState=((TrueObservation)obs).getTrueState();
    if (!trueState.getPathStateParam().getValue().getEdge().equals(resampleDist.getMaxValueKey().getTransitionStateDistribution().getMaxValueKey().getPathStateParam().getValue().getEdge())) {
      List<Entry<VehicleStateDistribution<O>,MutableDouble>> sortedDist=Lists.newArrayList(resampleDist.asMap().entrySet());
      Collections.sort(sortedDist,new Comparator<Entry<VehicleStateDistribution<O>,MutableDouble>>(){
        @Override public int compare(        Entry<VehicleStateDistribution<O>,MutableDouble> o1,        Entry<VehicleStateDistribution<O>,MutableDouble> o2){
          final double adjValue1=o1.getValue().getValue() + Math.log(((MutableDoubleCount)o1.getValue()).getCount());
          final double adjValue2=o2.getValue().getValue() + Math.log(((MutableDoubleCount)o2.getValue()).getCount());
          return -Double.compare(adjValue1,adjValue2);
        }
      }
);
      for (      Entry<VehicleStateDistribution<O>,MutableDouble> entry : sortedDist) {
        final VehicleStateDistribution<O> state=entry.getKey().getTransitionStateDistribution().getMaxValueKey();
        final Vector distToTrueState=state.getPathStateParam().getParameterPrior().getGroundDistribution().getMean().minus(trueState.getPathStateParam().getValue().getGroundState());
        final int count=((MutableDoubleCount)entry.getValue()).getCount();
        final double adjValue=entry.getValue().getValue() + Math.log(count);
        System.out.println(resampleDist.getLogFraction(entry.getKey()) + "String_Node_Str" + adjValue+ "String_Node_Str"+ count+ "String_Node_Str"+ distToTrueState+ "String_Node_Str"+ state.getPathStateParam().getValue()+ "String_Node_Str"+ state.getPathStateDistLogLikelihood()+ "String_Node_Str"+ state.getPredictiveLogLikelihood());
      }
      System.out.println(trueState.getPathStateParam().getValue());
    }
  }
  final ArrayList<VehicleStateDistribution<O>> smoothedStates=resampleDist.sample(this.random,this.getNumParticles());
  List<VehicleStateDistribution<O>> updatedStates=Lists.newArrayList();
  for (  final VehicleStateDistribution<O> state : smoothedStates) {
    final VehicleStateDistribution<O> sampledTransitionState=state.getTransitionStateDistribution().sample(this.random);
    VehicleStateDistribution<O> updatedState=internalUpdate(sampledTransitionState,obs);
    updatedState.setTransitionStateDistribution(state.getTransitionStateDistribution());
    updatedState.setPriorPredictiveState(sampledTransitionState);
    updatedStates.add(updatedState);
  }
  target.clear();
  target.incrementAll(updatedStates);
  Preconditions.checkState(target.getDomainSize() > 0);
  if (target instanceof CountedDataDistribution<?>) {
    Preconditions.checkState(((CountedDataDistribution<?>)target).getTotalCount() == this.numParticles);
  }
}